Linear Fog and glFrustum

I am using fixed function pipeline and linear fog (and for compatibility reasons I cannot changed this now).

I am rendering couple of viewpoints with off-axis glFustrum, and with different near plane distance.

The problem I am seeing is that far away object (my “skydome”) gets different amount of fog on the
different frustums.

I first thought that the reason was my different near plane, but when I scaled my frustum, so that the near planes matched the difference is still there. (I did the scaling by scaling all the frustum parameters except the far plane, at this point I was afraid that I would introduce bad far plane clipping)

I have checked that If I copy my projection matrix from the first view to the second view before sky dome rendering, then the fog seems to match, so the issue appears to be really projection matrix related.

(Yes, I am pretty sure I am not doing projection matrix abuse)

Any hints and pointers either solving this problem or describing the interaction between projection matrix and (linear) fog would be appreciated.

Eero

Make sure you are are using radial fog coord mode, not eye-plane or eye-plane absolute.

You can get alot of fogging strangeness with eye-plane and eye-plane absolute fog coord mode, especially with very wide or very off-axis frustums. The fog coord ends up changing alot even when you are just rotating the eyepoint, which is of course not realistic.

Then just ensure that your MODELVIEW transforms for the different frusta are using the exact same eyepoint and only vary in the look direction (no scales allowed), then you’re gold. Use the same fog params between frusta of course.