teaching machines

Feature 7 Post Mortem

Adding fog to my scene was one of the easier additions to my walkabout scene that I’ve done thus far. I got it to work on more or less my first try, although there was a lot of tweaking to be had after that. After watching the video on fog, I decided that I wanted to create my fog in the second manner, as I thought that would be the most realistic.

Most of the steps for creating fog were taken from the video, although I did make a couple changes. The biggest was that I define my fog in eye space instead of in world space. Originally I wanted to simply draw my fog in the 128 x 128 space over my terrain, but Chris suggested a better idea to me: to define the fog in eye space so that it moves with the camera. This way the fog is always perpendicular to the camera–I had some concerns about the camera looking at the fog from the side so that it wasn’t visible. Defining the fog in eye space coordinates was easy once I realized how to do it (with some help from Chris), and I accomplished it in the following manner. Now I didn’t have to multiply by the camera’s view matrix in the shader, since the coordinates were already defined in relation to the camera.

After this my fog displayed as I expected. The part that took me the longest to get right was how opaque my fog should be and how many planes of fog I should draw. If the fog was too opaque the program was slow and one could tell there were many planes of it, but if it was too see-through  it was unnoticeable. I finally decided on the following amount of loops for my drawing and an opacity of .02 times the original alpha value.

Lastly, I defined a variable that defines whether or not the fog should be drawn. My program starts with the fog not drawn, simply because it takes a lot of processing power to draw it. The camera movement is also very slow when it is there. If one wants to see the fog, they simply need to push r, and then it will appear! Pushing r again will toggle it back off.

And of course, here is a video of my fog:

http://www.youtube.com/watch?v=x39bBwl292w&feature=youtu.be

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *