Archived

This topic is now archived and is closed to further replies.

dfurlo

Height Based Fog

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites