Transparent material render order problem
Hi. I an having some problems with rendering transparent objects. This is how the objects should be rendered, but I get this.
In the first image I use the Cutout Rendering mode of the Standard Shader while in the second Fade mode. So my question is how to I make the objects to be rendered correctly without using some sort of Cutout shader.
I tried to fix this by using sorting layers, changing the render Queue of the material, but it still not rendering correctly .
Answer by adehoe · Nov 21, 2017 at 04:50 AM
did you try "LightMode"="ForwardBase" "RenderType"="Transparent" "Queue"="Transparent" AlphaToMask On
Answer by Tomer-Barkan · Nov 16, 2018 at 08:10 PM
The problem with Semi-Transparent (Fade), is that it doesn't write depth. It considers the material transparent, so it will still render stuff that are behind it.
In your example, it renders the laying plane first but it doesn't write the depth of each pixel, due to the fact that it wants to keep the depth of objects behind it (since it's transparent, objects behind it may still be relevant). Then it renders the standing plane and since it didn't save the depth of the laying one, it doesn't recognize that parts of the standing plane are actually behind the laying plane (the parts that are below it) - so it draws everything even the parts that were behind. You could easily see this in action by moving the standing plane a bit back, and suddenly it will appear fully behind the laying one.
The reason changing render queue and sorting layers doesn't help, is that it only changes which one is drawn first. It doesn't solve the core problem of transparent objects not hiding those behind them - and as such do not cull objects behind them. Cutout works because if the alpha value is above the threshold, it draws it fully opaque, and as such sets the depth value knowing that anything behind it will no longer be visible.
I can't think of any simple solution. You could split the planes to parts that are in front / behind, and then it will render them in the correct order according to distance from camera. That's what I would do if I had 2 sprites, and I wanted parts of one to be behind the second, and other parts to be in front.
Your answer
Follow this Question
Related Questions
Rendering order shifts with transparent cubes (3D perspective camera, Standard shader) 0 Answers
Can I use transparent shapes to cut out doors, windows, etc, in preexisting walls? 0 Answers
Alpha shader on a game object with multiple texture tiles 0 Answers
Leaves disappear in game mode 0 Answers
Problem rendering textured quads with transparent areas 0 Answers