Hazel Whorley
Level Design

me@hazelwhorley.com

Tutorials

Environment Maps for Fluid Surfaces [UED 3]

This tutorial assumes you know how to import textures and create fluid surfaces.



Intro

An environment map is a kind of 3d snapshot of part of your level. It's used to make water and other surfaces look reflective. This tutorial will show you how to make a reflective fluid surface from scratch. First you need to make a CubeMap, this contains 6 screenshots of a point in the level from different angles. You can then make an Environment Map (TexEnvMap) and Shader to use on the fluid surface. Water Preview

CubeMap Diagram
Diagram showing the 6 environment map textures



Settings

To take the screenshots accurately from six different angles, you need to make some keybinds in the user.ini file. Go to the UT2004\System Folder and open User.ini in a text editor (it's a good idea to make a backup first). Search for the text "NumPad" and replace NumPad keys 0-6 with the following:

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)

Search the rest of the file for "NumPad" and delete any duplicate entries you find. This is to make sure the new keybinds work properly. Numpad keys 0-5 rotate the camera view to each angle for the CubeMap, and Numpad 6 returns the camera to normal.



Screenshots

When you're ready to take the screenshots, start your map and set up the view by doing the following:

Area in map to take screenshots
  1. Find the spot you want to take the screenshots and enter ghost mode (by typing ghost at the console)
  2. Type togglescreenshotmode in the console to hide the hud and weapon
  3. Change the screen display to window mode (under Settings > Display)
  4. Switch the resolution to 256x256 (or any other power of 2) depending on how big you want the screenshots. To do this, type setres 256x256 in the console.

To take the screenshots, press each Numpad key in turn (0-5) followed by F9 to take a screenshot. If your scene includes emitters or other animating effects it's a good idea to pause the game first. You should now have six 256x256 .bmp files saved to the UT2004\Screenshots folder. If you rename them, make sure the filenames reflect the order in which they were taken (e.g. cube0, cube1, cube2 etc.)

6 Screenshots



Editing & Effects (optional)

With Paint Shop Pro, Photoshop, or another image editing program you can touch up the screenshots or add effects. If you apply an effect to one image, apply the same effect to all the images otherwise you might see the edges of the texture in the envmap. Here are a few ideas:

Gaussian Blur
Gives the screenshots a softer look, good for fluid surfaces. A blur radius of 1.2 or below looks best.

Gaussian Blur

PSP7: Effects > Blur > Gaussian Blur
Photoshop: Filter > Blur > Gaussian Blur

Brightness/Contrast/Colour
You could lighten the image if it's too dark, give it more contrast or a coloured tint for water. I've adjusted the brightness and colorized the image below with a blue tint.

Brightness and Colourise

PSP7: Options under the Colours > Adjust menu.
Photoshop: Options under the Image > Adjust menu.

Retouch Tools
The retouch tools allow you to add some special effects to the screenshots, like making windows look like they glow. The dodge tool has been used on the windows below (it probably looks better on screenshots where the window has a very dark surrounding).

Dodge: Brightens an area of the image and makes it look like it glows.
Burn: The opposite of dodge - darkens an area of the image.
Blur (Soften in PSP7): Blurs an area of the image.
Lightness Up/Down (PSP7): Lightens an area of the image, effect isn't as strong as dodge.

Retouch Tool

PSP7: Click the retouch icon on the left and select the tool type in the tool options window.
Photoshop: Right-click one of the icons in the toolbar on the left, and select a tool type from the menu.



CubeMap & TexEnvMap

Making a CubeMap

  1. Open your map and import the six screenshot textures into the MyLevel package (uncheck Generate MipMaps). It's a good idea to create a new group for these textures.
  2. Before doing anything else, right-click each texture and compress it to DXT1. Your map file size will grow considerably otherwise.
  3. In the texture browser click File > New. Enter Package: MyLevel, Group: EnvMaps (or your group name), and Name: mycubemap (or other name). Select CubeMap from MaterialClass and press New.
  4. Go to the CubeMap's properties and set all the screenshots as the faces of the cube.
CubeMap Properties

Making a TexEnvMap

  1. Click File > New and enter Package: MyLevel, Group: EnvMaps (or your group name), and Name: myenvmap (or other name).
  2. In the TexEnvMap properties choose the CubeMap you made as the Material.
  3. Change the EnvMapType to EM_WorldSpace so the reflection is the right way up.
  4. You can apply the EnvMap to a surface to check it's worked! Move the camera around a bit in the editor to see the effect.
TexEnvMap Properties

Water Shader

You can apply the TexEnvMap to the fluid surface on it's own, but it isn't transparent and looks a bit like mercury, not water. There are some more advanced shader effects than this, but here's how to create a simple realistic-looking transparent water shader. By now you should have a working Environment Map, and you also need to find a water texture with an alpha channel (for transparency). I've imported my own here, there are plenty in the default packages too. You could look at water shaders from existing maps to see how they're set up.

Shader Textures
  1. In the texture browser click File > New and enter Package: MyLevel, Group: EnvMaps (or your group name), and Name: mywatershader (or other name).
  2. To make a plain shiny transparent water texture, enter the values as shown below.
  3. Depending on how the textures look, you could remove the values in Specular and SpecularityMask. It's best to try a few combinations and see what fits best with your map. Try changing the OutputBlending mode and see what happens.
Shader Setup 1

If you want the water texture to show up as well as the envmap, set the water texture as "diffuse". It depends on the textures whether or not it looks better or worse.

Shader Setup 2

Apply the shader to a fluid surface and you're done! Enjoy!

Water Preview



Resources

Example Map: tutorial_envmap.zip [0.75MB]

UnrealWiki: Fluid Surfaces and Shaders
UnrealWiki: CubeMap
UDN: Environment Maps