When and Why use Pass in SubShader?

TextureShader has Pass section, but this SurfaceShader doesn't have Pass... why?

  • adrian replied

    Hey ssaitot ,

    I must confess, I am not a unity expert.
    As I understand it, the information in the Pass block is passed to the GPU.

    In the lessons, when using the Pass block only information that will not change regular, such as color, will be passed to the GPU.

    However when creating a shader that will interact with light, such as shadows, this will change constantly, so the info is not passed to the GPU.

    The rock texture shader used, has a Pass block, the shadow shader is, added or overlaid, on top of the texture shader.

    Passing info to the GPU means storing the info in the GPU memory, it would be a waste of memory resources to store info that is constantly changing.

    More complex shaders can have multiply passes, and you don't have to use a Pass block at all, but for redrawing color for example, every time the light direction, or camera position changed is not a very efficient use of resources.

    Check Unity Manual - Pass for more info.

    I hope this makes sense.

  • Hiro SAITOT(saitot) replied

    Thank you Adrian, now I think I understood more than before :)