Water Page

From C4 Engine Wiki

Jump to: navigation, search

The Water Page is a tool page in the C4 Engine World Editor. It can be displayed by selecting Water from the Page menu.

Shown below, the Water Page contains a single tool that is used to create new dynamic water surfaces and a popup menu with additional commands pertaining to water.

Image:page_water.png


Menu Commands

The menu button in the upper-right corner displays a menu of commands when clicked.

Command

Description

Generate Land Elevation Data

For the selected water geometries, this generates per-vertex information that includes land elevation and gradient data. This data can be accessed in a shader using the Vertex Geometry process.

Remove Land Elevation Data

For the selected water geometries, this removes any land elevation data that was previously generated.

Rebuild Water Block...

This command opens a dialog that allows you to change the dimensions of the water mesh in a water block and change the directions for which horizon water geometries are built. The old water geometries are deleted and replaced by new water geometries. Any previously generated land elevation data is lost and would need to be regenerated.

Import Wave Data...

Imports wave data from a .wat resource that was previously created with the water console command (see Warm-Starting Water Blocks below). After wave data has been imported, then starting wave positions are visible in the World Editor.

Remove Wave Data

Removes wave data from all water block nodes.


Water Block Settings

The following settings are shown under the Water Block tab in the Node Info window for water block nodes.

Command

Description

Minimum land elevation

When land elevation data is generated for a water geometry in the block, this value determines the minimum elevation that will be stored. An elevation of zero represents the flat water surface, and higher elevations go upward, so the minimum elevation is typically a negative value representing land that is underwater.

Maximum land elevation

When land elevation data is generated for a water geometry in the block, this value determines the maximum elevation that will be stored. An elevation of zero represents the flat water surface, and higher elevations go upward, so the maximum elevation is typically a positive value representing land that is above water.

Maximum land test elevation

This value determines the maximum elevation from which test rays are fired when generating land elevation data.


Water Controller Settings

The following settings are shown under the Controller tab in the Node Info window for water block nodes.

Command

Description

Wave speed (m/s)

Specifies the transverse speed at which waves propagate through the water.

Viscosity

Specifies the viscosity of the water. Higher values cause the water to be more gooey so that waves die down quickly, and lower values make the water thin so that waves continue for a long time.

Maximum always awake distance (m)

Specifies the distance from the camera for which a water geometry is always awake regardless of whether it is visible. This is typically a small value (in terms of the size of a water geometry) that ensures that water near the camera continues to be simulated all the time.

Minimum always asleep distance (m)

Specifies the distance from the camera for which a water geometry is always asleep regardless of whether it is visible. This is typically a large value that causes distant water geometries to go to sleep in order to increase performance.

Invisible time before sleeping (s)

When the distance to a water geometry lies between the maximum awake distance and the minimum asleep distance, the time specified here determines how long the water geometry stays awake without being visible before it decides to go to sleep.

Enable random waves

Specifies whether random wave generation is enabled for a water block.

Maximum wave elevation

Specifies the maximum elevation of randomly-generated waves.

Position count (per geometry)

Specifies the number of randomly-selected points within each water geometry at which a random wave is generated each step of the simulation.


Warm-Starting Water Blocks

Since wave generators do not run in the World Editor, water geometries always begin in a perfectly flat state when a world is played. Only after wave generators have been allowed to run for a while does the water surface reach an equilibrium state of constant wave complexity. In order to provide a way to "warm start" the water surfaces in a world so that they are initially in a wavy state, the engine includes a wave export/import mechanism.

Exporting Wave Data

Wave data can be exported to a .wat resource by using the water console command while a world is being played. Before exporting, the following steps should be taken:

  • In the World Editor, give a unique node name (under the Node tab in the Node Info window) to each water block for which you want to export wave data. Wave data is only exported for named water blocks.
  • Set the minimum sleep distance for the water controller on each water block you want to export to a high value (larger than the level size). This ensures that all of the water geometries remain awake so that waves are propagated throughout the entire world.
  • Play the world and let it run for a while so that the waves get completely warmed up. Once you are satisfied that the waves have reached a good equilibrium state, proceed to the next step.
  • Enter water name in the console, where name is the name of a water resource that you want to create, without the .wat extension. This name is relative to the top-level folder containing the world currently being played.

Importing Wave Data

After a water resource has been created for a world, the wave information stored in it can be imported in the World Editor. To do so, select the Import Wave Data menu item in the Water page, and choose the water resource that you previously exported for the world. The water surface will instantly change in the World Editor, and you should now see the waves as they were when you exported them. Remember to change the minimum sleep distance for each water controller back to a reasonable number.

When wave data is imported, the World Editor looks for water block nodes that have the same name and dimensions that are recorded in the water resource. If no matches are found, then wave data cannot be imported.