Feature 6 Post Mortem

Generating water for my walkabout wasn’t difficult, as most of the process involved following Dr. Johnson’s video, but there was one change I had to make that stumped me for a while. My water is simply a 2-dimensional plane that I sized so that it would fill one of the lower parts of my terrain. I generated 3D noise with the Field3 class provided and used it to make my water move. All of this was done according to the method in the video.

Loading in my texture was done with the following code:

None of this really gave me trouble, although orienting the water obj and sizing it so that none of the edges of the plane could be seen took some fine-tuning. I was lucky that part of my terrain was dipped down and allowed for a rather large amount of water.

Adding time to my water and changing the onDraw() method wasn’t too hard either, nor was getting the skybox to reflect off the water. The hardest part was getting the actual ripples to appear on the water. At first the time float was working and the water was changing with time, but no ripples were visible and the water was as smooth as a mirror. The clouds from my skybox were moving on the water, so “time” was changing, but the water still looked flat. After awhile I realized I wasn’t setting ftexcoord, the out variable in my vertex shader. I tried just passing a vec2 of the position x and z values through, but this caused only a small portion of the water to change. Eventually (with some instructor help), I settled on a vec2 of position.x / obj width and position.z / obj height. I hardcoded the width and height in, which doesn’t make the shaders very extendable. I contemplated passing the height and width in as uniforms, but I realized there was still no way to get these directly from the obj file and would have to hardcode them in anyway. My final vertex shader looked like this:

After this my water was finished. Lastly, here is a video of my water. The skybox still looks horrible, but the only reason I included it as a part of this video was so the water would have something to reflect.

http://www.youtube.com/watch?v=im-Ct013La8

Comments

Leave a Reply

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