Noise Module
Hash, value, gradient, Worley, cellular, and fractal noise helpers.
Turn the guide into code
Take the key idea from this page into the playground and validate it in a real shader instead of leaving it as theory.
Open PlaygroundHash, value, gradient, Worley, cellular, and fractal noise helpers.
Import
import Noise
This module has no module imports.
Usage Examples
Organic Surface Variation
Use Noise when UVs or world positions need coherent variation: dirt masks, water ripples, animated dissolve edges, terrain bands, or procedural albedo.
import Noise
float2 p = input.uv * 6.0;
float base = Noise::fbm_2d(p, 5, 2.0, 0.5);
float detail = Noise::turbulence_2d(p * 3.0 + resources.time * 0.08, 4);
float mask = saturate(base * 0.8 + detail * 0.25);
float3 clean = resources.baseColor;
float3 worn = resources.edgeWearColor;
output.color = float4(lerp(clean, worn, mask), 1.0);
Domain-Warped Effects
Use domain warp helpers when ordinary noise looks too grid-aligned or repetitive. Warped coordinates are useful for clouds, magic, fire, liquid, and force fields.
import Noise
float2 flowUv = input.uv * resources.flowScale;
float2 warped = Noise::domain_warp_2d(flowUv + resources.time * 0.05, 0.6);
float veins = Noise::ridged_fbm_2d(warped * 3.0, 5, 2.1, 0.48);
float glow = smoothstep(0.55, 0.95, veins);
float3 color = lerp(resources.backgroundColor, resources.energyColor, glow);
output.color = float4(color * (0.6 + glow * 1.8), 1.0);
Constants
const float3 HASH_SCALE3 = float3(0.1031, 0.1030, 0.0973)const float4 HASH_SCALE4 = float4(0.1031, 0.1030, 0.0973, 0.1099)Structs
No structs found.
Enums
No enums found.
Functions
hash11
float -> float
hash11 :: (float p) -> float
hash21
float2 -> float
hash21 :: (float2 p) -> float
hash31
float3 -> float
hash31 :: (float3 p) -> float
hash22
float2 -> float2
hash22 :: (float2 p) -> float2
hash33
float3 -> float3
hash33 :: (float3 p) -> float3
hash23
float2 -> float3 (useful for colored noise)
hash23 :: (float2 p) -> float3
value_noise_2d
value_noise_2d :: (float2 p) -> float
value_noise_3d
value_noise_3d :: (float3 p) -> float
gradient_noise_2d
gradient_noise_2d :: (float2 p) -> float
gradient_noise_3d
gradient_noise_3d :: (float3 p) -> float
worley_2d
Returns (F1, F2) - distance to closest and second closest points
worley_2d :: (float2 p) -> float2
worley_2d_f1
Simple F1 only version (faster)
worley_2d_f1 :: (float2 p) -> float
worley_3d
worley_3d :: (float3 p) -> float2
fbm_2d
fbm_2d :: (float2 p, int octaves, float lacunarity = 2.0, float gain = 0.5) -> float
fbm_3d
fbm_3d :: (float3 p, int octaves, float lacunarity = 2.0, float gain = 0.5) -> float
ridged_fbm_2d
Ridged multifractal - great for mountains, lightning
ridged_fbm_2d :: (float2 p, int octaves, float lacunarity = 2.0, float gain = 0.5) -> float
ridged_fbm_3d
ridged_fbm_3d :: (float3 p, int octaves, float lacunarity = 2.0, float gain = 0.5) -> float
domain_warp_2d
Warp coordinates using noise (creates organic distortions)
domain_warp_2d :: (float2 p, float strength = 1.0) -> float2
domain_warp_3d
domain_warp_3d :: (float3 p, float strength = 1.0) -> float3
domain_warp_fbm_2d
Double domain warp for more complex patterns
domain_warp_fbm_2d :: (float2 p, int octaves = 4, float warp_strength = 0.5) -> float
turbulence_2d
Turbulence (absolute value of FBM layers)
turbulence_2d :: (float2 p, int octaves) -> float
billowy_2d
Billowy noise (for clouds)
billowy_2d :: (float2 p, int octaves) -> float
voronoi_edge_2d
Swiss cheese / voronoi edge noise
voronoi_edge_2d :: (float2 p) -> float
Source
Generated from compiler-reference/modules/noise.bwsl.