Transparecy and fog
Yesterday I started with OpenGL, but I''ve already lerned a lot. But there are still 3 problems I have to solve:
------------------------------------------
1
If I use fog as following:
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, 1.0f);
glHint(GL_FOG_HINT, GL_NICEST);
glFogf(GL_FOG_START, 5.0f);
glFogf(GL_FOG_END, 50.0f);
glEnable(GL_FOG);
fog isn''t starting at 5.0 but it is starting right behind my screen, which is equal to 1.0 in my environment. At a depht of 2.0 all faces/object are completele coverd by fog (which means I can''t see them any more).
What do I do wrong?
------------------------------------------
2
I would like to use transparent objects, which can be done by using the Alpha-Value. In order to avoid one object being in front of another (so that I can''t see the one behind, as if the front-object was opage) i should use
glDisable(GL_DEPTH_TEST);
This is really working, as long as I dont use non-transparent objects as well. If I do so, I get rubbish on my screen (of course!).
Is there a way to use both transparent and non-transparent objects at once? Some one said I had to do do a multi-pass-rendering, but I dont know how to do taht, and I think there has to be another solution
------------------------------------------
3
My version of the help-file opengl.hlp ist corrupted. It says:
The equation for GL_EXP fog is "error with bitmap-display"
Can somebody tell me the correct equation for GL_LINEAR, GL_EXP and GL_EXP2? The Help-Topic ist named "glFogf, glFogi, glFogfv, glFogiv"
1. Sorry, I''ve never used fog so I guess I can''t help you. You may perhaps try different values ?
2. It''s a common problem. Here''s a possible solution :
glEnable( GL_DEPTH_TEST);
// draw all your non transparent polygons
glDepthMask( GL_FALSE); // Disable z-buffer writing but not z-buffer reading
// draw all your (z-sorted) transparent polygons
glDepthMask( GL_TRUE); // Enable back z-buffer writting
3. The Red Book (OpenGL Programing Guide) is available online. Search it with google, the equations must be described in the fog chapter.
Hope it helps!
2. It''s a common problem. Here''s a possible solution :
glEnable( GL_DEPTH_TEST);
// draw all your non transparent polygons
glDepthMask( GL_FALSE); // Disable z-buffer writing but not z-buffer reading
// draw all your (z-sorted) transparent polygons
glDepthMask( GL_TRUE); // Enable back z-buffer writting
3. The Red Book (OpenGL Programing Guide) is available online. Search it with google, the equations must be described in the fog chapter.
Hope it helps!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement