[Shader Help] Using stencil buffer in post processing shader?

Yo. I'm trying to have a post processing effect use the stencil buffer but I just can't seem to get it to work. The stencil mask works.

image

Now, what I'd like to do is have a post processing effect that gray scales everything inside/outside of the stencil mask. I've got a simple gray scale post processing effect using Graphics.Blit

image

But everytime I try to use a stencil read in the shader it's just a black screen.

Stencil {
    Ref 1
    Comp Equal
}


If I change the it to **Ref 0** everything is shown. It doesn't work because it seems like the buffer is cleared. I've tried this and this but I just can't get it to work. Anyone have any ideas how to fix this?

Ultimately, I'm trying to make this effect.

image

Using Unity 2019.1.0f1

Comments

  • Those are 2 textures though not a gray-scale. You can see the writing is not there when looking at the active map
    Thanked by 1dark_seth
  • edited
    Fengol said:
    Those are 2 textures though not a gray-scale. You can see the writing is not there when looking at the active map
    Agree. I actually made that effect with 2 texture while trying to make this Effect below. Below was what I aimed for.





  • Shows a little from the back end
  • image

    So, I still have a stencil mask mesh. Then I duplicate that mask mesh and give it a separate layer, that's rendered to a render texture. That render texture is then fed into the grayscale post effect.

    @dark_seth are you referring to the cracking platforms? One white and one gray texture? Could you elaborate.

    seghor-rebels-036.gif
    1017 x 557 - 1M
    Thanked by 1dark_seth
  • SUGBOERIE said:
    image

    So, I still have a stencil mask mesh. Then I duplicate that mask mesh and give it a separate layer, that's rendered to a render texture. That render texture is then fed into the grayscale post effect.

    @dark_seth are you referring to the cracking platforms? One white and one gray texture? Could you elaborate.

    No actually the background that gets revealed by the mesh

Sign In or Register to comment.