- Home /
Showing hidden units - using stencil buffer with standard shader and deferred rendering
The effect I'm trying to achieve is to show units that are occluded by the environment e.g., from the best RTS ever made:
I want to be able to get a similar effect while using 1) the standard shader (for PBR) on the models and 2) the deferred rendering configuration.
At a very high level, I want the Unity renderer to basically do this:
Perform deferred rendering pass to deferred render targets... When rendering un-occludable units, mark the stencil buffer with some value for any fragment of the model that passes the depth test
In a later pass, re-render the models with a simplified fragment shader. Only render pixels that are not marked by the aforementioned stencil value. Output the passing fragments with some color. Like blue...
This would would give a solid blue output for the occluded areas rather than the dithered blue output in the above screenshot, but that's a fine starting point for me.
The bigger question is how to do this in Unity. I'm not looking for shader code, but if someone can set me on the right path for implementing this (documentation, blog posts, etc) that would be great!!
Your answer
Follow this Question
Related Questions
Standard Shader Still Visible through Stencil Shader 0 Answers
Render a sprite only when it's on the parent but not other sprites. 0 Answers
Shadows in my rendered "Portal" Don't Render 0 Answers
Multi-shader Stencil Buffer not working as expected,Multi-shader Stencil not working as expected 0 Answers