Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Control Passes by keywords?

Discussion in 'Shaders' started by R4s3tsu, May 14, 2023.

  1. R4s3tsu

    R4s3tsu

    Joined:
    Mar 21, 2020
    Posts:
    12
    I'm trying to make a replacement shader thats using UsePass function, but I need to select which pass to use by material, for example if the material Have certain keyword, use all passes, if don't have use only shadow caster pass.
    Code (CSharp):
    1.  
    2.     SubShader
    3.    {
    4.        Tags { "RenderType"="Opaque" }
    5.    LOD 0
    6.  
    7.        Cull Off
    8.        CGINCLUDE
    9.        #pragma target 5.0
    10.        #pragma multi_compile __ _SHADERTYPE_BODY_ON
    11.        ENDCG
    12.      
    13.        #ifdef _SHADERTYPE_BODY_ON
    14.  
    15.        UsePass "Myshader/LightingPassNode/FORWARDBASE"
    16.        UsePass "Myshader/LightingPassNode/FORWARDADD"
    17.        UsePass "Myshader/LightingPassNode/SHADOWCASTER"
    18.        #else
    19.        UsePass "Myshader/LightingPassNode/SHADOWCASTER"
    20.  
    21.        #endif
    22.  
    23.    }
    24.  
    But using ifdef condition failed to compile. How I can work around this?
     
    Last edited: May 14, 2023