Class: WaterMaterial
Defined in: src/materials/WaterMaterial.ts:24
Surface material of WaterRenderer: Gerstner-wave displacement, refraction of the opaque scene behind, absorption, environment reflection and a sun highlight. Drawn by the transmission pass, after the opaque scene has been captured into the scene color pyramid.
Extends
Constructors
Constructor
new WaterMaterial():
WaterMaterial
Defined in: src/materials/WaterMaterial.ts:30
Returns
WaterMaterial
Overrides
Properties
instanceID
instanceID:
string
Defined in: src/materials/Material.ts:26
Material Unique Identifier
Inherited from
name
name:
string
Defined in: src/materials/Material.ts:32
name of this material
Inherited from
enable
enable:
boolean=true
Defined in: src/materials/Material.ts:35
Whether this material is enabled for rendering.
Inherited from
Accessors
oitMode
Get Signature
get oitMode():
"sorted"|"weighted"|"depth-peel"
Defined in: src/materials/Material.ts:69
Order-independent transparency mode opt-in.
'sorted'(default): back-to-front sorted alpha-blend. Cheap, correct between meshes, but in-mesh triangle order is geometry- based not depth-based so self-overlapping meshes (spheres, torus) show banding.'weighted': McGuire-Bavoil 2013 Weighted-Blended OIT. Single- pass, order-independent, no in-mesh banding. Approximate — accum.rgb/accum.a degenerates to a depth-weighted average so α=1 looks averaged-milky at small scene scales (the front-vs- back depth-weight ratio saturates the paper's z/200 norm). Use for unbounded transparent layer counts: particles, smoke, foliage, hair cards.'depth-peel': Dual depth peeling. Multi-pass (passCount × 2 layers), order-correct over operator. α=1 is cleanly opaque — front fragment dominates because subsequent layers get multiplied by (1 - frontColor.a) = 0. Hard layer count limit (default 10). Use for hero glass, scientific visualization, layered architectural geometry.
All three only take effect when engine.setting.render.useOIT is true (otherwise everything falls through the sorted path).
Setter notifies attached renderers so the corresponding derived pass(es) get lazily generated when flipping mode at runtime. Without this, callers had to follow up with an alphaMode setter call to provoke refreshRenderClassification → castNeedPass.
Documented at Material-level (not LitMaterial) so any future material subclass (particle, decal) can opt in.
Returns
"sorted" | "weighted" | "depth-peel"
Set Signature
set oitMode(
value):void
Defined in: src/materials/Material.ts:74
Set the order-independent transparency mode, notifying renderers to re-classify the affected passes.
Parameters
value
"sorted" | "weighted" | "depth-peel"
Returns
void
Inherited from
shader
Get Signature
get shader():
Shader
Defined in: src/materials/Material.ts:96
Get the shader bound to this material.
Returns
Set Signature
set shader(
shader):void
Defined in: src/materials/Material.ts:90
Set the shader for this material and cache its default sub-shader.
Parameters
shader
Returns
void
Inherited from
doubleSide
Get Signature
get doubleSide():
boolean
Defined in: src/materials/Material.ts:101
Whether the default sub-shader renders both faces (no back-face culling).
Returns
boolean
Set Signature
set doubleSide(
value):void
Defined in: src/materials/Material.ts:106
Enable or disable double-sided rendering on the default sub-shader.
Parameters
value
boolean
Returns
void
Inherited from
castShadow
Get Signature
get castShadow():
boolean
Defined in: src/materials/Material.ts:111
Whether this material casts shadows.
Returns
boolean
Set Signature
set castShadow(
value):void
Defined in: src/materials/Material.ts:116
Enable or disable shadow casting for this material.
Parameters
value
boolean
Returns
void
Inherited from
acceptShadow
Get Signature
get acceptShadow():
boolean
Defined in: src/materials/Material.ts:124
Whether this material receives shadows from other casters.
Returns
boolean
Set Signature
set acceptShadow(
value):void
Defined in: src/materials/Material.ts:129
Enable or disable shadow receiving for this material.
Parameters
value
boolean
Returns
void
Inherited from
castReflection
Get Signature
get castReflection():
boolean
Defined in: src/materials/Material.ts:139
Whether this material contributes to reflection probes.
Returns
boolean
Set Signature
set castReflection(
value):void
Defined in: src/materials/Material.ts:144
Enable or disable reflection casting for this material.
Parameters
value
boolean
Returns
void
Inherited from
blendMode
Get Signature
get blendMode():
BlendMode
Defined in: src/materials/Material.ts:149
The blend mode of the default sub-shader.
Returns
Set Signature
set blendMode(
value):void
Defined in: src/materials/Material.ts:154
Set the blend mode of the default sub-shader.
Parameters
value
Returns
void
Inherited from
depthCompare
Get Signature
get depthCompare():
GPUCompareFunction
Defined in: src/materials/Material.ts:159
The depth comparison function of the default sub-shader.
Returns
GPUCompareFunction
Set Signature
set depthCompare(
value):void
Defined in: src/materials/Material.ts:164
Set the depth comparison function across all passes of this material.
Parameters
value
GPUCompareFunction
Returns
void
Inherited from
transparent
Get Signature
get transparent():
boolean
Defined in: src/materials/Material.ts:175
Whether this material is rendered as transparent.
Returns
boolean
Set Signature
set transparent(
value):void
Defined in: src/materials/Material.ts:180
Enable or disable transparency, moving the pass to the transparent queue when enabled.
Parameters
value
boolean
Returns
void
Inherited from
cullMode
Get Signature
get cullMode():
GPUCullMode
Defined in: src/materials/Material.ts:188
The face culling mode of the default sub-shader.
Returns
GPUCullMode
Set Signature
set cullMode(
value):void
Defined in: src/materials/Material.ts:193
Set the face culling mode across all passes of this material.
Parameters
value
GPUCullMode
Returns
void
Inherited from
UnLitTexArrayMaterial.cullMode
depthWriteEnabled
Get Signature
get depthWriteEnabled():
boolean
Defined in: src/materials/Material.ts:205
Whether depth writing is enabled for the default sub-shader.
Returns
boolean
Set Signature
set depthWriteEnabled(
value):void
Defined in: src/materials/Material.ts:210
Enable or disable depth writing for the default sub-shader.
Parameters
value
boolean
Returns
void
Inherited from
stencilFront
Get Signature
get stencilFront():
GPUStencilFaceState
Defined in: src/materials/Material.ts:217
Stencil front face state
Returns
GPUStencilFaceState
Set Signature
set stencilFront(
value):void
Defined in: src/materials/Material.ts:222
Set the stencil front face state.
Parameters
value
GPUStencilFaceState
Returns
void
Inherited from
stencilBack
Get Signature
get stencilBack():
GPUStencilFaceState
Defined in: src/materials/Material.ts:229
Stencil back face state
Returns
GPUStencilFaceState
Set Signature
set stencilBack(
value):void
Defined in: src/materials/Material.ts:234
Set the stencil back face state.
Parameters
value
GPUStencilFaceState
Returns
void
Inherited from
stencilReadMask
Get Signature
get stencilReadMask():
number
Defined in: src/materials/Material.ts:241
Stencil read mask
Returns
number
Set Signature
set stencilReadMask(
value):void
Defined in: src/materials/Material.ts:246
Set the stencil read mask.
Parameters
value
number
Returns
void
Inherited from
stencilWriteMask
Get Signature
get stencilWriteMask():
number
Defined in: src/materials/Material.ts:253
Stencil write mask
Returns
number
Set Signature
set stencilWriteMask(
value):void
Defined in: src/materials/Material.ts:258
Set the stencil write mask.
Parameters
value
number
Returns
void
Inherited from
stencilRef
Get Signature
get stencilRef():
number
Defined in: src/materials/Material.ts:265
Stencil reference value
Returns
number
Set Signature
set stencilRef(
value):void
Defined in: src/materials/Material.ts:270
Set the stencil reference value.
Parameters
value
number
Returns
void
Inherited from
useBillboard
Set Signature
set useBillboard(
value):void
Defined in: src/materials/Material.ts:275
Enable or disable billboard orientation via the USE_BILLBOARD shader define.
Parameters
value
boolean
Returns
void
Inherited from
topology
Get Signature
get topology():
GPUPrimitiveTopology
Defined in: src/materials/Material.ts:280
The primitive topology of the default sub-shader.
Returns
GPUPrimitiveTopology
Set Signature
set topology(
value):void
Defined in: src/materials/Material.ts:285
Set the primitive topology of the default sub-shader.
Parameters
value
GPUPrimitiveTopology
Returns
void
Inherited from
baseColor
Get Signature
get baseColor():
Color
Defined in: src/materials/Material.ts:295
Get the base color uniform.
Returns
Set Signature
set baseColor(
color):void
Defined in: src/materials/Material.ts:290
Set the base color uniform.
Parameters
color
Returns
void
Inherited from
transmissionFactor
Get Signature
get transmissionFactor():
number
Defined in: src/materials/WaterMaterial.ts:68
Drawn by the transmission pass so the scene color pyramid already holds the scene behind.
Returns
number
sceneColorPyramid
Get Signature
get sceneColorPyramid():
Texture
Defined in: src/materials/WaterMaterial.ts:76
Returns
foamTexture
Get Signature
get foamTexture():
Texture
Defined in: src/materials/WaterMaterial.ts:110
Returns
Set Signature
set foamTexture(
texture):void
Defined in: src/materials/WaterMaterial.ts:106
Tileable foam (r) drawn where whitecaps form; null falls back to plain noise patches.
Parameters
texture
Returns
void
waveFadeDistance
Set Signature
set waveFadeDistance(
value):void
Defined in: src/materials/WaterMaterial.ts:158
Parameters
value
number
Returns
void
foamIntensity
Get Signature
get foamIntensity():
number
Defined in: src/materials/WaterMaterial.ts:182
Whitecaps where the waves pinch into sharp crests (0 to 1); calm water has none.
Returns
number
Set Signature
set foamIntensity(
value):void
Defined in: src/materials/WaterMaterial.ts:185
Parameters
value
number
Returns
void
reflectionRoughness
Get Signature
get reflectionRoughness():
number
Defined in: src/materials/WaterMaterial.ts:194
Roughness of the surface below the scale of the fine ripples (0 to 1), blurring the reflection; ripples too fine for a pixel add to it.
Returns
number
Set Signature
set reflectionRoughness(
value):void
Defined in: src/materials/WaterMaterial.ts:197
Parameters
value
number
Returns
void
subsurfaceIntensity
Get Signature
get subsurfaceIntensity():
number
Defined in: src/materials/WaterMaterial.ts:203
Sunlight glowing through the crests of tall waves when looking toward the sun.
Returns
number
Set Signature
set subsurfaceIntensity(
value):void
Defined in: src/materials/WaterMaterial.ts:206
Parameters
value
number
Returns
void
underwaterClarity
Get Signature
get underwaterClarity():
number
Defined in: src/materials/WaterMaterial.ts:217
How clearly the world above shows through the surface from underwater (0 to 1). 0 is physical: Snell's window spans 48.6 degrees from straight up and the rest of the surface mirrors the water below; higher widens the window and weakens the mirror.
Returns
number
Set Signature
set underwaterClarity(
value):void
Defined in: src/materials/WaterMaterial.ts:220
Parameters
value
number
Returns
void
absorptionColor
Get Signature
get absorptionColor():
Color
Defined in: src/materials/WaterMaterial.ts:226
Light passing through the water is tinted toward this color.
Returns
Set Signature
set absorptionColor(
value):void
Defined in: src/materials/WaterMaterial.ts:229
Parameters
value
Returns
void
underwaterColor
Get Signature
get underwaterColor():
Color
Defined in: src/materials/WaterMaterial.ts:234
Color of deep water: anything seen through the water, from above or below, fades into it with distance.
Returns
Set Signature
set underwaterColor(
value):void
Defined in: src/materials/WaterMaterial.ts:237
Parameters
value
Returns
void
density
Get Signature
get density():
number
Defined in: src/materials/WaterMaterial.ts:242
Absorption per world unit of path through the water.
Returns
number
Set Signature
set density(
value):void
Defined in: src/materials/WaterMaterial.ts:245
Parameters
value
number
Returns
void
refractionStrength
Get Signature
get refractionStrength():
number
Defined in: src/materials/WaterMaterial.ts:250
Scale of the wave distortion seen through the surface: 1 is physical, 0 disables it.
Returns
number
Set Signature
set refractionStrength(
value):void
Defined in: src/materials/WaterMaterial.ts:253
Parameters
value
number
Returns
void
waterDepth
Get Signature
get waterDepth():
number
Defined in: src/materials/WaterMaterial.ts:258
Depth of the bottom below the surface, in world units; used when setting.render.water is off (no scene depth).
Returns
number
Set Signature
set waterDepth(
value):void
Defined in: src/materials/WaterMaterial.ts:261
Parameters
value
number
Returns
void
specularPower
Get Signature
get specularPower():
number
Defined in: src/materials/WaterMaterial.ts:266
Sun highlight exponent; higher is smaller and sharper.
Returns
number
Set Signature
set specularPower(
value):void
Defined in: src/materials/WaterMaterial.ts:269
Parameters
value
number
Returns
void
specularIntensity
Get Signature
get specularIntensity():
number
Defined in: src/materials/WaterMaterial.ts:274
Sun highlight strength.
Returns
number
Set Signature
set specularIntensity(
value):void
Defined in: src/materials/WaterMaterial.ts:277
Parameters
value
number
Returns
void
reflectionIntensity
Get Signature
get reflectionIntensity():
number
Defined in: src/materials/WaterMaterial.ts:282
Environment reflection strength.
Returns
number
Set Signature
set reflectionIntensity(
value):void
Defined in: src/materials/WaterMaterial.ts:285
Parameters
value
number
Returns
void
fresnelClamp
Get Signature
get fresnelClamp():
number
Defined in: src/materials/WaterMaterial.ts:290
Upper bound of the fresnel reflection weight (0 to 1).
Returns
number
Set Signature
set fresnelClamp(
value):void
Defined in: src/materials/WaterMaterial.ts:293
Parameters
value
number
Returns
void
waveTime
Set Signature
set waveTime(
value):void
Defined in: src/materials/WaterMaterial.ts:301
Parameters
value
number
Returns
void
Methods
getPass()
getPass(
passType):RenderShaderPass[]
Defined in: src/materials/Material.ts:304
get render pass by renderType
Parameters
passType
PassType
Returns
Inherited from
getAllPass()
getAllPass():
RenderShaderPass[]
Defined in: src/materials/Material.ts:312
get all color render pass
Returns
Inherited from
clone()
clone():
Material
Defined in: src/materials/Material.ts:320
clone one material
Returns
Material
Inherited from
destroy()
destroy(
force):void
Defined in: src/materials/Material.ts:328
Release this material's shader and clear its identifying fields.
Parameters
force
boolean
Returns
void
Inherited from
setDefine()
setDefine(
define,value):void
Defined in: src/materials/Material.ts:337
Set a shader define flag on this material's shader.
Parameters
define
string
value
boolean
Returns
void
Inherited from
getDefine()
getDefine(
define):boolean
Defined in: src/materials/Material.ts:342
Get the value of a shader define flag.
Parameters
define
string
Returns
boolean
Inherited from
setTexture()
setTexture(
propertyName,texture):void
Defined in: src/materials/Material.ts:347
Bind a texture to the named shader property.
Parameters
propertyName
string
texture
Returns
void
Inherited from
setStorageBuffer()
setStorageBuffer(
propertyName,buffer):void
Defined in: src/materials/Material.ts:352
Bind a storage GPU buffer to the named shader property.
Parameters
propertyName
string
buffer
Returns
void
Inherited from
setUniformBuffer()
setUniformBuffer(
propertyName,buffer):void
Defined in: src/materials/Material.ts:357
Bind a uniform GPU buffer to the named shader property.
Parameters
propertyName
string
buffer
Returns
void
Inherited from
setUniformFloat()
setUniformFloat(
propertyName,value):void
Defined in: src/materials/Material.ts:363
Set a float uniform on the named shader property.
Parameters
propertyName
string
value
number
Returns
void
Inherited from
setUniformInt32()
setUniformInt32(
propertyName,value):void
Defined in: src/materials/Material.ts:368
Set a 32-bit integer uniform on the named shader property.
Parameters
propertyName
string
value
number
Returns
void
Inherited from
setUniformVector2()
setUniformVector2(
propertyName,value):void
Defined in: src/materials/Material.ts:373
Set a Vector2 uniform on the named shader property.
Parameters
propertyName
string
value
Returns
void
Inherited from
setUniformVector3()
setUniformVector3(
propertyName,value):void
Defined in: src/materials/Material.ts:378
Set a Vector3 uniform on the named shader property.
Parameters
propertyName
string
value
Returns
void
Inherited from
setUniformVector4()
setUniformVector4(
propertyName,value):void
Defined in: src/materials/Material.ts:383
Set a Vector4 uniform on the named shader property.
Parameters
propertyName
string
value
Vector4
Returns
void
Inherited from
setUniformColor()
setUniformColor(
propertyName,value):void
Defined in: src/materials/Material.ts:388
Set a color uniform on the named shader property.
Parameters
propertyName
string
value
Returns
void
Inherited from
getUniformFloat()
getUniformFloat(
str):any
Defined in: src/materials/Material.ts:393
Get the float value of the named uniform.
Parameters
str
string
Returns
any
Inherited from
getUniformInt32()
getUniformInt32(
str):any
Defined in: src/materials/Material.ts:398
Get the 32-bit integer value of the named uniform.
Parameters
str
string
Returns
any
Inherited from
getUniformV2()
getUniformV2(
str):Vector2
Defined in: src/materials/Material.ts:403
Get the Vector2 value of the named uniform.
Parameters
str
string
Returns
Inherited from
getUniformV3()
getUniformV3(
str):Vector3
Defined in: src/materials/Material.ts:408
Get the Vector3 value of the named uniform.
Parameters
str
string
Returns
Inherited from
getUniformV4()
getUniformV4(
str):Vector4
Defined in: src/materials/Material.ts:413
Get the Vector4 value of the named uniform.
Parameters
str
string
Returns
Vector4
Inherited from
getUniformColor()
getUniformColor(
str):Color
Defined in: src/materials/Material.ts:418
Get the color value of the named uniform.
Parameters
str
string
Returns
Inherited from
getTexture()
getTexture(
str):Texture
Defined in: src/materials/Material.ts:423
Get the texture bound to the named shader property.
Parameters
str
string
Returns
Inherited from
getStorageBuffer()
getStorageBuffer(
str):StorageGPUBuffer
Defined in: src/materials/Material.ts:428
Get the storage buffer bound to the named shader property.
Parameters
str
string
Returns
Inherited from
getStructStorageBuffer()
getStructStorageBuffer(
str):GPUBufferBase
Defined in: src/materials/Material.ts:433
Get the struct storage buffer bound to the named shader property.
Parameters
str
string
Returns
GPUBufferBase
Inherited from
Material.getStructStorageBuffer
getUniformBuffer()
getUniformBuffer(
str):GPUBufferBase
Defined in: src/materials/Material.ts:438
Get the uniform buffer bound to the named shader property.
Parameters
str
string
Returns
GPUBufferBase
Inherited from
applyUniform()
applyUniform():
void
Defined in: src/materials/Material.ts:443
Upload pending uniform changes to the GPU.
Returns
void
Inherited from
setWave()
setWave(
index,dirX,dirZ,steepness,wavelength):void
Defined in: src/materials/WaterMaterial.ts:146
Sets one Gerstner wave. A wavelength of 0 disables it.
Parameters
index
number
0 to WATER_MAX_WAVES - 1
dirX
number
direction of travel, x
dirZ
number
direction of travel, z
steepness
number
0 to 1; the sum over all waves should stay below 1 to avoid loops
wavelength
number
crest-to-crest distance in world units
Returns
void

