Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

GLSL and FFP fog

This topic is 4517 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

I am trying to implement fog with GLSL using the FFP fog types... Here is my code.
//vs
varying vec4 fog;

void main(void)
{
    gl_FogFragCoord = gl_FogCoord;
    
    fog = vec4(exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord));
    fog = clamp(fog, 0.0, 1.0);
    
    gl_Position = ftransform();
}

/fs
varying vec4 fog;

void main(void)
{
   vec4 Color = vec4(0.0, 0.0, 1.0, 1.0);
   
Color = mix(gl_Fog.color, Color, .5);//If I set this to .5 I see the fog color I send to the fog setup functions
//this will not render the fog color???
  Color = mix(gl_Fog.color, Color, fog);
      
   gl_FragColor = Color;
}

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by 7Days
What is color use for???To simulate the fog color??


Well I just put in a vec4 for color, but it would be a base texture color...

Share this post


Link to post
Share on other sites
Hi,

I don't understand why in toy vertex shader, you use the constructor vec4 for your fog?
I think the error come from there, fog should be a float number.
Furthermore take care because according to the red book, exp does not exist in GLSL, there is only exp2 (base 2). So you can use it, using a constant to define log2.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!