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

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

#include <Water.h>

Public 成员函数

 Water (Graphics *gfx)
 
 ~Water ()=default
 
 Water (const Water &)=delete
 
Wateroperator= (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]².
 
void update (float dt)
 Advance the animation clock by dt seconds.
 
void setTime (float seconds)
 
float getTime () const
 
void setWaveSpeed (float speed)
 
float getWaveSpeed () const
 
void setWaveAmplitude (float amp)
 Amplitude of the shore-edge waves.
 
float getWaveAmplitude () const
 
void setRippleAmplitude (float amp)
 Amplitude of the occasional middle drop ripples.
 
float getRippleAmplitude () const
 
void setEdgeFalloff (float edge)
 Width (in UV, 0..1) of the edge wave band.
 
float getEdgeFalloff () const
 
void setRippleCount (int count)
 How many expanding drop ripples exist.
 
int getRippleCount () const
 
void setRippleInterval (float seconds)
 Seconds between drop ripples.
 
float getRippleInterval () const
 
void setWaveScale (float scale)
 
float getWaveScale () const
 
void setWaterColor (float r, float g, float b)
 
void setReflectionTint (float r, float g, float b)
 
void setReflectionIntensity (float intensity)
 
float getReflectionIntensity () const
 
void setSunIntensity (float intensity)
 
float getSunIntensity () const
 
void setScreenSpaceReflection (bool enabled, float strength=0.85f)
 Optional screen-space reflection overlay. When enabled, the shader samples the SSR pass result (bound via the renderable's height-texture slot, binding 6) at the fragment's screen UV and blends it over the env cubemap reflection. Call setViewport before drawing so screen UVs map.
 
bool getScreenSpaceReflection () const
 
float getScreenSpaceReflectionStrength () const
 
void setViewport (float width, float height)
 Window / target size in pixels, used to compute screen-space UVs.
 
float getViewportWidth () const
 
float getViewportHeight () const
 
void bindParams ()
 Upload current params to the shader push constants.
 
void draw ()
 Draw the water plane (uses default mesh3d camera / lighting state).
 
ShadergetShader () const
 
MeshgetMesh () const
 

静态 Public 成员函数

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

详细描述

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.h33 行定义.

构造及析构函数说明

◆ Water() [1/2]

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

在文件 Water.cpp181 行定义.

引用了 bindParams() , 以及 eve::graphics::newWaterShader().

◆ ~Water()

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

◆ Water() [2/2]

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

成员函数说明

◆ bindParams()

void eve::graphics::Water::bindParams ( )

Upload current params to the shader push constants.

在文件 Water.cpp259 行定义.

引用了 eve::graphics::Shader::sendFloat() , 以及 eve::graphics::Shader::sendVec3().

被这些函数引用 setTime(), update() , 以及 Water().

◆ 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.cpp186 行定义.

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

◆ draw()

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

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

在文件 Water.cpp279 行定义.

引用了 eve::graphics::Graphics::drawMeshShader().

◆ getEdgeFalloff()

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

在文件 Water.h63 行定义.

◆ getMesh()

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

在文件 Water.h106 行定义.

◆ getReflectionIntensity()

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

在文件 Water.h79 行定义.

◆ getRippleAmplitude()

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

在文件 Water.h59 行定义.

◆ getRippleCount()

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

在文件 Water.h67 行定义.

◆ getRippleInterval()

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

在文件 Water.h71 行定义.

◆ getScreenSpaceReflection()

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

在文件 Water.h91 行定义.

◆ getScreenSpaceReflectionStrength()

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

在文件 Water.h92 行定义.

◆ getShader()

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

在文件 Water.h105 行定义.

◆ getSunIntensity()

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

在文件 Water.h82 行定义.

◆ getTime()

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

在文件 Water.h47 行定义.

◆ getViewportHeight()

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

在文件 Water.h97 行定义.

◆ getViewportWidth()

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

在文件 Water.h96 行定义.

◆ getWaveAmplitude()

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

在文件 Water.h55 行定义.

◆ getWaveScale()

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

在文件 Water.h74 行定义.

◆ getWaveSpeed()

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

在文件 Water.h51 行定义.

◆ 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.cpp174 行定义.

◆ paramName()

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

在文件 Water.cpp176 行定义.

◆ setEdgeFalloff()

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

Width (in UV, 0..1) of the edge wave band.

在文件 Water.cpp234 行定义.

引用了 v.

◆ setReflectionIntensity()

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

在文件 Water.cpp248 行定义.

引用了 v.

◆ setReflectionTint()

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

在文件 Water.cpp243 行定义.

引用了 b.

◆ setRippleAmplitude()

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

Amplitude of the occasional middle drop ripples.

在文件 Water.cpp233 行定义.

引用了 v.

◆ setRippleCount()

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

How many expanding drop ripples exist.

在文件 Water.cpp235 行定义.

引用了 v.

◆ setRippleInterval()

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

Seconds between drop ripples.

在文件 Water.cpp236 行定义.

引用了 v.

◆ setScreenSpaceReflection()

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

Optional screen-space reflection overlay. When enabled, the shader samples the SSR pass result (bound via the renderable's height-texture slot, binding 6) at the fragment's screen UV and blends it over the env cubemap reflection. Call setViewport before drawing so screen UVs map.

在文件 Water.cpp250 行定义.

引用了 enabled.

◆ setSunIntensity()

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

在文件 Water.cpp249 行定义.

引用了 v.

◆ setTime()

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

在文件 Water.cpp226 行定义.

引用了 bindParams().

◆ setViewport()

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

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

在文件 Water.cpp254 行定义.

引用了 h , 以及 w.

◆ setWaterColor()

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

在文件 Water.cpp238 行定义.

引用了 b.

◆ setWaveAmplitude()

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

Amplitude of the shore-edge waves.

在文件 Water.cpp232 行定义.

引用了 v.

◆ setWaveScale()

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

在文件 Water.cpp237 行定义.

引用了 v.

◆ setWaveSpeed()

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

在文件 Water.cpp231 行定义.

引用了 v.

◆ update()

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

Advance the animation clock by dt seconds.

在文件 Water.cpp221 行定义.

引用了 bindParams().


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