Skip to main content
GameDev.net gamedev.net
🔒 Locked

Fog effect

Started by Asuralm Apr 17, 2006 at 10:12 AM 1 replies 700+ views
Original Post
Asuralm
Asuralm
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!
Asura
nefthy
nefthy
screenshot?
RuneLancer
RuneLancer
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.