Search Unity

Question Stencil value per Entity?

Discussion in 'Graphics for ECS' started by Thygrrr, Feb 21, 2023.

  1. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Is there a way to, in Shaderlab or ShaderGraph, specify a stencil value from a IComponentData with
    MaterialProperty? Is that even something that Unity's Universal Render Pipeline can instance?
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    You can try writing to the SV_StencilRef system value semantic from a hand written fragment shader, and you can use a DOTS instanced property to determine which value you write.

    However, using SV_StencilRef in this way is an optional feature, and is not guaranteed to be supported on every platform, driver, or GPU.
     
  3. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Cool, I'll try this! Much appreciated!