Sign in to follow this  

Fog effect

This topic is 4261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all: I want to add fog effect to my scene. Here is my initialization of fog:
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);
}

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this