Skip to main content
gamedev.net
🔒 Locked

Billboarding + depth buffer

Started by clapton 2 replies 500+ views
Original Post
clapton
clapton
Hello! I wanted to ask you how would you solve my simple problem. There is plenty of ways to do that but I am curious about the most efficient one. Here is a situation - I have a 2D texture with alpha channel. When I put it on a screen some parts are translucent and some - obviously - are not. The thing is that the whole image is written into a depth buffer as a solid quad (it's not the shape of the image that appears in color buffer). My question is how can I use my color data to manipulate depth buffer just like color buffer is? Example - if one of image's pixels have alpha = 0.0 a depth value corresponding to the pixel would not change after the texture is drawn on screen. Thanks for your help :)
___Quote: Know where basis goes, know where rest goes.
Zongo
Zongo
In your case, you can use alpha testing. Sets the alpha test to pass fragments that only have an incoming alpha greater than 0.01f (for example, you could use 0). Other fragments will be rejected and the depth buffer will not be updated. The color buffer will not be updated either, but if you do standard alpha blending, it should be what you want.

glEnable(GL_ALPHA_TEST);glAlphaFunc(GL_GREATER, 0.01);
clapton
clapton
Thanks Zongo. :) It's a good idea. Though, I have a question concernig alpha testing. Do all gfx cards support it ?

Thanx
___Quote: Know where basis goes, know where rest goes.
Zongo
Zongo
Well, it's been there since openGL 1.0. Most graphic cards have hardware accelerated alpha testing.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.