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() [1/2]
|
explicit |
◆ ~Water()
| eve::graphics::Water::~Water | ( | ) |
◆ Water() [2/2]
|
delete |
成员函数说明
◆ applyConfigJson()
| Result< void > eve::graphics::Water::applyConfigJson | ( | const std::string & | json | ) |
Atomically replace all authored parameters from eve.graphics.stylized-water/1 JSON.
- 参数
-
json Borrowed 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.
引用了 bindParams(), eve::Result< T >::failure(), eve::graphics::WaterStyleConfig::fromJson() , 以及 eve::Result< T >::success().
◆ bindParams()
| void eve::graphics::Water::bindParams | ( | ) |
Upload current params to the shader push constants.
引用了 eve::graphics::WaterStyleConfig::causticsScale, eve::graphics::WaterStyleConfig::causticsStrength, eve::graphics::WaterStyleConfig::deepColor, eve::graphics::WaterStyleConfig::depthDistance, eve::graphics::WaterStyleConfig::foamColor, eve::graphics::WaterStyleConfig::foamSoftness, eve::graphics::WaterStyleConfig::foamStrength, eve::graphics::WaterStyleConfig::foamWidth, eve::graphics::WaterStyleConfig::fresnelPower, eve::graphics::WaterStyleConfig::opacity, eve::graphics::WaterStyleConfig::reflectionIntensity, eve::graphics::WaterStyleConfig::reflectionTint, eve::graphics::WaterStyleConfig::refractionStrength, eve::graphics::WaterStyleConfig::rippleAmplitude, eve::graphics::WaterStyleConfig::rippleCount, eve::graphics::WaterStyleConfig::rippleInterval, eve::graphics::WaterStyleConfig::screenSpaceReflection, eve::graphics::WaterStyleConfig::screenSpaceReflectionStrength, eve::graphics::Shader::sendFloat(), eve::graphics::Shader::sendVec3(), eve::graphics::WaterStyleConfig::shallowColor, eve::graphics::WaterStyleConfig::sunIntensity, eve::graphics::WaterStyleConfig::waveAmplitude, eve::graphics::WaterStyleConfig::waveScale, eve::graphics::WaterStyleConfig::waveSharpness , 以及 eve::graphics::WaterStyleConfig::waveSpeed.
被这些函数引用 applyConfigJson(), setTime(), update() , 以及 Water().
◆ clearDepthGradient()
|
inline |
◆ config()
|
inline |
◆ configJson()
| Result< std::string > eve::graphics::Water::configJson | ( | ) | const |
Return the canonical current eve.graphics.stylized-water/1 JSON snapshot.
◆ createPlane()
| void eve::graphics::Water::createPlane | ( | float | sizeX, |
| float | sizeZ, | ||
| int | segX, | ||
| int | segZ | ||
| ) |
◆ createProceduralMesh()
| Result< int > eve::graphics::Water::createProceduralMesh | ( | const WaterMeshSettings & | settings | ) |
Validate, generate and atomically publish a Pcg-compatible plane or concentric-circle mesh.
- 参数
-
settings Borrowed 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.
引用了 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 | ( | ) |
◆ drawWithPlanarReflection()
| void eve::graphics::Water::drawWithPlanarReflection | ( | Texture * | planarReflection, |
| float | strength = 1.0F |
||
| ) |
Draw with an optional caller-rendered planar reflection.
- 参数
-
planarReflection Borrowed texture sampled only during this synchronous draw; may be null. The caller retains ownership and may release it after this call returns. strength Reflection 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.
引用了 strength.
◆ getDepthGradientTexture()
|
inline |
◆ getEdgeFalloff()
|
inline |
◆ getMesh()
◆ getReflectionCaptureEnabled()
|
inline |
◆ getReflectionCaptureMask()
|
inline |
◆ getReflectionIntensity()
|
inline |
◆ getRippleAmplitude()
|
inline |
◆ getRippleCount()
|
inline |
◆ getRippleInterval()
|
inline |
◆ getScreenSpaceReflection()
|
inline |
◆ getScreenSpaceReflectionStrength()
|
inline |
◆ getShader()
|
inline |
◆ getSunIntensity()
|
inline |
◆ getTime()
◆ getViewportHeight()
|
inline |
◆ getViewportWidth()
|
inline |
◆ getWaveAmplitude()
|
inline |
◆ getWaveDirectionAngle()
|
inline |
◆ getWaveScale()
|
inline |
◆ getWaveSpeed()
|
inline |
◆ operator=()
◆ paramCount()
|
static |
◆ paramName()
|
static |
◆ setDepthGradient()
| Result< int > eve::graphics::Water::setDepthGradient | ( | const WaterDepthGradient & | gradient, |
| int | resolution | ||
| ) |
Bake Pcg GenerateColorDepth semantics and atomically publish the clamp-sampled texture.
- 参数
-
gradient Borrowed immutable color and alpha keys. resolution Square 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.
引用了 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.
引用了 eve::graphics::WaterStyleConfig::foamWidth , 以及 v.
◆ setReflectionCaptureEnabled()
|
inline |
◆ setReflectionCaptureMask()
|
inline |
◆ setReflectionIntensity()
| void eve::graphics::Water::setReflectionIntensity | ( | float | intensity | ) |
Sets the reflection intensity.
引用了 eve::graphics::WaterStyleConfig::reflectionIntensity , 以及 v.
◆ setReflectionTint()
| void eve::graphics::Water::setReflectionTint | ( | float | r, |
| float | g, | ||
| float | b | ||
| ) |
◆ setRippleAmplitude()
| void eve::graphics::Water::setRippleAmplitude | ( | float | amp | ) |
Amplitude of the occasional middle drop ripples.
引用了 eve::graphics::WaterStyleConfig::rippleAmplitude , 以及 v.
◆ setRippleCount()
| void eve::graphics::Water::setRippleCount | ( | int | count | ) |
How many expanding drop ripples exist.
◆ setRippleInterval()
| void eve::graphics::Water::setRippleInterval | ( | float | seconds | ) |
Seconds between drop ripples.
◆ 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.
引用了 enabled, eve::graphics::WaterStyleConfig::screenSpaceReflection, eve::graphics::WaterStyleConfig::screenSpaceReflectionStrength , 以及 strength.
◆ setSunIntensity()
| void eve::graphics::Water::setSunIntensity | ( | float | intensity | ) |
Sets the sun intensity.
◆ setTime()
| void eve::graphics::Water::setTime | ( | float | seconds | ) |
◆ setViewport()
| void eve::graphics::Water::setViewport | ( | float | width, |
| float | height | ||
| ) |
◆ setWaterColor()
| void eve::graphics::Water::setWaterColor | ( | float | r, |
| float | g, | ||
| float | b | ||
| ) |
◆ setWaveAmplitude()
| void eve::graphics::Water::setWaveAmplitude | ( | float | amp | ) |
Amplitude of the shore-edge waves.
◆ setWaveDirectionAngle()
| Result< void > eve::graphics::Water::setWaveDirectionAngle | ( | float | degrees | ) |
Set Pcg PWS_WaterSystem wave direction in finite degrees around world Y.
引用了 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.
引用了 v , 以及 eve::graphics::WaterStyleConfig::waveScale.
◆ setWaveSpeed()
| void eve::graphics::Water::setWaveSpeed | ( | float | speed | ) |
Sets the wave speed.
引用了 v , 以及 eve::graphics::WaterStyleConfig::waveSpeed.
◆ update()
| void eve::graphics::Water::update | ( | float | dt | ) |
该类的文档由以下文件生成: