Jump to content
  • Advertisement
Sign in to follow this  
Jalien

OpenGL Volumetric fog shader

This topic is 2607 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 just want to get the effect as the picture shows:
volumetricfog.jpg
I use the OpenGL extention GL_EXT_fog_coord to implement volumetric fog, but, it seems to be the whole screen is filled with fog,why?
For the purpose of studing,I want to use cg shader to implement volumetric fog.Does anyone get it?I found little information about it.
I have spent a lot of time on it,but little progress I get. :(
Any help will be apreciated.

Share this post


Link to post
Share on other sites
Advertisement
I just want to get the effect as the picture shows:
To get the "volumetric cube of fog" in the picture, for each pixel, you need to calculate the ray from that pixel to the camera, and then calculate the distance that the ray passes through the fog volume.
If the fog is a box, then you can perform a ray-box intersection test in your fragment shader to find the entry/exit points and measure the distance between them.
I use the OpenGL extention GL_EXT_fog_coord to implement volumetric fog, but, it seems to be the whole screen is filled with fog,why?[/quote]To answer "why?" you'd have to tell us what you did with GL_EXT_fog_coord, and what you expected it to do.
That extension is designed to allow you to specify per-vertex fog in the fixed-function pipeline.

Share this post


Link to post
Share on other sites
Thanks for your reply.smile.gif

for each pixel, you need to calculate the ray from that pixel to the camera, and then calculate the distance that the ray passes through the fog volume.
If the fog is a box, then you can perform a ray-box intersection test in your fragment shader to find the entry/exit points and measure the distance between them.

Maybe I should learn something about ray-box intersection." for each pixel",Do you mean that I should use pixel shader? and "perform a ray-box intersection test in your fragment shader ", or fragment shader? I just don't know how to perform piexl operation.

To answer "why?" you'd have to tell us what you did with GL_EXT_fog_coord, and what you expected it to do.
That extension is designed to allow you to specify per-vertex fog in the fixed-function pipeline.
[/quote]
The source code is on the other computer. I used it in another engine. The engine offerd an interface for us to embed OpenGL code,I just use the GL_EXT_fog_coord to implement
volumetric fog as NeHe's lesson 41,and then draw my scene. I just want to use it to simluate visibility underwater, the fog should exist only underwater.

Thanks you again.smile.gif

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!