Sheet 7: Procedural Volume Generation
Exercise 1: Rescale-And-Add Clouds (20 points)
In this exercise you will replace the analytic volume datasets from the previous sheets with a procedurally generated cloud volume. The raycaster, transfer function, and volumetric shadow computation are already implemented.
Your task is to complete RescaleAndAddVolume.cpp. The class already contains
the volume parameters, a permutation table, Perlin noise sampling, and helper functions
such as smoothStep. The missing part is the actual cloud-density generation.
Implement the procedural volume in three parts:
- Fill
RescaleAndAddVolume::generateby iterating over all voxels. - Map voxel coordinates to normalized coordinates in
[0, 1]. - Implement
fractalNoiseas rescale-and-add noise over multiple octaves. - Use
roughnessfor the amplitude decay andlacunarityfor the frequency growth. - Implement
cloudEnvelopeto create a soft, noisy spherical falloff. - Shape the final density using coverage, density scale, density offset, and density exponent.
The fractal noise should follow the rescale-and-add formula from the lecture:
Here N is the provided Perlin noise function, f is
baseFrequency, l is lacunarity,
r is roughness, and o is
octaves. Normalize the sum by
A = ∑i=0o-1 ri so the
result remains in a stable range when changing the number of octaves.
The provided perlin function returns values roughly in
[-1, 1]. For ordinary noise, remap each octave with
0.5 * octaveValue + 0.5. For billowy noise, use
1.0 - abs(octaveValue) before adding the octave to the sum.
After computing the base fractal noise, shape the cloud density in
generate:
- Compute
noise = fractalNoise(x, y, z). - Compute
envelope = cloudEnvelope(x, y, z). - Use an additional high-frequency Perlin sample as detail noise.
- Compute
erosion = 1.0 - detailErosion * (1.0 - detail). - Combine structure and boundary with
shapedNoise = noise * (0.20 + 0.80 * envelope) * erosion. - Threshold the cloud with
cloudShape = smoothStep(coverage, 1.0, shapedNoise). - Shape opacity with
pow(cloudShape, densityExponent) * densityScale + densityOffset. - Clamp to
[0, 1], multiply byenvelope, and storeround(density * 255).
For cloudEnvelope, start with the distance to the center of the unit volume.
Then perturb the radius with a low-frequency Perlin sample:
Use radius * radiusScale as the local boundary and return
1.0 - smoothStep(radius - envelopeSoftness, radius, distance).
This keeps the volume brick rectangular, but makes the actual cloud fade out with
a soft, noisy silhouette.
The generated volume should be written into volume.data as 8-bit density values.
Use the parameter sets in main.cpp to compare different clouds with the
V key.
The most relevant parameters are:
octaves,roughness, andlacunarity: control the rescale-and-add noise.baseFrequency: controls the scale of the largest structures.coverage: controls how much of the noise becomes visible cloud.radiusandenvelopeSoftness: control the large-scale cloud boundary.silhouetteNoiseFrequencyandsilhouetteNoiseStrength: roughen the outline.detailErosion: removes material using high-frequency detail.
Exercise 2: Find a Better Cloud (10 points)
The provided parameter sets in main.cpp are intentionally only a starting point.
They demonstrate that the generator works, but they do not create especially convincing
clouds yet. Procedural modeling often needs experimentation: small parameter changes can
move the result from a soft cloud to a dense blob, noisy foam, or something that looks
more like stone.
Create at least one additional RescaleAndAddVolumeParameters entry that
produces a better-looking cloud. You may change any generator parameter, but keep the
volume resolution reasonable enough that the program remains interactive.
Try to improve both the large shape and the fine structure:
- Use
radius,envelopeSoftness, and silhouette noise to avoid an obvious sphere. - Use
coverage,densityScale, anddensityExponentto control how quickly density appears. - Use
baseFrequency,octaves,roughness, andlacunarityto balance large fluffy shapes and smaller detail. - Use
detailErosionto break up overly solid regions. - Check the result from multiple view and light directions.
Submit the new parameter set together with a short explanation of what you changed and why the result looks more cloud-like than the provided examples.
Reference Solution
V toggle cloud parameter set, R reset, T toggle transfer-function editor
1 clip in X, 2 clip in Y, 3 clip in Z
4 move clip in X, 5 move clip in Y, 6 move clip in Z
Q increase oversampling, W decrease oversampling
J/L move light in X, I/K move light in Y, U/O move light in Z
Up zoom in, Down zoom out
Left mouse drag rotate, Right mouse drag quick edit transfer function