Skip to main content

Variable: precipitation

const precipitation: object

Defined in: modules/geometry/precipitation/precipitation.ts:19

Stateless, seeded falling particles in a movable volume. Coordinates are local metres.

Type Declaration​

bindingLayout​

readonly bindingLayout: readonly [{ group: 3; name: "precipitation"; }]

defaultUniforms​

readonly defaultUniforms: object

defaultUniforms.fallSpeed​

readonly fallSpeed: 20 = 20

defaultUniforms.seed​

readonly seed: 29 = 29

defaultUniforms.time​

readonly time: 0 = 0

defaultUniforms.turbulence​

readonly turbulence: 0 = 0

defaultUniforms.volumeCenter​

readonly volumeCenter: [0, 0, 150]

defaultUniforms.volumeSize​

readonly volumeSize: [1200, 1600, 300]

defaultUniforms.wind​

readonly wind: [2, 0]

name​

readonly name: "precipitation" = 'precipitation'

source​

readonly source: "\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​

readonly uniformTypes: object

uniformTypes.fallSpeed​

readonly fallSpeed: "f32" = 'f32'

uniformTypes.seed​

readonly seed: "f32" = 'f32'

uniformTypes.time​

readonly time: "f32" = 'f32'

uniformTypes.turbulence​

readonly turbulence: "f32" = 'f32'

uniformTypes.volumeCenter​

readonly volumeCenter: "vec3<f32>" = 'vec3<f32>'

uniformTypes.volumeSize​

readonly volumeSize: "vec3<f32>" = 'vec3<f32>'

uniformTypes.wind​

readonly wind: "vec2<f32>" = 'vec2<f32>'

vs​

readonly vs: "\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()​

readonly getUniforms(props?): Partial<PrecipitationUniforms>

Parameters​

props?​

PrecipitationProps = {}

Returns​

Partial<PrecipitationUniforms>