Jump to content
  • Advertisement
Sign in to follow this  
Asuralm

Fog effect

This topic is 4625 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!