- Home /
How To Cull Adjacent Transparent Faces
For the project I'm working on, I have a cluster of semi-transparent rectangular prisms directly adjacent to one another. The picture below shows what it looks like. You can see here how you can see the adjacent semi-transparent faces ( the ones on the sides ). My question is, is there a way ( whether it be with layer or what ) that I can cull these faces so they are not drawn?
I.E. I basically I only want the closest transparent face to be drawn. Any help is greatly appreciated!
Answer by FortisVenaliter · Jan 26, 2017 at 06:20 PM
So, this is because of draw order. When drawing transparent objects, you have to draw back-to-front, in terms of the depth buffer, so they can properly blend the colors with what is behind them. Unity normally does this on it's own, but it can only do so much.
There are a couple ways to correct this, but none are particularly easy.
The best way to do it would be to build the mesh in code to draw the bottom faces first, then the sides, then the top, in terms of the mesh's vertices. But that would require all transparent tiles to be in the same mesh.
The other thing you can do would be to make the bottoms and sides of the tiles their own mesh with an opaque shader, and then the top tiles with a transparent shader. Opaque objects are always rendered before transparent.
Your answer
Follow this Question
Related Questions
Hiding sections of arbitrary models that lie one side of a plane 0 Answers
Use material with transparency to mask lensflare 0 Answers
Occlusion, hiding an object within a transparent box. 0 Answers
Objects behind transparent objects (sometimes) not drawn. 0 Answers
Backface Transparent Diffuse Shader 1 Answer