Billboard Transparency

BlitzMax Forums/OpenGL Module/Billboard Transparency

TheTophatDemon(Posted 2014) [#1]
First and foremost, here's the link to the code

I'm having trouble with transparency in my billboards.
OK, so the textures for them are perfectly transparent (PNG), and I have GL_BLEND and all that stuff enabled. So, before drawing the sprite I disabled Depth Masking so the sprites won't show through the walls. But then the sprites render through each-other! It's hard to explain, I'll post some screenshots.




BLaBZ(Posted 2014) [#2]
Keep the depth mask disabled, and enable depth test.


glEnable(GL_DEPTH_TEST)


Kryzon(Posted 2014) [#3]
Don't use alpha blending, use alpha testing.


TheTophatDemon(Posted 2014) [#4]
Neither of these solutions worked in the slightest, and seemingly did nothing at all. What's weird is that when Depth Mask is disabled, if you look toward the left "hemisphere of rotation" it works perfectly fine, and only looks like it does in the other one.


Kryzon(Posted 2014) [#5]
The solution works, your implementation of it does not.

When rendering the billboards:

- Set the depth mask to GL_TRUE (the billboards will write to the depth buffer).

- Disable GL_BLEND. You won't use it.

- Enable GL_DEPTH_TEST (the billboards will be depth-tested with the depth buffer).

- Enable GL_ALPHA_TEST (the billboards will be alpha-tested).

- Set up the alpha testing function. You will use glAlphaFunc( GL_GREATER, 0.5 ) (only fragments that have an alpha value greater than 0.5 will be rendered on the screen).


TheTophatDemon(Posted 2014) [#6]
OK, got it working. Thanks for the replies. I'm sort of a noob at OpenGL, but I wanted a good challenge (and more FPS).