Fog depth has no effect

Started by
3 comments, last by Moho 21 years ago
I have implemented fog, but the GL_FOG_START and GL_FOG_END primitives do not have any effect. I am using the fog to blend the terrain into the horizon, so would like the fog to only effect points far from the viewpoint No matter what I set GL_FOG_START and GL_FOG_END to, the fog always looks the same: float fogColor[4] = {0.0f,0.0f,1.0f,1.0f}; glFogi(GL_FOG_MODE, GL_EXP2); glFogfv(GL_FOG_COLOR, fogColor); glHint(GL_FOG_HINT, GL_DONT_CARE); glFogf(GL_FOG_DENSITY, 0.1); glFogf(GL_FOG_START, (float)5.0f); glFogf(GL_FOG_END, (float)50.0f); glEnable(GL_FOG); Can anybody explain why this is? Shaun M [edited by - moho on April 1, 2003 1:58:50 PM] [edited by - moho on April 1, 2003 1:59:33 PM]
Advertisement
GL_FOG_START and GL_FOG_END only have any effect when fog mode is set to GL_LINEAR. GL_DENSITY is used when fog mode is GL_EXP or GL_EXP2.
glFog

quote:
GL_FOG_START: The params parameter is a single integer or floating-point value that specifies start, the near distance used in the linear fog equation. The default near distance is 0.0.


quote:
GL_FOG_END: The params parameter is a single integer or floating-point value that specifies end, the far distance used in the linear fog equation. The default far distance is 1.0.


GL_FOG_START and _END only work when you are using GL_LINEAR as the fog mode.
"...."
EDIT: Do'h, I was beaten (too slow)!

That would be because you're using GL_EXP2 as the fog mode. In any EXP fog mode, the start and end have no effect, but the density affects it. Use GL_LINEAR as the fog mode, and start and end will have an effect, but the density will not.

-------------------
Realm Games Company

[edited by - greatone on April 1, 2003 2:05:53 PM]
-------------------Realm Games Company
Got it. Thanks.
Shaun

This topic is closed to new replies.

Advertisement