Woo! Multiplying the sprite color by 1-FogAlpha was the solution.
And I disagree with you saying it is approximate. The equation I used is exactly the same equations used when the card blits sprites with alpha on the screen. There's nothing approximte about my solution. It's exactly how the card would fog something internally. And it looks exactly the way you would expect it to and the way I want it to.
(Assuming you don't take the alpha channel of the sprite into account... I did not qhen I wrote those equations. I don't know how that affects it. But the results with my antialiased sprites with alpha channels appear to be correct, so I think in the end it didn't matter.)
What's wrong with just multiplying the sprite by a color calculated depending on the fog distance?
Because that would produce entirely the wrong result, if the fog color is not a shade of gray. I have red birds with white wings. My fog is blue. If I multiplied the bird's color with blue, then I'd get bright blue wings, and a black body. That's the first thing I tried. :-)
Also, I wanted fog to work right cause other people use my sprite system and I had implemented this kludgy solid_glow thing to allow you to make sprites flash white. Now you can do fog, and do the flashing in a non-kludgy way.
And I disagree with you saying it is approximate. The equation I used is exactly the same equations used when the card blits sprites with alpha on the screen. There's nothing approximte about my solution. It's exactly how the card would fog something internally. And it looks exactly the way you would expect it to and the way I want it to.
(Assuming you don't take the alpha channel of the sprite into account... I did not qhen I wrote those equations. I don't know how that affects it. But the results with my antialiased sprites with alpha channels appear to be correct, so I think in the end it didn't matter.)
What's wrong with just multiplying the sprite by a color calculated depending on the fog distance?
Because that would produce entirely the wrong result, if the fog color is not a shade of gray. I have red birds with white wings. My fog is blue. If I multiplied the bird's color with blue, then I'd get bright blue wings, and a black body. That's the first thing I tried. :-)
Also, I wanted fog to work right cause other people use my sprite system and I had implemented this kludgy solid_glow thing to allow you to make sprites flash white. Now you can do fog, and do the flashing in a non-kludgy way.