Fog

A longstanding trick in computer graphics is to add fog to a scene. Not only does fog help create a sense of atmosphere, but it also helps to avoid needing to render huge scenes, since everything further than a certain distance away becomes invisible.

The math behind fog isn’t all that complicated, which is why I was surprised yesterday to realize that a scene I was rendering had the fog exactly wrong: Everything near the camera was obscured by misty white fog, whereas objects far away remained perfectly visible.

It wasn’t right, but it certainly looked very cool. I could see entire vistas, mountains, streams and villages, with crystal clarity, going far off into the distance, even as nearby objects remained shrouded in mist.

I pored over my code, trying to understand where I had gone wrong, but couldn’t seem to find the bug. I didn’t actually understand what was going on until later that night, when I woke up in bed, and realized that the entire episode had been a dream.

So it seems that I program when I dream. I wonder whether that is a good thing. For all I know, I’m a better programmer when asleep.

But if last night was any indication, I am lousy at debugging in my dreams.

3 Responses to “Fog”

  1. It may have been a dream, but: that’s still a neat idea for a demo!

  2. J. Peterson says:

    Image? Now we’re curious to see what inverse fog looks like.

  3. admin says:

    I am not sure it would make visual sense. I’ll have to think about it. Maybe it will be clearer when it is further away. :-)

Leave a Reply