0
Not a bug

I can't get the Refraction to work.

Dan Zaidan 10 years ago updated by Freya Holmér (Developer) 10 years ago 2

I can't get the Refraction to work. I am using the Trial version of Unity Pro and the Refraction shader that comes in the examples folder works perfectly. But when I try to create a shader with refraction myself I get an error when I try to connect it.

I tried connecting it with different nodes such as multiply, power, texture 2d and value...


I'm using Unity 4.2.1f4 on Windows 7 64 bits.

I'm very new to creating shaders so it is most likely that I am doing something wrong...

Thanks.


Image 50Image 51

Answer

Answer
Not a bug

This is because refraction only allows Vector2 inputs, which should be clarified more, but it's not exactly a bug :)

+1

Refraction is a Vector2 value, which is an offset in screen space. First off, you need Transparency/Alpha in order to see refraction. Connect a value like 0.5 for started into Alpha, and make sure your shader blend setting is alpha blended.


After that, create an append node, and append the R and G channels from the normal map, and connect it to the Refraction input, and you should be set!


You *should* be able to connect a Vector 1 as well, like you tried. I'll make sure it typecasts in alpha 0.13 :)

It worked! I believe it was because I wasn't inserting a Vector2 value.

Thanks for your clarification.

Congratulations on the awesome tool! ;)

Answer
Not a bug

This is because refraction only allows Vector2 inputs, which should be clarified more, but it's not exactly a bug :)