OceanWaves
The OceanWaves class simulates dynamic ocean surface displacement and normals using FFT-based wave generation. It supports real-time updates through compute shaders and provides textures for vertex displacement and surface normals. Parameters such as wind velocity, direction, wave height, and animation speed allow for realistic and customizable wave behavior. This class is designed for integration with water rendering systems that require animated, physically-based surface data.
info
The FourierTransform instance can be reused across multiple systems to reduce initialization overhead.
#include <objects/oceanwaves/include/TellusimOceanWaves.h>
Example
// Create FFT instance
FourierTransform fft;
constexpr uint32_t texture_size = 512;
if(!fft.create(device, FourierTransform::ModeRGBf21c, texture_size, texture_size)) return false;
// Create OceanWaves instance
OceanWaves oceanwaves;
constexpr uint32_t plane_steps = 64;
constexpr float32_t plane_size = 128.0f;
if(!oceanwaves.create(device, fft, texture_size)) return false;
oceanwaves.setWindVelocity(8.0f);
oceanwaves.setWaveStep(plane_size / texture_size);
oceanwaves.setWaveHeight(1.0f);
// Setup oceanwaves material with displacement and normal textures
MaterialShading shading_material(scene);
if(!shading_material.load(DATA_PATH "oceanwaves.shading")) return false;
shading_material.setShadingTexture("vertex_texture", oceanwaves.getVertexTexture());
shading_material.setShadingTexture("normal_texture", oceanwaves.getNormalTexture());
// Dispatch ocean waves simulation
if(!oceanwaves.dispatch(device, compute, 0.01f)) return false;