0
\$\begingroup\$

I am using Unity 2019.3 and I have a custom shader A which contains the code

Stencil{
     Ref 5
     Comp Equal
     Pass Keep
}

And the other custom shader B contains the code

Stencil{
     Ref 5
     Comp Always
     Pass Replace
}

The stencil test can do the right thing only if I add Fallback "Diffuse" in B, otherwise, it's never working. And A has no code related to Fallback.

Since shader A is using for post processing and I did something like

    buffer.SetGlobalTexture(ShaderID._MainTex,source);
    buffer.SetRenderTarget(destination);
    buffer.DrawMesh(mesh,Matrix4x4.identity,material,0,pass);

The material uses shader A.

Does this cause the issue because before today, I never use the Fallback during stencil test.

PS. You can use this and scene named SSS as example. In that scene the shader named Unlit/PBR has this issue. If you delete Fallback "Diffuse in that shader, the post processing effect never works.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I don't think we have enough information about what these shaders are doing or how you're using them to reproduce the issue. Can you ensure your question contains a Minimal Complete Verifiable Example? \$\endgroup\$
    – DMGregory
    Dec 17 '19 at 12:30
  • \$\begingroup\$ Please post the MCVE in your question itself, not as an external link. \$\endgroup\$
    – DMGregory
    Dec 18 '19 at 3:54
  • \$\begingroup\$ I've edited the question, now you'll have a more clear view of this issue \$\endgroup\$ Dec 18 '19 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.