PDA

View Full Version : Yet another Fog question



jota
02-27-2004, 04:10 PM
I am making a program in opengl. I have a 3dstudio max city and thought it would be cool to add fog. I have a lot of polygons in my city (~5300).

glFogi(GL_FOG_MODE, GL_EXP);
//glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, .002f);
glHint(GL_FOG_HINT, GL_DONT_CARE); glFogf(GL_FOG_START, 0); glFogf(GL_FOG_END, 5.0);

is the code i have in my init. I have a keybaord function that goes
case 'g': g_bFog = !g_bFog;
if(g_bFog)
glEnable(GL_FOG);
glDisable(GL_FOG);
break;

Now the fog enables ok and everything its just that my frame rate gets killed when fog is enabled. It goes from 55 or so to 9. I tried linear, exp and exp2. Another help in optimizing this somewhat would be great. Thanks!

chemdog
02-27-2004, 10:08 PM
See if this helps, "glHint(GL_FOG_HINT, GL_FASTEST);". And be sure to set the fog parameters only once, and not on every frame.

General speed problems can be fixed by using some algorithm to reduce the amount you are drawing. For example, you can use a BSP-tree, and this should eliminate most of the over-draw, and eliminate drawing things that aren't visible(like backsides of buildings and building that are off-screen).