- Home /
Shader that renders pixel with highest alpha value?
How do I create a shader that, at each pixel, renders the object with the highest alpha value (AKA most opaque) while ignoring more transparent pixels, regardless of their z depth?
I'm very new to shaders, but I read about Stencil shaders and was wondering if you could compare the reference values using the alpha value of the object. The shader would not have additive alpha blending, etc.
I currently set the alpha value of my objects using a custom Mesh by setting the colors of the mesh's vertices in script.
I've created a simple demo below, with three quads with varying transparency values overlapping. As you can see, although the white square has the highest transparency value in the middle, you can still see a hint of blue and red over the white.
No, not a cutout shader. I've updated the post to be more clear about what I mean!
Did you ever find a solution to this? I need something similar to stop 2D drop shadows with faded edges overlapping. Thanks
Your answer
Follow this Question
Related Questions
Stencil Shader no longer working with Lightweight Render Pipeline 1 Answer
My object keeps rendering the object in the back first using stencil buffer 0 Answers
See backside of a transparent emissive shader? 0 Answers
Help me understand stencil shader logic 1 Answer
Multi-shader Stencil Buffer not working as expected,Multi-shader Stencil not working as expected 0 Answers