fog and alpha

Fog seems to have an odd effect on translucent objects: The fog color affects them much more than opaque objects at the same distance from the viewer, and even if the alpha is 0.99, applying fog makes the translucent object much more translucent. Any idea what I could be doing wrong?

Remember when you’re blending that you are including the existing fragment in the result, thus if you overlap translucent objects you can effectively double your fog coverage.

Originally posted by Omaha:
Remember when you’re blending that you are including the existing fragment in the result, thus if you overlap translucent objects you can effectively double your fog coverage.
I don’t get that. Say I’m using white fog, and I render a triangle far enough away to be turned completely white. Then I overlap that with a triangle that’s a little closer, so it doesn’t turn completely white, and with an alpha of 0.99. The fact that there was something behind should make little difference. White fog shouldn’t be able to make anything more white that a white clear color.

Perhaps pictures can make it clearer what I’m talking about. Here’s a slightly transparent torus with white fog on its far side…

That’s not so weird. But here is what it looks like when it is approximately edge-on:

Why is the distant white shining through the near blue?

It looks like a lack of depth sorting/zbuffer.

…FYI, fog blending has no affect on the rasterized alpha (spec, page 192)…

Originally posted by ZbuffeR:
It looks like a lack of depth sorting/zbuffer.
Yet I am sorting the triangles back to front. If I turn off the fog and reduce the alpha, everything looks right.

Oops, never mind, found my bug. I was using another pass to draw specular highlights on transparent stuff, and neglected to turn off fog then. With fog off in the specular pass, things look more reasonable, at least with white fog.