PDA

View Full Version : Using standard fog for transparency



LaSerDance
01-29-2004, 01:47 AM
To prevent objects from suddenly appearing at my far clipping plane (in a big scene) I want them to fade in when they enter de view frustum. To do that I setup standard fog with color 1,1,1,0. I set the start of the fog at 10m before the end of my frustum and the end of the fog right at the end of the frustum. Looking at the formula's in the openGL book: C=fCi+(1-f)Cf I expect my objects to be transparent when f=1 because I made the fogcolor transparent. However, it seems like it doesn't matter what the alpha value of the fog is, it only changes the color of the objects, not the transparency. Does anyone know WHY this is ? And maybe how to get the effect without using vertexshaders ?

AdrianD
01-29-2004, 02:14 AM
you can accomplish the same effect with a 1D-RGBA-texture with the fog-ramp and a properly set texgen. if you can't waste a texture unit for this you can also do it in multipass. in the first pass write into alpha only, and in the second pass use glBlend(GL_DST_ALPHA,GL_ONE_MINUS_DST_ALPHA);

LaSerDance
01-29-2004, 05:03 AM
good idea, thanks !