Variable: precipitation
constprecipitation:object
Defined in: modules/geometry/precipitation/precipitation.ts:19
Stateless, seeded falling particles in a movable volume. Coordinates are local metres.
Type Declaration
bindingLayout
readonlybindingLayout: readonly [{group:3;name:"precipitation"; }]
defaultUniforms
readonlydefaultUniforms:object
defaultUniforms.fallSpeed
readonlyfallSpeed:20=20
defaultUniforms.seed
readonlyseed:29=29
defaultUniforms.time
readonlytime:0=0
defaultUniforms.turbulence
readonlyturbulence:0=0
defaultUniforms.volumeCenter
readonlyvolumeCenter: [0,0,150]
defaultUniforms.volumeSize
readonlyvolumeSize: [1200,1600,300]
defaultUniforms.wind
readonlywind: [2,0]
name
readonlyname:"precipitation"='precipitation'
source
readonlysource: "\nstruct precipitationUniforms {\n time: f32,\n fallSpeed: f32,\n turbulence: f32,\n seed: f32,\n volumeCenter: vec3<f32>,\n volumeSize: vec3<f32>,\n wind: vec2<f32>,\n};\n@group(3) @binding(auto) var<uniform> precipitation: precipitationUniforms;\nfn precipitation_random(identifier: u32) -> f32 {\n var value = identifier + u32(precipitation.seed) * 747796405u;\n value = (value ^ (value >> 16u)) * 2246822519u;\n value = (value ^ (value >> 13u)) * 3266489917u;\n value = value ^ (value >> 16u);\n return f32(value & 16777215u) / 16777216.0;\n}\nfn precipitation_getPosition(identifier: u32) -> vec3<f32> {\n let randomPosition = vec3<f32>(precipitation_random(identifier * 3u), precipitation_random(identifier * 3u + 1u), precipitation_random(identifier * 3u + 2u));\n let volumeSize = max(precipitation.volumeSize, vec3<f32>(0.001));\n let minimum = precipitation.volumeCenter - volumeSize * 0.5;\n let drift = vec3<f32>(precipitation.wind, -precipitation.fallSpeed) * precipitation.time;\n let unwrapped = randomPosition * volumeSize + drift - minimum;\n var position = unwrapped - floor(unwrapped / volumeSize) * volumeSize + minimum;\n position.x += precipitation.turbulence * sin(precipitation.time * 0.9 + randomPosition.z * 31.0);\n position.y += precipitation.turbulence * cos(precipitation.time * 0.7 + randomPosition.x * 23.0);\n return position;\n}\nfn precipitation_getFade(position: vec3<f32>) -> f32 {\n let edge = 0.5 - abs((position - precipitation.volumeCenter) / max(precipitation.volumeSize, vec3<f32>(0.001)));\n return smoothstep(0.0, 0.08, min(edge.x, min(edge.y, edge.z)));\n}\n"
uniformTypes
readonlyuniformTypes:object
uniformTypes.fallSpeed
readonlyfallSpeed:"f32"='f32'
uniformTypes.seed
readonlyseed:"f32"='f32'
uniformTypes.time
readonlytime:"f32"='f32'
uniformTypes.turbulence
readonlyturbulence:"f32"='f32'
uniformTypes.volumeCenter
readonlyvolumeCenter:"vec3<f32>"='vec3<f32>'
uniformTypes.volumeSize
readonlyvolumeSize:"vec3<f32>"='vec3<f32>'
uniformTypes.wind
readonlywind:"vec2<f32>"='vec2<f32>'
vs
readonlyvs: "\nlayout(std140) uniform precipitationUniforms {\n float time;\n float fallSpeed;\n float turbulence;\n float seed;\n vec3 volumeCenter;\n vec3 volumeSize;\n vec2 wind;\n} precipitation;\nfloat precipitation_random(uint identifier) {\n uint value = identifier + uint(precipitation.seed) * 747796405u;\n value = (value ^ (value >> 16u)) * 2246822519u;\n value = (value ^ (value >> 13u)) * 3266489917u;\n value = value ^ (value >> 16u);\n return float(value & 16777215u) / 16777216.0;\n}\nvec3 precipitation_getPosition(uint identifier) {\n vec3 randomPosition = vec3(precipitation_random(identifier * 3u), precipitation_random(identifier * 3u + 1u), precipitation_random(identifier * 3u + 2u));\n vec3 volumeSize = max(precipitation.volumeSize, vec3(0.001));\n vec3 minimum = precipitation.volumeCenter - volumeSize * 0.5;\n vec3 drift = vec3(precipitation.wind, -precipitation.fallSpeed) * precipitation.time;\n vec3 position = mod(randomPosition * volumeSize + drift - minimum, volumeSize) + minimum;\n position.xy += precipitation.turbulence * vec2(sin(precipitation.time * 0.9 + randomPosition.z * 31.0), cos(precipitation.time * 0.7 + randomPosition.x * 23.0));\n return position;\n}\nfloat precipitation_getFade(vec3 position) {\n vec3 edge = 0.5 - abs((position - precipitation.volumeCenter) / max(precipitation.volumeSize, vec3(0.001)));\n return smoothstep(0.0, 0.08, min(edge.x, min(edge.y, edge.z)));\n}\n"
getUniforms()
readonlygetUniforms(props?):Partial<PrecipitationUniforms>
Parameters
props?
PrecipitationProps = {}
Returns
Partial<PrecipitationUniforms>