Archived

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

help, linear fog doesnt work right

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

if i stand at one point within my world, and rotate my view around, the fog will fade in and out, much like light did when i had it enabled, but i no longer have it enabled due to the fact that it acted strange like this (i suspected normals) do you have to have normals specified in order to use linear fog? why does the fog only work correctly if im facing a certain direction, instead of all directions?

Share this post


Link to post
Share on other sites
The fog weight is calculate in world space, that is, "between" the modelview and projection matix. But you''re probably performing your eye to world transforms in the projection matrix, which means OpenGL have the wrong eye to world matrix (which is the modelview matrix, but you put it in the projection matrix instead). Never, ever, put anything other than a projection in the projection matrix, unless you''re absolutely sure about what you''re doing.

Share this post


Link to post
Share on other sites
wow, that slowed my app down a little, but thanks for the tip, they dont mention things like this (specifically) in the open gl programming book from prima tech

[edited by - fireking on November 28, 2003 3:46:58 PM]

Share this post


Link to post
Share on other sites
here''s what happens in my frame function

0. camera is updated (no opengl functions here)
1. clear buffers
2. set matrix mode to model view
3. load identity
4. call gluLookAt with updated coords
5. calculate the frustum (glGetFloatv is used here)
6. update md2 coords
7. draw a small sky box around cam with depth test off
8. draw the terrain (we switch to texture matrix, scale detail texture, switch back to model view matrix)
9. draw md2
10. draw water
11. set fog parameters
12. swap buffers

there really isnt that much going on with matrix mode or matrix functions

Share this post


Link to post
Share on other sites
wouldnt one expect that the fog should be set up before you draw anything? how is opengl supposed to correctly blend between the fragment color and the fog color if it doesnt know about the fog? though if the params never change anyway at least all frames after the first should look right.

Share this post


Link to post
Share on other sites