PDA

View Full Version : Depth buffering & transparency plz. help!



W. C. Picker
02-17-2003, 10:15 AM
I got a 32bpp texture wih an alpha channel, and a few holes in it.
Is there a way to write to the depth buffer only the texels with alpha!=0 ?

but:
Dont want to disable depth writing.
Sorting wont do because i want polygons to intersect.

I think it might be possible, cause trees made of 2 intersecting masked textures are quite common.

I'd apreciate any help

marcus256
02-18-2003, 03:45 AM
glAlphaFun( GL_GREATER, 0 );
glEnable( GL_ALPHA_TEST );

http://www.opengl.org/discussion_boards/ubb/smile.gif


The alpha test is done before writing/comparing to the color/depth/stencil buffers, so it will treat texture pixels that do not pass the alpha test as non existing. This can actually speed up rendering too, if you are fill rate limited, since alpha testing is so early in the pipeline (before framebuffer access).

W. C. Picker
02-18-2003, 03:58 AM
Thanx a lot Marcus,

but i cant get the glAlphaFunc to work

more details here:
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/011801.html