Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

pragma multi_compile in cginc

Discussion in 'Shaders' started by trad_emark, Jun 4, 2018.

  1. trad_emark

    trad_emark

    Joined:
    Oct 9, 2015
    Posts:
    7
    Is it possible to define shader keywords in cginc shaders?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,660
    Hi!
    No, only the shader source itself is scanned.
     
  3. trad_emark

    trad_emark

    Joined:
    Oct 9, 2015
    Posts:
    7
    Thanks for the answer. May I suggest to put this information into documentation?
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,660
    Sure, I'll add it.
     
    trad_emark likes this.
  5. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    169
    @aleksandrk
    Does the unity standard shader dynamically add all of the multi compiles then, or how does that work? it is a bit tedious to add multi compiles to lots of shaders when we could just include the cginc.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,660
    Surface shaders add those when generating code, yes.
    As of Unity 2020.2 it's possible to put #pragma directives in includes, but those have to be included using #include_with_pragmas directive. This also requires turning Caching preprocessor on in Editor project settings.
     
  7. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    169
    Wonderful! I'll keep that in mind for when we upgrade. Thanks Aleks!
     
    aleksandrk likes this.
unityunity