Parameters
Name | Type | Description |
---|---|---|
x | vec3<f32> | Input 3D position for noise generation. |
Returns
Dependencies
WGSL Code
//! requires hash31fn noise3D(x: vec3<f32>) -> f32 {let p = floor(x);let f = fract(x);return mix(mix(mix(hash31(p),hash31(p + vec3<f32>(1.0, 0.0, 0.0)),f.x),mix(hash31(p + vec3<f32>(0.0, 1.0, 0.0)),hash31(p + vec3<f32>(1.0, 1.0, 0.0)),f.x),f.y),mix(mix(hash31(p + vec3<f32>(0.0, 0.0, 1.0)),hash31(p + vec3<f32>(1.0, 0.0, 1.0)),f.x),mix(hash31(p + vec3<f32>(0.0, 1.0, 1.0)),hash31(p + vec3<f32>(1.0, 1.0, 1.0)),f.x),f.y),f.z);}