载入中...
搜索中...
未找到

Dynamic water surface with sky reflection and animated ripples. 更多...

#include <Water.h>

Public 成员函数

 Water (Graphics *gfx)
 Water.
 
 ~Water ()
 Water.
 
 Water (const Water &)=delete
 
Water & operator= (const Water &)=delete
 
void createPlane (float sizeX, float sizeZ, int segX, int segZ)
 Build a flat XZ plane (Y-up) sized sizeX × sizeZ with UVs in [0,1]².
 
Result< int > createProceduralMesh (const WaterMeshSettings &settings)
 Validate, generate and atomically publish a Pcg-compatible plane or concentric-circle mesh.
 
void update (float dt)
 Advance the animation clock by dt seconds.
 
void setTime (float seconds)
 Sets the time.
 
float getTime () const
 Returns the time.
 
void setWaveSpeed (float speed)
 Sets the wave speed.
 
float getWaveSpeed () const
 Returns the wave speed.
 
void setWaveAmplitude (float amp)
 Amplitude of the shore-edge waves.
 
float getWaveAmplitude () const
 Returns the wave amplitude.
 
void setRippleAmplitude (float amp)
 Amplitude of the occasional middle drop ripples.
 
float getRippleAmplitude () const
 Returns the ripple amplitude.
 
void setEdgeFalloff (float edge)
 Compatibility setter for the world-space shoreline foam width.
 
float getEdgeFalloff () const
 Returns the edge falloff.
 
void setRippleCount (int count)
 How many expanding drop ripples exist.
 
int getRippleCount () const
 Returns the ripple count.
 
void setRippleInterval (float seconds)
 Seconds between drop ripples.
 
float getRippleInterval () const
 Returns the ripple interval.
 
void setWaveScale (float scale)
 Sets the wave scale.
 
float getWaveScale () const
 Returns the wave scale.
 
Result< void > setWaveDirectionAngle (float degrees)
 Set Pcg PWS_WaterSystem wave direction in finite degrees around world Y.
 
float getWaveDirectionAngle () const
 Return the normalized wave direction angle in [0,360).
 
Result< int > setDepthGradient (const WaterDepthGradient &gradient, int resolution)
 Bake Pcg GenerateColorDepth semantics and atomically publish the clamp-sampled texture.
 
Texture * getDepthGradientTexture () const
 Return the Graphics-owned current depth-ramp texture, or null when disabled.
 
void clearDepthGradient ()
 Disable depth-ramp sampling without destroying the Graphics-owned texture.
 
void setWaterColor (float r, float g, float b)
 Sets the water color.
 
void setReflectionTint (float r, float g, float b)
 Sets the reflection tint.
 
void setReflectionIntensity (float intensity)
 Sets the reflection intensity.
 
float getReflectionIntensity () const
 Returns the reflection intensity.
 
void setSunIntensity (float intensity)
 Sets the sun intensity.
 
float getSunIntensity () const
 Returns the sun intensity.
 
void setScreenSpaceReflection (bool enabled, float strength=0.85f)
 Optional screen-space reflection overlay. When enabled, the shader samples the temporally resolved SSR-chain result (bound through mesh binding 6) at the fragment's screen UV and blends it over the environment cubemap backup. The drawable viewport is inferred when setViewport was not called. SSR must also be enabled on RenderControl.
 
bool getScreenSpaceReflection () const
 Returns the screen space reflection.
 
float getScreenSpaceReflectionStrength () const
 Returns the screen space reflection strength.
 
Result< void > applyConfigJson (const std::string &json)
 Atomically replace all authored parameters from eve.graphics.stylized-water/1 JSON.
 
Result< std::string > configJson () const
 Return the canonical current eve.graphics.stylized-water/1 JSON snapshot.
 
WaterStyleConfig config () const
 Return the immutable current configuration snapshot by value.
 
void setViewport (float width, float height)
 Window / target size in pixels, used to compute screen-space UVs.
 
float getViewportWidth () const
 Returns the viewport width.
 
float getViewportHeight () const
 Returns the viewport height.
 
void bindParams ()
 Upload current params to the shader push constants.
 
void draw ()
 Draw the water plane (uses default mesh3d camera / lighting state).
 
void drawWithPlanarReflection (Texture *planarReflection, float strength=1.0F)
 Draw with an optional caller-rendered planar reflection.
 
void setReflectionCaptureEnabled (bool enabled)
 Enable or disable inclusion in reflection-probe captures.
 
bool getReflectionCaptureEnabled () const
 Return whether this water surface is included in reflection-probe captures.
 
void setReflectionCaptureMask (uint32_t mask)
 Set the reflection-capture visibility layer mask.
 
uint32_t getReflectionCaptureMask () const
 Return the reflection-capture visibility layer mask.
 
Shader * getShader () const
 Returns the shader.
 
Mesh * getMesh () const
 Returns the mesh.
 

静态 Public 成员函数

static int paramCount ()
 Names of the push-constant parameters (for UI / inspection).
 
static std::string paramName (int index)
 Param name.
 

详细描述

Dynamic water surface with sky reflection and animated ripples.

A custom Mesh3D fragment shader renders a flat plane as water:

  • Reflects the sky via the environment cubemap (binding 3), Fresnel-weighted so grazing angles reflect the sky more strongly.
  • Ripples near the water's edge (waves lapping the shore), strongest at the boundary and fading inward.
  • Occasional expanding ripple rings in the middle (rain drops / fish / boat), appearing at staggered intervals.
  • A sun glint highlight from the primary directional light.

Parameters are packed into the shader push-constant block (data[0..31]); see Water::bindDefaults for the layout. Caller owns Water*; its Mesh / Shader are owned by Graphics.

在文件 Water.h 第 68 行定义.

构造及析构函数说明

◆ Water() [1/2]

eve::graphics::Water::Water ( Graphics *  gfx)
explicit

◆ ~Water()

eve::graphics::Water::~Water ( )

◆ Water() [2/2]

eve::graphics::Water::Water ( const Water &  )
delete

成员函数说明

◆ applyConfigJson()

Result< void > eve::graphics::Water::applyConfigJson ( const std::string &  json)

Atomically replace all authored parameters from eve.graphics.stylized-water/1 JSON.

参数
jsonBorrowed UTF-8 JSON used only for this call.
返回
Success after validation and publication; failure preserves the previous configuration. @thread Main/render thread only. Does not invoke callbacks or allocate GPU resources.

在文件 Water.cpp 第 383 行定义.

引用了 bindParams(), eve::Result< T >::failure(), eve::graphics::WaterStyleConfig::fromJson() , 以及 eve::Result< T >::success().

◆ bindParams()

◆ clearDepthGradient()

void eve::graphics::Water::clearDepthGradient ( )
inline

Disable depth-ramp sampling without destroying the Graphics-owned texture.

在文件 Water.h 第 148 行定义.

◆ config()

WaterStyleConfig eve::graphics::Water::config ( ) const
inline

Return the immutable current configuration snapshot by value.

在文件 Water.h 第 187 行定义.

◆ configJson()

Result< std::string > eve::graphics::Water::configJson ( ) const

Return the canonical current eve.graphics.stylized-water/1 JSON snapshot.

在文件 Water.cpp 第 391 行定义.

引用了 eve::graphics::WaterStyleConfig::toJson().

◆ createPlane()

void eve::graphics::Water::createPlane ( float  sizeX,
float  sizeZ,
int  segX,
int  segZ 
)

Build a flat XZ plane (Y-up) sized sizeX × sizeZ with UVs in [0,1]².

在文件 Water.cpp 第 172 行定义.

引用了 a, b, c, d, idx, eve::graphics::Graphics::newMeshFromArrays(), pos, uv, x , 以及 z.

◆ createProceduralMesh()

Result< int > eve::graphics::Water::createProceduralMesh ( const WaterMeshSettings &  settings)

Validate, generate and atomically publish a Pcg-compatible plane or concentric-circle mesh.

参数
settingsBorrowed immutable dimensions, height, density and shape.
返回
Published vertex count. Failure preserves the current mesh. @thread Graphics owner thread only. No callback or borrowed pointer survives the call.

在文件 Water.cpp 第 207 行定义.

引用了 a, b, c, eve::graphics::calculateWaterMeshTriangles(), counts, cx, d, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), idx, eve::graphics::Graphics::newMeshFromArrays(), nx, nz, eve::graphics::Plane, point, pos, eve::PreconditionViolation, settings, step, eve::Result< T >::success(), sx, sz, uv, vertexCount, x , 以及 z.

◆ draw()

void eve::graphics::Water::draw ( )

Draw the water plane (uses default mesh3d camera / lighting state).

在文件 Water.cpp 第 393 行定义.

◆ drawWithPlanarReflection()

void eve::graphics::Water::drawWithPlanarReflection ( Texture *  planarReflection,
float  strength = 1.0F 
)

Draw with an optional caller-rendered planar reflection.

参数
planarReflectionBorrowed texture sampled only during this synchronous draw; may be null. The caller retains ownership and may release it after this call returns.
strengthReflection contribution in [0,4]. A supplied planar reflection takes priority over the configured screen-space reflection history for this draw only. @thread Main/render thread only. The call does not retain pointers or invoke callbacks.

在文件 Water.cpp 第 395 行定义.

引用了 strength.

◆ getDepthGradientTexture()

Texture * eve::graphics::Water::getDepthGradientTexture ( ) const
inline

Return the Graphics-owned current depth-ramp texture, or null when disabled.

在文件 Water.h 第 146 行定义.

◆ getEdgeFalloff()

float eve::graphics::Water::getEdgeFalloff ( ) const
inline

Returns the edge falloff.

在文件 Water.h 第 115 行定义.

◆ getMesh()

Mesh * eve::graphics::Water::getMesh ( ) const
inline

Returns the mesh.

在文件 Water.h 第 224 行定义.

◆ getReflectionCaptureEnabled()

bool eve::graphics::Water::getReflectionCaptureEnabled ( ) const
inline

Return whether this water surface is included in reflection-probe captures.

在文件 Water.h 第 215 行定义.

◆ getReflectionCaptureMask()

uint32_t eve::graphics::Water::getReflectionCaptureMask ( ) const
inline

Return the reflection-capture visibility layer mask.

在文件 Water.h 第 219 行定义.

◆ getReflectionIntensity()

float eve::graphics::Water::getReflectionIntensity ( ) const
inline

Returns the reflection intensity.

在文件 Water.h 第 157 行定义.

◆ getRippleAmplitude()

float eve::graphics::Water::getRippleAmplitude ( ) const
inline

Returns the ripple amplitude.

在文件 Water.h 第 110 行定义.

◆ getRippleCount()

int eve::graphics::Water::getRippleCount ( ) const
inline

Returns the ripple count.

在文件 Water.h 第 120 行定义.

◆ getRippleInterval()

float eve::graphics::Water::getRippleInterval ( ) const
inline

Returns the ripple interval.

在文件 Water.h 第 125 行定义.

◆ getScreenSpaceReflection()

bool eve::graphics::Water::getScreenSpaceReflection ( ) const
inline

Returns the screen space reflection.

在文件 Water.h 第 173 行定义.

◆ getScreenSpaceReflectionStrength()

float eve::graphics::Water::getScreenSpaceReflectionStrength ( ) const
inline

Returns the screen space reflection strength.

在文件 Water.h 第 175 行定义.

◆ getShader()

Shader * eve::graphics::Water::getShader ( ) const
inline

Returns the shader.

在文件 Water.h 第 222 行定义.

◆ getSunIntensity()

float eve::graphics::Water::getSunIntensity ( ) const
inline

Returns the sun intensity.

在文件 Water.h 第 162 行定义.

◆ getTime()

float eve::graphics::Water::getTime ( ) const
inline

Returns the time.

在文件 Water.h 第 94 行定义.

◆ getViewportHeight()

float eve::graphics::Water::getViewportHeight ( ) const
inline

Returns the viewport height.

在文件 Water.h 第 194 行定义.

◆ getViewportWidth()

float eve::graphics::Water::getViewportWidth ( ) const
inline

Returns the viewport width.

在文件 Water.h 第 192 行定义.

◆ getWaveAmplitude()

float eve::graphics::Water::getWaveAmplitude ( ) const
inline

Returns the wave amplitude.

在文件 Water.h 第 105 行定义.

◆ getWaveDirectionAngle()

float eve::graphics::Water::getWaveDirectionAngle ( ) const
inline

Return the normalized wave direction angle in [0,360).

在文件 Water.h 第 135 行定义.

◆ getWaveScale()

float eve::graphics::Water::getWaveScale ( ) const
inline

Returns the wave scale.

在文件 Water.h 第 130 行定义.

◆ getWaveSpeed()

float eve::graphics::Water::getWaveSpeed ( ) const
inline

Returns the wave speed.

在文件 Water.h 第 100 行定义.

◆ operator=()

Water & eve::graphics::Water::operator= ( const Water &  )
delete

◆ paramCount()

int eve::graphics::Water::paramCount ( )
static

Names of the push-constant parameters (for UI / inspection).

在文件 Water.cpp 第 152 行定义.

◆ paramName()

std::string eve::graphics::Water::paramName ( int  index)
static

Param name.

在文件 Water.cpp 第 154 行定义.

引用了 index.

◆ setDepthGradient()

Result< int > eve::graphics::Water::setDepthGradient ( const WaterDepthGradient &  gradient,
int  resolution 
)

Bake Pcg GenerateColorDepth semantics and atomically publish the clamp-sampled texture.

参数
gradientBorrowed immutable color and alpha keys.
resolutionSquare texture resolution in [2,4096]; columns sample x/resolution.
返回
Generated pixel count. Failure preserves the current ramp. @thread Graphics owner thread only; no pointer or callback survives the call.

在文件 Water.cpp 第 281 行定义.

引用了 eve::graphics::WaterDepthGradient::alphaStops, color, eve::graphics::WaterDepthGradient::colorStops, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), eve::InvalidArgument, eve::graphics::Graphics::newTextureFromImageData(), pixels, eve::Result< T >::success(), t, x , 以及 y.

◆ setEdgeFalloff()

void eve::graphics::Water::setEdgeFalloff ( float  edge)

Compatibility setter for the world-space shoreline foam width.

在文件 Water.cpp 第 324 行定义.

引用了 eve::graphics::WaterStyleConfig::foamWidth , 以及 v.

◆ setReflectionCaptureEnabled()

void eve::graphics::Water::setReflectionCaptureEnabled ( bool  enabled)
inline

Enable or disable inclusion in reflection-probe captures.

在文件 Water.h 第 213 行定义.

引用了 enabled.

◆ setReflectionCaptureMask()

void eve::graphics::Water::setReflectionCaptureMask ( uint32_t  mask)
inline

Set the reflection-capture visibility layer mask.

在文件 Water.h 第 217 行定义.

引用了 mask.

◆ setReflectionIntensity()

void eve::graphics::Water::setReflectionIntensity ( float  intensity)

Sets the reflection intensity.

在文件 Water.cpp 第 342 行定义.

引用了 eve::graphics::WaterStyleConfig::reflectionIntensity , 以及 v.

◆ setReflectionTint()

void eve::graphics::Water::setReflectionTint ( float  r,
float  g,
float  b 
)

Sets the reflection tint.

在文件 Water.cpp 第 339 行定义.

引用了 b, g, r , 以及 eve::graphics::WaterStyleConfig::reflectionTint.

◆ setRippleAmplitude()

void eve::graphics::Water::setRippleAmplitude ( float  amp)

Amplitude of the occasional middle drop ripples.

在文件 Water.cpp 第 323 行定义.

引用了 eve::graphics::WaterStyleConfig::rippleAmplitude , 以及 v.

◆ setRippleCount()

void eve::graphics::Water::setRippleCount ( int  count)

How many expanding drop ripples exist.

在文件 Water.cpp 第 325 行定义.

引用了 eve::graphics::WaterStyleConfig::rippleCount , 以及 v.

◆ setRippleInterval()

void eve::graphics::Water::setRippleInterval ( float  seconds)

Seconds between drop ripples.

在文件 Water.cpp 第 326 行定义.

引用了 eve::graphics::WaterStyleConfig::rippleInterval , 以及 v.

◆ setScreenSpaceReflection()

void eve::graphics::Water::setScreenSpaceReflection ( bool  enabled,
float  strength = 0.85f 
)

Optional screen-space reflection overlay. When enabled, the shader samples the temporally resolved SSR-chain result (bound through mesh binding 6) at the fragment's screen UV and blends it over the environment cubemap backup. The drawable viewport is inferred when setViewport was not called. SSR must also be enabled on RenderControl.

在文件 Water.cpp 第 344 行定义.

引用了 enabled, eve::graphics::WaterStyleConfig::screenSpaceReflection, eve::graphics::WaterStyleConfig::screenSpaceReflectionStrength , 以及 strength.

◆ setSunIntensity()

void eve::graphics::Water::setSunIntensity ( float  intensity)

Sets the sun intensity.

在文件 Water.cpp 第 343 行定义.

引用了 eve::graphics::WaterStyleConfig::sunIntensity , 以及 v.

◆ setTime()

void eve::graphics::Water::setTime ( float  seconds)

Sets the time.

在文件 Water.cpp 第 316 行定义.

引用了 bindParams().

◆ setViewport()

void eve::graphics::Water::setViewport ( float  width,
float  height 
)

Window / target size in pixels, used to compute screen-space UVs.

在文件 Water.cpp 第 348 行定义.

引用了 h , 以及 w.

◆ setWaterColor()

void eve::graphics::Water::setWaterColor ( float  r,
float  g,
float  b 
)

Sets the water color.

在文件 Water.cpp 第 336 行定义.

引用了 b, eve::graphics::WaterStyleConfig::deepColor, g , 以及 r.

◆ setWaveAmplitude()

void eve::graphics::Water::setWaveAmplitude ( float  amp)

Amplitude of the shore-edge waves.

在文件 Water.cpp 第 322 行定义.

引用了 v , 以及 eve::graphics::WaterStyleConfig::waveAmplitude.

◆ setWaveDirectionAngle()

Result< void > eve::graphics::Water::setWaveDirectionAngle ( float  degrees)

Set Pcg PWS_WaterSystem wave direction in finite degrees around world Y.

在文件 Water.cpp 第 328 行定义.

引用了 degrees, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument , 以及 eve::Result< T >::success().

◆ setWaveScale()

void eve::graphics::Water::setWaveScale ( float  scale)

Sets the wave scale.

在文件 Water.cpp 第 327 行定义.

引用了 v , 以及 eve::graphics::WaterStyleConfig::waveScale.

◆ setWaveSpeed()

void eve::graphics::Water::setWaveSpeed ( float  speed)

Sets the wave speed.

在文件 Water.cpp 第 321 行定义.

引用了 v , 以及 eve::graphics::WaterStyleConfig::waveSpeed.

◆ update()

void eve::graphics::Water::update ( float  dt)

Advance the animation clock by dt seconds.

在文件 Water.cpp 第 311 行定义.

引用了 bindParams().


该类的文档由以下文件生成: