How to correctly apply direction to reflection from unity_SpecCube0
Hi Everyone,
I am writing a surface shader which is supposed to reflect the world around it using the built in Unity Reflection Probes. I have the following code:
float3 reflectedDir = reflect(IN.viewDir, normalize(o.Normal));
fixed4 unityReflTex = (UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, reflectedDir));
fixed4 reflcol = (smoothstep(1 - (_RimThick*4), 1.0, dotProduct)) * unityReflTex ;
What do I need to do to the reflectedDir float3 in order to make it position the unityReflTex correctly? At the moment, it seems like the reflection is affected by the UVs of the object.
I could just use the worldRefl from the input, but this doesn't bend with the normals of the object.
Thanks in advance!
What do you mean worldRefl doesn't "bend with the normals of the object"? If you are using normal maps, you have to use INTERNAL_DATA and calculate the WorldReflectionDir () in the surface shader.
@Namey5 This is exactly what I needed! Thank you very much. I used WorldReflectionVector (IN, o.Normal) which I found in the documentation. $$anonymous$$any thanks.