I've always been daunted by the thought of having to program water for my game, but this week I finally went for it and programmed the wet stuff! Check out my dev log video below, or read more about how I created the water under the video.
Features:
- Reflection: By adding a couple of extra render parses I was able to create some neat effects for reflection and refraction. The reflection is rendered to a texture by moving the camera under the plane of the water and rendering everything above the water's plane. This texture could then be clipped to the water's surface in a subsequent render parse.
- Fresnel Effect: The reflection and refraction textures are blended together using the Fresnel calculation. This means that when you look straight down into the water it appears very transparent, but when you look across the water's surface at a low angle it appears almost completely reflective.
- Distortion: To give the illusion that the water surface is moving I used a du/dv map. This map is similar to a bump map, but the red and green value at each pixel represent the x and y texture coordinate offset at any given point on the water's surface. By moving two of these maps over each other and taking the average of the two maps before using the values to distort the reflection and refraction textures the water appears to move.
- Specular Highlights: Finally, I wanted the water to appear shiny, and to shimmer in the sunlight. For this I used bump mapping and 2 moving normal maps to get the normal at each point on the water's surface. I used these normals in a fairly standard specular lighting formula to create the specular highlights.
So that's it for another week! Thank you very much for reading :) Next week I'm working on adding sound and music into the game! If you want to see more of my dev log videos then check out my Youtube channel, or you can see a load more pictures and updates on my Twitter page.
Your dev log videos are great! Especially considering I am currently studying the development and design of games and one day hope to create some of my own, having every part of your development progress explained is fantastic. So thanks for the knowledge and keep up the good work!
I found out about you yesterday and watched everyone of your videos in one day on youtube. Keep up the good work!
Great devlog, nice to see how things are created.