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

shader variant with geometry

Discussion in 'Shaders' started by pitibonom, Apr 26, 2021.

  1. pitibonom

    pitibonom

    Joined:
    Aug 17, 2010
    Posts:
    188
    Hi all :)

    Is it possible to make a geometry shader conditionnal to shader variant ?

    Code (CSharp):
    1.  
    2.          // my variants....
    3.          #pragma multi_compile_local ___ WITH_CITY_NIGHTLIGHTS
    4.          #pragma multi_compile_local ___ OPEN_CLOSE_EFFECT
    5.          #pragma multi_compile_local ___ FOUILLIS_EFFECT
    6.  
    7.          #pragma vertex vertex_program
    8. #if defined(FOUILLIS_EFFECT)        
    9.          #pragma geometry geometry_program
    10. #endif        
    11.          #pragma fragment fragment_program
    12.  
    13.          #pragma multi_compile_fog
    14.  
    15.          #pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
    16.  
    17.  
    18.  
    I tried but got a compiler error saying there's no geometry program.

    Can a pragma be conditionnal ?

    Thanks and happy unitying ! :)
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,850
    Hi!
    Pragmas can be conditional in some cases, but not based on keywords.
     
  3. pitibonom

    pitibonom

    Joined:
    Aug 17, 2010
    Posts:
    188
    okay.

    thanks @aleksandrk :)
    Then i'll have to change material shader from script.
    I hope this won't be too heavy for mobile platforms :/

    Happy unitying !