What you're seeing is a defect in the fixed-function pipeline. The problem is two-fold:
- OpenGL implementations are allowed to calculate fog colors at vertices and do a simple interpolation between the vertices.
- The vertices that we interpolate between are not necessarily the corners of your triangle; they could be the vertices that OpenGL adds when it clips your triangle to the view frustum.
As we fly, the actual size of the mesh triangles is changing, as part of each mesh triangle scrolls off screen. This in turn affects the gradient of how fast we fog and what the corner fog colors are.
The results are, well, that video: fog doens't match between the runways and the ground, and the particular strange results vary as we fly.
The solution is, like all things in life, to replace the fixed-function pipeline with a pixel shader. The pixel shader can then use a per-fragment value (like the depth value) to fog. This is more expensive (well, probably not really...we have the depth value around and it's the same number of DSP ops) but will produce consistent fog across the entire area.
No comments:
Post a Comment