2D Value Noise
Hash grid noise gives each cell a hard, sudden color — it looks like a mosaic. Value Noise fixes that by interpolating the random values at neighboring grid corners, so colors blend smoothly. The whole thing comes down to:
Let's look at what valueNoise does inside.
Getting the four corner values
Split the coordinate into an integer part i (which cell) and a fractional part f (where inside the cell):
Then sample the hash at each corner of the cell:
Smooth interpolation
Blending with raw f produces linear interpolation, which leaves faint creases at cell edges. A smoothing curve fixes this:
This curve has a slope of zero at both 0% and 100%, meaning the transition meets each grid corner tangentially — no kinks.
Then blend in both X and Y using mix:
Try changing it
| Change | Effect |
|---|---|
8.0 → 2.0 | Larger blobs, like rolling hills |
8.0 → 32.0 | Finer noise, approaching a misty haze |
u = f*f*(3.0-2.0*f) → u = f | Linear interpolation — faint creases appear at cell borders |
vec3(n) → vec3(n, n*0.8, n*0.6) | Warm-toned noise |
Exercise
Inside main, call valueNoise(vUv * 8.0) and output the result as a grayscale image.
Answer Breakdown
Replace n = 0.0 with n = valueNoise(vUv * 8.0).
vUv * 8.0— scales coordinates to control noise frequencyvalueNoise(...)— interpolates the four grid corners and returns a smooth 0–1 valuevec3(n)— grayscale output
The starter has n = 0.0, so everything is black. After the change, each pixel gets an interpolated value based on its position within the cell, producing smoothly flowing noise.
Try changing 8.0 to 4.0 and see how the noise gets larger and softer.