Faces visual trough object

Hi guys,

I’m currently stuck and I need some help. Now I know there are some awesome pro people here on the forums so hope you guys can help me.

So what I got at this moment are 2 planes crossing each other with a flame texture on it. Now at this point I use a Doublesided Unit transparent shader for it,

1291987--59290--$flame.png

As you can see on the picture you can see the faces through each other. Now if been trying, and haven’t got it working…

Anyone can help me out?

Thanks in Advance! :slight_smile:

You can’t, its the classic ‘painters algorithm’ problem that occurs when you don’t have the depth buffer to correctly sort pixels/fragments. You don’t have a depth buffer because you are using transparent shader, which means depth write is disabled as its impossible to assign a depth based on the alpha, its two conflicting concepts as a depth can’t be half transparent.

There are various solutions

  1. Use a two pass shader, the first uses alpha-testing, which is a boolean operation and will give you back your depth write to correclty order the pixels, but will result in jagged hard edges. The second pass does what you have now and should only add blended/alpha aspects of the textures where the first pass didn’t render. Its a trick often used for vegitation, I think Unity uses this for its trees/leaves, so maybe check out those shader sources.

  2. Split both planes in half down the center. This will give you four planes, and should in most cases give you the correct draw order, but each split plane would have to be its own gameobject which is probably quite wasteful.

  3. Use additive blending, though unsure if it would completely fix the problem.