This is my first proper tutorial, it aims to guide you through the steps of making a realistic water environment in Blender 3D. This water setup is for real-time use, great for games.
In this tutorial I will show you, howto make the water reflective, how to add ripples, how to add underwater effects and much more. I hope that you will like it .

What you will need
Blender 2.49 or later.
Some understanding of the game engine and gen-eral Blender knowledge. If you are confused by anything in this tutorial, you may need to acquire more Blender knowledge before following it.
An animated water normal map (more on this later)

Let’s begin!
Open up Blender and delete the default cube.
Change the viewport shading type to “Texture” and in the Game Settings clik “Blender GLSL Materials”.
Press “Space” and select “Plane” to add a plane.
Press “S” and then “Ten” to scale the plane up by ten times. This plane is our water surface, so press “N” and rename it to “water_surface”.
Once this is done, add a material to the plane and name it “water_surface”. In the material settings activate “ZTransp”, to allow the plane to have transparency.

Realistic Water Environment-1.jpg

Okay. Now we will set up the logic and python for the water. In the logic section add an always and link it to a python controller. Add a property called “material”, set it as a string and enter “water_surface”. Split the 3d viewport in half by right clicking on the bottom edge and selecting “split area”. Change the new viewport to a text one and clik add new or select the script called “Text”. Now open the mirror.txt file included with this tutorial. Open it with notepad or something similar. Now copy the text and paste it into Blender’s text window. Rename the script to “mirror”.

Realistic Water Environment-2.jpg

In the python controller we added earlier, type mirror as the python script. Go bak to the always sensor and clik on the button with the three dots. This means that the sensor will trigger every frame.

Go to the texture section of the water surface material and add a new texture. Set it as an image and clik “load”. Now look on your disque for the texture included with this tutorial called “water.png”. Every reflective
object in the game must have a unique “mirror” tex-ture. The resolution or colour of the texture is not im-portant, that’s why the one included is very small. I made it blue so it looks a bit like water in the viewport.
The textures should have useful names like “water” and “water_n” for the texture explained bellow.

Now add the texture included called water_n.jpg. This is the normal map. It is what provides the ripple ef-fects. In the texture’s settings activate the “Normal Map” setting. OR Look online for a tutorial on how to make an animated normal map texture yourself. There is a very good one here.

Realistic Water Environment-3.jpg

Now change the text viewport to a UV/Image editor viewport. Select the normal map texture and clik “View” -> “Real-time properties”. Set up the real-time properties like you see in the picture bellow:

Realistic Water Environment-4.jpg

Now go to the “map to” tab for the water_n texture and deselect “Col” and select “Nor”. The “Nor” value underneath where it says “Mix” can be put up to 1.0 or down depending on how strong you want the ripples to be. Note that this is only for the ripple’s specularity.
The actual distortion comes later and is done by using nodes.
Add a new texture to the water material. Browse for radial_alpha.jpg (included with this tutorial). Give it the name radial_a, and then delete it again.

This is just to get it registered as a proper texture. We will use it in the nodes for the water fresnel.
And speaquíng of nodes, I believe it’s time for the node part of the tutori-al. This isn’t a section that I can de-scribe in great detail, as there are so many steps to making it all worque and if one section isn’t done quite right, the whole thing won’t work
So, in your water’s material settings clik the nodes button. Once this is done a little red selection box will appear further down. Instead of adding a new node, clik the arrows and select “water_surface”. Now change the UV mapping window to a node window. This is the tricky part. You will see two “windows” or nodes so to speak. The one we want to keep is the one on the right. This should always be to the right. The other one can be deleted for now (select it and press delete). This next
part I can’t explain, so I have in-cluded a large picture of just how all the nodes should be set out (node image is included in the blend file download).
The picture is called “node_setup.jpg”. You will need to look at this picture and try to copyevery node and every setting within it. To make it easier I have put a note at the bottom of them to say what each node is, so you can find them easily when adding that type of node. You can look at the final blend as a reference too if you get stuck. To link two nodes drag from one circle to the other. To delete a link between two nodes, clik and drag across the link. To add a new node clik “Add” and select the node type you think is appropriate.
The explanations in the image should help you find the necessary node type.
Once this is done, press “P” and give your water a test run. Hopefully you will see animated ripples in the wa-ter (don’t panic if you’re not, just continue), but what’s this? The wa-ter appears completely blue! To fix this, press “TAB” while the water is selected and press “A” to select all faces. Change the node window to a UV window again and you will see a plane with four vértices. Press “A” again in the UV window to select all the vértices and press “M” to mirror the mapping on the X axis. Once
this is done, you may need to rotate the mapping too so press “R” and type “180”. This will rotate the map-ping 180 degrees.
Now add a cube somewhere near the water and press “P”. Hopefully now, the water will be reflecting the cube and you should be able to see ripples. If not, look at your node setup more closely, or if it’s reflect-ing wrongly, look at you UV map-ping setup and mirror it some more or rotate it etc. Note that the water is still mostly very blue. We willsoon fix this.
I won’t tell you how to make a sky dome or anything, or it will make this tutorial very long, but básically, the water is blue because it hasnothing to reflect in the blue areas, so you need to make a skybox or sky dome and give it a sky texture.
There is one in the final blend if you want to use that.
Now would probably be a good time to add a seabed. To do this just add a plane under the water and give it any old sand texture. One is includ-ed. Now when you play the game,
you should be able to see the seabed underneath at close range, and when you play from further away the water appears opaque. This means that the fresnel texture and camera depth data is working.
Add four more planes around the water for walls. Once they are posi-tioned around the water, and look like walls select them all and press “J” to join them all together. Then press “U” when all faces are se-lected and unwrap it using a cube setting or something similar. Add a new material and texture to the walls. A brik texture is provided.

Now when you press “P” you should see the walls being reflected too. This is básically where the out-side worque stops and the underwater worque begins.
Select the camera and press “Shift” + “S” and select “Curser -> selec-tion”. This will snap the curser to the camera. Now press “Space” and add a cube. Scale the cube by around 0.1. Parent the cube to the camera (select cube, then camera and press “Ctrl” + “P”. Now create an empty in the same way, but in-stead of parenting it to the cube or camera, we are going to parent it to one of the cube’s vértices. To do this, select the empty, then the cube, press “TAB” and select a ver-tex and press “Ctrl” + “P”. We need to parent the empty to a vertex so that it follows the camera but does not rotate with the camera. Normal parenting affects rotation, but ver-tex parenting doesn’t for some rea-son. We need to keep the rotation even because the empty must al-ways be facing the same way, as it is measuring where it is in relation to the water’s surface.
Now select the water and add a new property in the logic panel. Call the property “water”. Select the empty again and in the logic panel add a property called underwater and make it a bool. Now add a ray sensor that points in the –Z direc-tion (downwards) and a sensor that points in the +Z direction (upwards). Make both the ranges as high as they will go and enable the x-ray option. In the property area, type “water”.
Add two controllers and two actua-tors. The first actuator should be a property actuator that changes the underwater property to true, and the second should change the prop-erty to false. Link them up accord-ingly. All this means that when the
empty detects the water under-neath it, it sets the underwater property to false. If it detects the water is above it, it will set the un-derwater prop-erty to true.
Now add two property sensors, two controllers and four actua-tors. The first two actuators will ac-tivate the under-water effects; the second two will deactivate the effects. So the first sensor should sense if the underwater property is true, the second should sense if it is false. Once the sensors are done, open up the file called “blur_radial.txt” and copy and paste the contents into Blender’s text window. Name the new script as blur_radial. Do the same with the file called “fog_underwater.txt”, except call it fog_underwater. In the first actuator, set it as a custom 2d filter and type blur_radial. For the second do the same with fog_underwater and make the pass, pass 1 instead of pass 0 (as 0 is taken by blur_radial). Now for the other two actuators, make them remove 2d filter actuators and set the first one to remove pass 0 and the second to remove pass 1.

Realistic Water Environment-5.jpg

Link them up so that the first two new actuators are linked to the third controller, which should be linked to the first property sensor. It should be clear how to link up the rest now. Oh, and make the cube invisible in the physics settings. Now we need to get the camera to move. Look at the screenshot bellow to see how the logic should be set up:
The highlighted names MUST be like they are in the picture. Now add another script in the text window, this time from the “mouselook.txt” file. Name it “mouselook”. Now write “mouselook” in the empty script box you now have in the logic panel. Press num-pad 0 to go into camera view and press “P”. You should now be able to fly around using the W, A, S, D keys and use your mouse to look around. If you fly underwater, everything should go foggy and the edges of the screen should be blurry and when you exit the water the effects should disappear. If not, something has gone wrong in the empty’s logic. The last step is to add another plane just slightly under the water, facing downwards. Make a new material for it and give it the water_n texture, tiled 20 times. Apply the texture as “Nor” (not “Col”). Colour the texture blue-ish and play the game. When you look at the sur-face from underwater you should see ripples. If not, mess around with the map input settings some more.

Realistic Water Environment-6.jpg

That’s all folks

And that pretty much concludes this tutorial. If you have any questions, email me at:
Now all you need to do is make a game world and a functioning game and you’re on your way to becoming a Blender pro like me xD (kidding, I’m not a pro. I’ve got a long way to go yet).
Thanks goes to martinsh for the 2d filters