Water is one of the most complex shaders to render in games. Thanks to Petri Wilhelsmen's ocean shader demo, I was able to implement an ocean shader with wave ripples and light reflecting on the surface. The ocean plane is built up by vertexes and a deform shader was used to create the ocean waves using a normal map. I found a link to his sample here. The sample version of this tutorial was written in XNA 3.1 and I was able to convert it to XNA 4.0.
As shown in this image above,
I am still tweaking the resolution the texture model when scaled for big environments in my game.
My next water shader test was based on Canton Javier Ferrero's Water Shader example program. It was written in XNA 3.1 and I have successfully converted it to XNA 4.0. The XNA 3.0 version of the program was updated by David Mariscal Fernandez. You can find the original sample from the XNA Community website. In his example, he created a technique to calculate the reflection map and reflection scene first and then used a component called fresnel that calculates the angle between the surface normal and the view direction. Then the water color component was adapted. The water has real-time reflection as well. You can see a video of it in action below. I have also made the XNA 4.0 version I converted available to download below. Microsoft made a lot of changes to XNA between versions 3.1 and 4.0. Some of them are a real pain. For example, they got rid of point sprites, which many game projects with particle systems in XNA 3.1 utilize. They also got rid of clipping planes, which many projects with water planes in XNA 3.1 use to render reflections and refraction.
- Indie DB: Download