Author Topic: Overlapping Shaders  (Read 2437 times)

MrFish

  • Posts: 201
  • Turrets: +16/-500
Overlapping Shaders
« on: May 31, 2010, 09:58:44 pm »
I've got shaders with transparencies in my map. What is curious about these shaders in particular is that they don't work well near each other or where they can overlap. The shader furthest from you ends up showing up on top of the ones closet to you. I've looked through the shader manual and didn't find anything related to this. To explain better, I made this-



I hope that's easy to understand. What can I do?

Edit:

Ok so depthwrite seems to be what I'm looking for but the closest shader covers the furthest shader not only with whats visible but anything in the transparent border is not drawn as well.
« Last Edit: May 31, 2010, 10:04:48 pm by MrFish »

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: Overlapping Shaders
« Reply #1 on: May 31, 2010, 10:19:55 pm »
If you have only fully transparent / fully opaque parts in your texture (like in your example), you should use depthwrite in combination with an alphafunc. Look at textures/karith/e8bgrate01b for example. The alphafunc GE128 will discard all pixels with an alpha value < 127, and depthwrite will write the remaining pixels to the depth buffer, so anything further away is masked out.

If you need true alpha blending, the renderer would have to sort the surfaces back-to-front for correct rendering, but the renderer sorts only by shader type (skybox, opaque surface, transparent surface, particle, etc.).

MrFish

  • Posts: 201
  • Turrets: +16/-500
Re: Overlapping Shaders
« Reply #2 on: May 31, 2010, 11:39:45 pm »
Ok thank you.