#Is there a way to get a Stencil code block in ShaderGraph?

1 messages · Page 1 of 1 (latest)

tight pewter
#

My project makes extensive use of stencils and most shaders I write use HLSL directly, but some are complicated enough that Shadergraph makes more sense. That said, I have yet to find a way to get stencil shader code inside shadergraph, so after I finish authoring my shader, i have to open up the code and manually add:
_StencilComp ("Stencil Comparison", Float) = 3
}
SubShader
Stencil
{
Ref 3
Comp [_StencilComp]
Pass Keep
}

Which does work, but it breaks all the inspector formatting and makes it so if I need to make an adjustment to the shader i need to open the original, make the adjustment, and then readd this code each time.

Is there a way to add this code inside ShaderGraph, or are there plans to in the future?

acoustic shell
#

As far as I know, no, there is no way to add this code into shadergraph, or plans in the future.

Usually, stencil operations in URP are handled through RendererFeatures, you should be able to get away by filtering your objects by layers and user the RenderObjects RendererFeature to draw them with a custom stencil operation.

Now, if you really want to edit the stencil in the shader code, and not have to do it each time, I think you can hack a solution by writing an import post-processor that would inject the stencil logic in the generated shadergraph code.

misty beacon
#

We have received a lot of requests for this particular feature, so seeing all of the interest in it goes a long way toward moving it further up the list of things we want to implement in future releases.