Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add fog in my scene which contain transparent textures made by Blend ,

when i enable the fog the transparent textures appear white From a distance but when i disable it the textures appear well.

What is the solution to the problem of whiteness?

Fog Code:

GLfloat fogColor[4]= {0.5f, 0.5f, 0.5f, 1.0f};
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, 0.35f);
glFogf(GL_FOG_START, 1.0f);
glFogf(GL_FOG_END, 1000.0f);

Screenshot From Opengl

share|improve this question
Can you post a screenshot of the problem, and the relevant parts of your code (how you set up blending for your transparent textures, and how you do fog)? – Nathan Reed May 18 '12 at 17:08
about how i set up blending i'm just write glBlendFunc(GL_SRC_ALPHA,GL_ONE); and before glBegin(GL_QUADS) i'm enabling blend glEnable(GL_BLEND) and after glEnd() i disable it glDisable(GL_BLEND); – MhdAljobory May 18 '12 at 18:16
Have you considered getting rid of old OpenGL and switching to shaders? – Bartek Banachewicz Jun 24 '12 at 9:45
up vote 4 down vote accepted

The fog is working as it should work in fixed pipeline. It won't change, because fixed-pipeline support has been dropped.

Today is rendering done with shaders - GLSL.

Fog can be easily implemented in fragment shader:

uniform float fogStart;
uniform float fogEnd;

void main()

    fogFactor = (gl_FragDepth-fogStart)/(fogEnd-fogStart);
    fogFactor = 1 - clamp( fogFactor, 0.0, 1.0 );

    gl_FragColor = vec4(, gl_FragColor.w * fogFactor);

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.