3 answers · asked on Building a Snow Shader

Snow doesn't gradually apply, but rather switches on and off

I was following the tutorial and got to the point at 11:10 in the video, where you apply the material to the rocks. What happens in my project is that the shader either applies the snow to the entire rocks' surfaces, or not at all - it doesn't respect the dot product like it does in the video. I also tried out the "ShaderSchool_Examples_Snow_Basic" material, and the same thing happens.

I'm suspecting something wrong with the dot product calculation, but I'm not sure why it works on your version, while it doesn't work on my version, when they're both the same.

Does anybody see the problem? Again, I'm using the example shader provided from the downloads. 

Snow amount > 0:

Snow amount <= 0:

  • crew
    Jonathan Gonzalez

    I would need to see your shader code in order to determine what the issue could be. I tested the project files again just in case something was wrong with the shader but it worked fine for me. The only thing I can think of is that indeed the dot function or something related to that is not working properly. Also make sure that your shader and the one from the project files has a different name, both the file and also within the shader itself otherwise you might be using the exact same names and not seeing a difference in the files. 

    • a-n-d-re

      I created a new project from scratch and imported the download files just in case I had any duplicate names. I loaded the included scene called "Snow_Basic", and the rocks are set up to use the shader called "ShaderSchool/Examples/Snow_Basic".

      I have an ASUS ROG gaming laptop with an NVIDIA GeForce 980M graphics card, if that's useful information. I just updated the graphics card driver, and the problem persists both before and after the driver update. I am using Unity version "2017.1.2f1 Edu". 

      I tried using the "Snow_Fade" scene, and this one fades like it's supposed to. Still not sure how my project doesn't calculate the gradual snowiness though. 

  • crew
    Jonathan Gonzalez

    By the way the check for the dot product against the snow amount should be greater than or equal to. If you just have greater than or less than, then it won't work properly. With the greater than or equal to it will allow the entire rock to be covered in snow or not at all but we can also have snow gradually added on. 

    Check to see if you have this line written out exactly:

    if(dot(WorldNormalVector(IN, o.Normal), _SnowDirection.xyz) >= _SnowAmount)

    I assume you have everything within that if statement setup correctly as snow is visible, but just not gradual.