Slayweb

Slayweb - UT2003/UT2004 Tutorials - Water with Cube Maps
http://www.slayweb.com

UT2003 / UT2004 TUTORIALS - WATER WITH CUBE MAPS

This tutorial assumes that you have a basic knowledge of the editor and how make terrain, if you don't know about this then you should probably find out about that first from a site such as UDN.
Knowledge of an image editing program might also be a bonus.

So, quickly first I subtracted a 2048x2048x2048 box, added ZoneInfo & TerrainInfo and copied the SkyBox from BR-TwinTombs.
Which gave me this to start with,
Basic Terrain

STEP 1: SCREENSHOTS

First of all we need to take some screenshots of the level.
These will be used later in the water reflection.
You need to take six screenshots out from a single point (North, South, East, West, Up & Down).
Load up your level with no bots and remove the HUD, the crosshair, and your weapon. (in the settings menu)
Make sure you actually spawn in the level so the following commands take take effect.
From the console (Tab key), type Ghost or Fly so you are free to move about the level.
Position yourself at water level as close to the centre as possible.
The size of the screenshots should be 256x256, or 512x512 if you're greedy for detail.
(You could use any other size, you just have to make it a square)
To set the resolution, first press Alt+Enter to set UT2004 running in Windowed Mode.
Then, press the Tab key ingame to bring up the console and type SETRES 256x256x16 and the resolution will change.
Then at the console again, type FOV 90 to set the Field Of View to 90 degrees. (Default FOV is 85)
Note: If your sky box is moving it would be best to stop it before taking you screen shots otherwise some image editing will be required to make them seemless.

Numpad keys 0-5 change your view.

Use the following bindings if you've set them to something else:
NumPad0=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=0,yaw=0,roll=16384)
NumPad1=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=0,yaw=32768,roll=-16384)
NumPad2=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=0,yaw=16384,roll=32768)
NumPad3=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=0,yaw=-16384,roll=0)
NumPad4=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=16384,yaw=0,roll=16384)
NumPad5=set playercontroller bZeroRoll False | set playercontroller rotation (pitch=-16384,yaw=0,roll=16384)
NumPad6=set playercontroller bZeroRoll True | set playercontroller rotation (pitch=0,yaw=0,roll=0)

These are the six views you need. So press the following keys,
0, F9, 1, F9, 2, F9, 3, F9, 4, F9, 5, F9
to save your six screenshots.
Numpad 6 returns your view to normal.

You should now be able to lay out your screenshots like an unfolded cube.
View 0 --> Shot00000.bmp
View 1 --> Shot00001.bmp
View 2 --> Shot00002.bmp
View 3 --> Shot00003.bmp
View 4 --> Shot00004.bmp
View 5 --> Shot00005.bmp
shot00002.bmp
shot00001.bmp shot00004.bmp shot00000.bmp
shot00003.bmp
shot00005.bmp
Now that's out of the way, on with the water.

STEP 2: WATER VOLUME

Get your red build brush and size it to the area that you want to be water.
Then click the "Volume" button and choose "Water Volume"
Builder Brush for the water Selecting a Water Volume

You will now have a pink cube in your map representing your new water volume.
(You'll have to move/hide your builder brush to see it)
Showing a water volume

STEP 3: FLUID SURFACE

So now your level has water in, you can jump in and swim etc.
But what it doesn't have at the moment is a surface.
In UT water surfaces were just a sheet, however in UT2004 they are actors.
Go into the actor browser and under "Info", select "FluidSurfaceInfo"
Selecting a FluidSurfaceInfo
Now right-click in the centre of your water area and select "Add FluidSurfaceInfo Here"
You will see in the top 2d view that this generates a sheet of triangles.
Now move this sheet up until it is just above your water volume.
You will probably find that the sheet is too small to cover the required area.
To rectify this bring up the properties of the FluidSurfaceInfo, then under the "FluidSurfaceInfo" section, change the values of "FluidXSize" and "FluidYSize".
(These values should always be a power of 2 and no greater than 256)
FluidSurfaceInfo Properties
In this case I set mine to 96.

STEP 4: SURFACE TEXTURE

You will notice that the water has the horrible default texture on it, wouldn't it be better if it had a cool transparent surface that reflected the level around it? Yes? Read On!

There are four stages to creating a surface texture for the water:
Import Screenshots, Creating a Cubemap, Creating a TexturedEnvironmentMap, and Creating a Shader.

4a: IMPORTING SCREENSHOTS

Bring up the texture browser and click on "File" and then "Import", this will bring up a file dialog box. Locate and select the size screenshots you made earlier, then press OK
Then, in the import texture window that appears;
Enter the package as "myLevel" and enter the group as "Water".
Then press "OK All"
Import Texture Window
The images will then import and should show in the browser like this:
Texture List Window

4b: THE CUBEMAP

In the texture browser again, click on "File" and this time press "New" and Material Editor will pop up.
New Material Window
Check that the package and group are still set to "myLevel" & "Water"
Enter the name as "cubemap01"
Then in the properties section, change the MaterialClass to Cubemap, and press the "New" button
You'll now see the cubemap properties window.
In the properties section, expand Cubemap and you'll see Faces. Expand Faces and you'll see blank slots labelled 0-5, Your six level shots need to go here.
Click to select shot00000 in the texture browser, then click in [0] under faces and press the "Use" button that appears.
Repeat this for 1 through 5.
You should now have something like this:
Cubemap Property Window
I don't yet know what any of the other properties here do (yet),
but they are not necessary to complete this task.
Your cubemap is now finished and you can close this window.

4c: THE TEXTURED ENVIRONMENT MAP

In the texture browser again, click on "File" and then "New" to bring up the Material Editor again.
Check that the package and group are still set to "myLevel" & "Reflection"
This time enter the name as "texenvmap01" and under properties set MaterialClass to TexEnvMap.
New Material Window
In the properties for the TexEnvMap, first change "EnvMapType" to "EM_WorldSpace",
Then select cubemap01 from the texture browser and select "Use" in the Material property.
Your TexEnvMap is now complete and should look like this.
TexEnvMap Property Window

4d: THE SHADER

Bring up the texture browser and click on "File" and then "New" for the Material Editor.
Package, "myLevel". Group, "Reflection".
This time the name should be "shader01"
Leave the MaterialClass set to shader and click "New"
There are many shader properties here, most of which I know nothing about yet. However we only need the top two for a nice water effect.
"Diffuse" is the main texture for the shader effect, so you need to select texenvmap01 from the texture browser and use it here.
"Opacity" is where you set the transparency for the shader.
This is done with an Opacity channel texture.
I have no idea what one of these is but I do know that one has been kindly provided by the peeps at epic for use in their levels.
So open up the texture package "CP_Effects1" and select the "cp_opacity_channel1_epic" texture.
Now "Use" this texture in the opacity property of the Shader and you should have something like this.
Shader Property Window

STEP 5: PUTTING IT ALL TOGETHER

Now you're ready to put your new shader onto the fluid surface.
Right-click the FluidSurfaceInfo and select properties.
Under the display section, expand the Skins section.
You will see a button labelled "Add", press this and entry [0] will be created under Skins.
Now select shader01 from the texture browser and "Use" it in the Skins[0] section.
FluidSurfaceInfo Properties
Your water surface should now be complete with a nice transparent & reflective effect.

The final result 1   The final result 2

The map file made for this tutorial is available for download: slaywebtut1.zip (1MB)