Page 1 of 1

Stencil test performance question

PostPosted: Sat Jan 05, 2019 8:37 pm
by mossman
Hello,

I want to know if a shader without a stencil test consumes less than a shader with a stencil test with default values (
Ref 0, ReadMask 255, WriteMask 255, Comp always, Pass keep, Fail keep, ZFail keep) or is the same.

Thanks

Re: Stencil test performance question

PostPosted: Tue Jan 08, 2019 10:08 am
by Amplify_Borba
Hey there, performance will always depend on the shader's complexity, features used and the target device, so the most accurate answer you can get is by testing the shader on your target hardware and measure what happens.
You can use the RenderDoc and GPUOpen tools to benchmark your shaders, or even Unity's frame debugger, as it can be hard to predict how certain operations would perform under different shader types.

Specifically regarding Stencil, in some cases you can gain performance by discarding pixels as they won't have any further operations performed on them, however, this might not always be the case.

Re: Stencil test performance question

PostPosted: Thu Jan 10, 2019 6:46 pm
by mossman
Ok Many thanks is very useful.

Re: Stencil test performance question

PostPosted: Fri Jan 11, 2019 11:37 am
by Amplify_Borba
No problem, always happy to help!