0
W trakcie analizy

view/normal/light directions maybe in wrong place in the shader code

inkipinki 9 lat temu zaktualizowano 9 lat temu 2
Hello,

If i want to use some lik this:
Image

I got the error from unity:"undeclared identifier 'normalDirection"

Which i find a bit wierd, because here is the interesting part of the shadercode:

----
float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (mul( UNITY_MATRIX_MV, float4(i.normalDir,0) ).xyz.rgb.rg*_Refraction*pow(1.0-max(0,dot(normalDirection, viewDirection)),_FresnelExp)); float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
/////// Vectors:
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
float3 normalDirection = i.normalDir;
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
float3 lightColor = _LightColor0.rgb;

---

if i move the "/////vectors:" above the other 4 lines, it works fine, but i have to make this change each time shaderforge recompiles.


Could someone shed some light on this?!

Thanks!
W trakcie analizy
This is due to how the shader compiler works. It's currently not prioritized I'm afraid, because these changes tend to cause other issues as well :(
Okay, thanks :(

Good job man :