Question on Fog...

Started by
4 comments, last by zaNeXuS 21 years, 11 months ago
With OGL, is it possible to limit your fog to a certain height on your y-axis? --------------- Gaming is Life ---------------
---------------Gaming is Life---------------
Advertisement
To put it bluntly... no.

To give more info, there is no way of getting OpenGL''s fog to do that.
You could implement some sort of "volume fog" where it only fog''s polys with a y value less than your give number. I''m not sure how this would look (I''m quite sure it wont look good) but it''s a quick and easy way of doing it.
To do it properly you need to use "proper" volume fog. This involves another entiym to define where the fog is, then tracing a line from the camra to the poly (per pixal or per vertex should work) then and seeing if the line pass'' throgh the box.

Sorry if this don''t make as much sense as it could but I was up all last night

Anyway there are a few articals here on gamedev.

Ben Gosney.

"There''s a war going on out there... and it aint easy" - Hardwar
Please excuse my grammer, I'm from zomerzet
It is doable with the FOG_COORD_EXT.
There is a very simple way to achieve layer-fog, even on non-extended openGL. Use a fog-table in a texture. Y represents height, X is the range. Fill it with whatever fog distribution you like, you can even animated it with a noise function.

For every vertex of the scene you draw, compute it''s index into the fog texture (you can do that on the CPU, or if HW can do it, in a vertexshader). Now all you have to do perpixel is interpolate between your normal fragment colour and the fogcolour, based on the alpha value of your fog texture. This requires a second texture unit.

The results look awesome. There is a demo over at nVidia''s developer site.

/ Yann
draw the scene
enable a clipplane
enable fog]
draw scene (where the fog will be)

http://uk.geocities.com/sloppyturds/gotterdammerung.html
Thx for the replies ppl. Obviously the normal usage of OGL fog won''t work. I figured this out when I saw that you''ll have to clear your background to the same colour as the fog colour... Well, this applies to a space map, which I''m creating. The end effect that I''d like is to just have a fog layer on the main floor of the map, but there was actually no fog at all, the faces of all the polygons was just given the right texture colour so it looked like fog.

Anyway, I''ll try to implement your suggestions, thx!!!

---------------
Gaming is Life
---------------
---------------Gaming is Life---------------

This topic is closed to new replies.

Advertisement