+1
Fixed

Fresnel node plugged into Alpha Clip creates error

msperling 10 years ago updated by Argento Dragone 10 years ago 7
Just plug a Fresnel node into the Alpha Clip of the Main node and see the material go pink.
Examining the code reveals that the clip function and its parameter (Fresnel based on viewDir and normalDir) gets evaluated before the actual viewDirection and normalDirection vectors are being calculated.
So this is a case of postponing the clip function after the Fresnel can be calculated correctly. Clip is probably first because of getting rid of fragments that don't need further calculations thus saving performance. Doesn't work in this case. :)

Answer

Answer
Fixed
This has now been fixed in 0.34
Same with lightDirection... variable gets used in clip call before it has been declared.
I am on a shader thats clipping fragments based on their distance to a plane. For testing purpose I also had the shader go pink when dotting the worldPos with a constant vector3 and putting the result into alpha clip.
Under review
It's as you predicted, due to it discarding as early as possible, which makes it stupid in cases like this.

The dependency system in SF is awful at the moment, so things like this can naively be fixed in two ways: Postpone the clipping until after all the node variables have been set (damaging the performance of the shader), or spend lots of time remaking the entire dependency system into something sensible.

Perhaps I can move it down for now, until I remake the system for something better
Sounds like a viable hotfix solution for now. Enables prototyping of these kind of shaders.... and for optimization there's always the option to restructure the shader source code.

Just make a note somewhere for when you come around to overhaul the dependency system. So it doesn't come knocking at your door unprepared. :)
Answer
Fixed
This has now been fixed in 0.34
Just ran into this problem with Refraction (v 0.36)
This should go away in 0.37
*Salute*
Just thought I'd mention it. :)