Skip to content
yvt edited this page Dec 12, 2020 · 4 revisions

When the option called Shader Effects is set to at least high or r_water is set to 1, ocean simulation is enabled. This simulation is made of two phases:

  • Heightmap Calculation
  • Rendering

Heightmap Calculation

This phase computes the height of each point of the ocean. To compute this, we have to solve the wave equation. This is done by synthesising all possible standing waves by using 2D Fourier transform.

We didn't choose Euler method to solve the wave equation because of the following reasons:

  • This method is progressive and computation error is accumulated, resulting in
    • Unconserved kinematic energy.
    • Divergence.
  • This method is apt to cause high-frequency noise.
  • Mathematical instability.

Rendering

The OpenGL renderer provides four levels of ocean render quality settings. They are chosen by r_water config variable.

None

In this setting, it doesn't render the ocean in a special way and treats it as if it's a part of the terrain.

Level 1

This setting simulates the following properties of the ocean water:

  • Color (something like fog in an atmosphere)
  • Fresnel Reflection
  • Refraction

Currently, only the sky color is considered in simulating reflection.

Refraction is approximated (not physically accurate at all). It only shifts rendered pixels of objects in the water.

Level 2

This setting simulates reflection using a popular approximate method.

Level 3

This setting is the most advanced setting in OpenSpades, or perhaps in most if not all modern games. It combines the traditional "portal" mirror rendering technique and screen-space raytracing to render physically-accurate reflection and refraction.