+1
Fixed
Fresnel node plugged into Alpha Clip creates error
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. :)
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
0
Answer
Fixed
Freya Holmér (Developer) 10 years ago
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.
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
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. :)
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. :)
Customer support service by UserEcho