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

  • \$\begingroup\$ 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)? \$\endgroup\$ May 18, 2012 at 17:08
  • \$\begingroup\$ 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); \$\endgroup\$ May 18, 2012 at 18:16
  • 1
    \$\begingroup\$ Have you considered getting rid of old OpenGL and switching to shaders? \$\endgroup\$ Jun 24, 2012 at 9:45

1 Answer 1


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.xyz, gl_FragColor.w * fogFactor);


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .