Skip to main content
gamedev.net
🔒 Locked

transparency & zbuffer

Started by der 3 replies 450+ views
Original Post
der
der
salut, does someone know how to tell opengl to write zbuffer only when alpha component of a texel of a RGBA texture is 1 and not when it's 0? And how to configure ogl in order to make it interpolate RGB but not A ? So even zoomed texures appear to have clear edges... I played a DirectX game ( shame on me ! ), namely 007 Nightfire ( again ! ), in which trees leaves were drawn this way. Edges looked rounded. Maybe it requires some GL_EXTENSION to do that ?
Ingenu
Ingenu
see alpha testing
Cause I'm a good mood I'm gonna tell you (just seen Yann L is about to write articles :) )
glAplhaFunc( GL_EQUAL, 1.0f );

They are prolly using both alpha testing (glAlphaFunc) and alpha blending (glBlendFunc), that's how we do it most of the time.
Alpha test discard fragments under treshold (0.2-0.5), and alpha blending makes sure your edge blend softly with the background.

Not sure about not interpolating A... with the tech above you don't care.
-* So many things to do, so little time to spend. *-
vincoof
vincoof
You can't interpolate RGB and A separately, unless you setup RGB into a texture and A into another texture and give different parameters into each texture. (requires multitexturing BTW).
Anyway that's not what you want.
The thing you want is using alpha testing WITHOUT blending.
Call something like glAlphaFunc(GL_GREATER, 0.5f) and glEnable(GL_ALPHA_TEST) and you'll see almost the same effect that your game provided. (feel free to change the 0.5 threshold at wish, that's just an example).

The big advantage with this method is that you get order-independant transparency (pretty obvious, since there's no blending) and you get soft edges, but then you get the problem Ingenu pointed : minified textures won't look very nice. You can still mipmap the textures to reduce this bad effect though.
AxoDosS
AxoDosS
glEnable(GL_ALPHA_TEST);
glAplhaFunc(GL_EQUAL, 1.0f);

Topic Locked

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

Sign in to reply to this topic.