Height Based Fog

Started by
4 comments, last by dfurlo 20 years, 11 months ago
Hi, Hope someone can help, cos I''m trying to hit a deadline thats 10 hours away. To get the demo level we would like to get volumetric fog that only raises that a certain height. The directx sample stuff creates a full wall a fog. Is there a way I can simple limit this to a fixed height? Thanks, Damian.
Advertisement
that would be volumetric fog, which is tricky stuff. quake 3 did it though in some levels, that may have been fake though (just on the textures, i don''t remember ever actually seeing anything in it)
I''ve seen this done with OpenGL, so I assume that directx supprts this. Surely there is some documentation on it somewhere?
it''d be pretty easy also to make this in a vertex shader, since you''d end up with the transformed vertex''s coordinates, which would make it really easy to fog based on the y coord. you would only need two constants as well, the starting height and attenuation, maybe a third for ending but not really necessary.
quote:Original post by billybob
it''d be pretty easy also to make this in a vertex shader, since you''d end up with the transformed vertex''s coordinates, which would make it really easy to fog based on the y coord. you would only need two constants as well, the starting height and attenuation, maybe a third for ending but not really necessary.

Indeed. NVidia''s DX SDK has a sample demonstrating height-based fog using a vertex shader. It''s pretty simple to do. You can check the sample if you like (requires the effects browser.) at nvidia''s developer website.



Cheers,
Muhammad Haggag

If you''re calculating your own vertex fog, you can base the fog value on the Y of the vertex.

If your hardware has T&L, you can generate the coordinates for a 1-D fog texture based on the Y value in camera space. Use CAMERASPACEPOSITION to generate the texture coordinates, then use a texture transformation matrix to output the Y as a 1-D coordinate. I haven''t used this technique myself but it might get you started in the right direction.

I think there were some papers by Jason Mitchell of ATI a few years ago that performed height based fog using the DX6 texture blending stages. You might look on ATI''s website or through some of the GDC archives.

Other than that, I''d encourage you to use vertex shaders as previously suggested.

This topic is closed to new replies.

Advertisement