Water Tutorial
|
- To create a river, see River tutorial.
Water is made within the game by creating a water node, sizing it, setting its type (river/ocean/etc) and adjusting its properties.
Note: The original version of HeroBlade used mirrors to emulate water reflection. The current version of HeroBlade uses "cubemaps" to emulate two kinds of water reflection. The term "mirror" is still used, however, to indicate a water's Type.
Tutorial
- Create a place in the terrain where the water will be located, such as a lake bed. For example:
- Create a new heightmap via the Terrain panel.
- Create a depression which will be used as a lake bed with the Edit Height tool.
- Create a new mirror via the Create Menu.
- Use the Select & Translate Tool
to place the node more or less in the center of the lake bed, at the height of where "water level" should be.
- If necessary, size your mirror to the correct size using the height/width/depth Bounds Tool
- When properly sized, no yellow lines along the edge of the water should be visible, as the edges will all be "underground".
- Use the lower bound height of the water to mark out the "underwater" area; this will be used to tell the engine when a character is beneath the water's surface. Be sure to lower this past the bottom of the lake bed. (You may wish to press F2 to turn collisions off, and lower your viewpoint below the heightmap to ensure that the water is deep enough)
- It is good practice to look at the water from multiple angles, to ensure there are no bright yellow line "gaps" between the water and terrain. If a gap exists, this might cause a character to fall in between the water and the terrain.
- View the mirror's properties via the Properties Panel
- In the Color section, click on the "..." button to get a color wheel, and adjust the DiffuseColor property of the water.
- The Alpha value of the DiffuseColor determines how much the water's color shows through. A low alpha means the water is very reflective; a high alpha means not very reflective at all. Set the alpha to a low number, such as .1
- To change the transparency of the water (not the reflectivity), adjust the Opacity property to a lower number, such as .5
- Adjust WaveAmplitude to taste; this probably shouldn't be above 1.0. This adjusts the apparent height of the waves, though since water is currently just a perspective trick, you can only achieve so much with this (at glancing angles, the water will be obviously flat).
Water Type
- WaterType specifies how reflection is handled. Options are:
- PLAIN_RIPPLE - (default) True reflective mirror, which reflects the entire surrounding area, or at least everything set to Reflect. Note that this can be an enormous framerate hit, since it is effectively re-rendering the entire environment in order to reflect.
- RIVER - Simulates a reflection via a Cubemap rather than the surrounding area. The reflection is caused by small sine-wave displacements, meant to emulate river water. Note that when you select this or OCEAN, the water may temporarily disappear, until a Cubemap is chosen via the CubeMap property.
- OCEAN - Simulates a reflection via a Cubemap rather than the surrounding area. It creates a nice deep-water ocean look.
Note: Because of processing requirements, you should only use the PLAIN_RIPPLE type if you plan to raise the minimum machine spec that your player base will use, except for true mirrors. Most water should be either RIVER or OCEAN, unless you have a good reason otherwise. PLAIN_RIPPLE re-renders the entire scene every frame to create its reflection, which can seriously impact frame rate.
- Plain Ripple Water Video
Tutorial:
- Select RIVER as the water type.
- The water will disappear, as a texture has not been specified yet.
- Add a cube map (the CubeMap property).
- CubeMaps are managed via the Repository Browser. You will have at least one with Clean Engine in \Engine\CleanGame\CubeMaps\ called hero_cubemap.dds
- In the Visuals section, adjust the WaveZoomWidth and WaveZoomDepth properties to get good wave sizes, such as 5
- Pick a good WaveSpeed (9 is almost always way too fast; 1 usually works well).
- Adjust the Opacity property of the water to determine how visible things beneath the surface are. A lower value (0.1) will make the water more transparent
Swimming
- De-select the water (select some other node,
or press Escape).
- Go into character mode
- Walk your character into the water.
- If the water is deep enough,
your character should automatically begin "swimming" in the water
- Note: Swimming will only work if the mirror/water is not the currently selected object.
Well done!
Ocean Water is Confusing
Ocean water is designed to be low impact. By default it has a wave texture, and an old opaque dark blue cube map associated with it, which we of course expect you to change. But some developers have still become confused about what it takes to make nice looking water.
The simple explanation is that the side color of the lighting scheme, plus the texture for the ocean waves, plus the shader for the water, plus the diffuse color of the water, plus the opacity of the water, plus the cube map and its color (if the water color alpha is set below 1), all combine for the outcome of the over all color of ocean water. Which is very low impact, and designed to cover a large area.
Our implementation is realistic, and looks great with great cube maps and color and lighting choices. But if you don't have a working cube map in place, many strange things will happen, and the default cubemap is obviously not the one you'll want to use in your shipping product. You can of course also customize the shaders and textures associated with the water to make it do different things, but we don't recommend it to teams without relatively knowledgeable engineers or artists.
Here we whipped up a little cliff side island scene, used the default example HeroEngine Logo Cubemap, it's just 6 colored boxes in the center of white backgrounds, attached it to the water, set the water color to a light cyan and then took some screenshots with various color alpha settings, and water opacity settings, both looking into the light, and some looking into the side light. You can see that even with a strange multi-colored cubemap, I can can achieve some great looking and different styles.
Engine Level Textures
You are welcome to modify any of the default engine shader textures.
For instance: /Render/ShaderTextures/water_ocean_waves.dds. It's an eight-layer cube map used for water displacement. The RGB channels are a normal map and the A channel is used for wave height. The layers are simply stepped through linearly according to WaveSpeed * .5 * clock