- Home /
SurfaceOutput.viewDir not the same in deferred
I have a surface shader that I'm trying to get Fresnel working on and I'm getting strange results in Deferred rendering rather than Forward (forward looks correct). Seems to be related to the value of viewDir.
Here's the code I'm using for the Fresnel effect;
half fresnel = pow(1.0f - saturate(dot(IN.viewDir, N)), _Fresnel);
I see the same result in Skyshop's materials as well.
Anyone know how to get around this?
Answer by jvo3dc · Nov 28, 2013 at 11:04 AM
I noticed the same issue. It seems viewDir is not set correctly during deferred rendering.
My current simple workaround is to replace "IN.viewDir" with "(_WorldSpaceCameraPos - IN.worldPos)".
Of course you do have to make sure that worldPos is specified in your input structure.
Yes, I've tried that, but appears to be just as unreliable. Perhaps the root problem is something to do with one of those parameters.
Your answer
Follow this Question
Related Questions
custom Standard Shader alpha issues. 1 Answer
Colors tint at shader 0 Answers
Can I see the calculation of unity_MatrixVP ? 1 Answer
How to save a variable from the shader? 0 Answers
Flat Shading / No Vertex Interpolation 2 Answers