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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question Stencil value per Entity?

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

  1. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    510
    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:
    288
    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:
    510
    Cool, I'll try this! Much appreciated!