Custom Depth Write Masks

We need some custom depth write masks for a very specific use case in our project, & we’re wondering if there’s a way to have extra TStaticDepthStencilState without requiring engine changes? Attached image shows two new depth stencil states added by me to the bottom of this list with our desired behaviour, & we haven’t found an appropriate way to replicate this without these engine changes. We can make the engine changes if we need to, but wondering if there’s an alternative solution.

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into adding custom Depth Stencil states for you.

Hello,

You can try creating custom Depth Stencil states doing something similar to the following code snippet without needing to add to the TStaticDepthStencilState:

`FDepthStencilStateInitializerRHI Initializer;
Initializer.DepthTest =…
… // Set required values on the Initializer

FDepthStencilStateRHIRef StencilState = RHICreateDepthStencilState(Initializer);`Please let us know if this helps.

I think that could work, how do we actually set this custom stencil state on a component? I can only see “SetCustomDepthStencilWriteMask” which takes an enum value for the state write mask, which we don’t have here.

Right now, we have a list of actors we want to apply this masks to, & simply loop through them & all of their components, & apply the write mask. Is the same kind of implementation possible with these new states created with FDepthStencilStateInitializerRHI?

Hello,

Since you are trying to add a new write mask for Components writing into Custom Stencil, you will need to make the engine modification, adding an entry to “ERendererStencilMask”, “EStencilMask”, and “FRHIDepthStencilState* GetCustomDepthStencilState(…)”.

Please let us know if this helps.

Yeah this is the route we ended up going with, thanks for your time on this.

Hello,

Thank you for the reply.

Can we close your case? You can always re-open it if you need additional assistance for the same issue.

Yeah this should be good to close now.