View Full Version : Fog alpha values
I've been trying to fade out distant hex grid lines in my game using fog, I assumed that if I set the line color to 0,0,0,0 and the fog color to 1,1,1,1 the alpha value of the lines should increase with the distance from the camera. With the blend func GL_ONE,GL_SRC_ALPHA this should fade out the lines in the manner I'm looking for. However, the line color changes but the alpha value doesn't. I tried using glAlphaTest to show any change in alpha value and none was apparent. Does GL 1.1 suppport alpha in fog? Any ideas how I can fade the lines to transparent without using alpha?
02-15-2005, 05:07 AM
Actually you should set the fog color to exactly the same as the line color, save the alpha.
- line color (0,0,0,0) to fog color (0,0,0,1)
Thanks for the reply. However, the color seems to make no difference. I set it to white just to prove to myself that the fog was affecting the lines :)
Here's the map with white fog and increasing alpha
Here's the same shot with the fog set to 0,0,0,1
I don't get it, unless the lines alpha value is not affected by the fog.
02-15-2005, 12:45 PM
Fog alpha doesn't matter.
The specification explicitly states that the fog stage doesn't change the alpha value, so if you call glColor(r,g,b,0) you will always get alpha=zero no matter the alpha you set up in the fog color.
Thanks vincoof, that confirms what I thought.
I've managed to get the effect working using black lines, white fog and glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR)
Screenshot of fade effect (http://www.codehead.co.uk/images/hexfade.jpg)
This avoids the need for alpha values.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.