void FogEffect(){
GLfloat fogColor[4] = {0.5, 0.5, 0.5, 0.5};
fogMode = GL_LINEAR;
glFogi(GL_FOG_MODE, fogMode);
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, 0.35);
glHint(GL_FOG_HINT, GL_DONT_CARE);
glFogf(GL_FOG_START, 1);
glFogf(GL_FOG_END, 5);
glEnable(GL_FOG);
glClearColor(0.5, 0.5, 0.5, 0.5);
}
Fog effect
Hi all:
I want to add fog effect to my scene. Here is my initialization of fog:
But when I run it, it produces a grey screen. All objects in the scene are not shown properly. Why is that??
Thanks in advance!
That's a very narrow range. Your fog density won't be taken into account for linear fog, but a starting and ending range of 1 and 5 means anything past 5.0f units of depth will be 100% obscured by the fog.
Try increasing the range considerably. Maybe to 20 instead of 5, or more if your objects are deeper in the scene.
Edit: Typo
Try increasing the range considerably. Maybe to 20 instead of 5, or more if your objects are deeper in the scene.
Edit: Typo
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement