Finalize marble parameters for scene/final.

Add pixel_scale parameter to noise_explorer to allow scaling of p vector
passed to value function.
This commit is contained in:
2018-10-15 12:42:22 -07:00
parent 5faba9cf26
commit ea0532fd6e
5 changed files with 157 additions and 50 deletions

View File

@@ -9,7 +9,8 @@ pub trait NoiseSource: Send + Sync {
/// value returns noise on the interval [0., 1.).
fn value(&self, p: Vec3) -> f32;
fn marble(&self, p: Vec3, period: Vec3, power: f32, size: usize) -> f32 {
fn marble(&self, p: Vec3, period: Vec3, power: f32, size: usize, scale: f32) -> f32 {
let p = p / scale;
// TODO(wathiede): can't understand why 255 works for perlin and lode, maybe it's near 360
// degrees and interacts with the sine function?
let xyz_value = p.x * period.x / 255.
@@ -52,6 +53,7 @@ pub enum NoiseType {
period: Vec3,
power: f32,
size: usize,
scale: f32,
},
}
@@ -64,9 +66,10 @@ impl NoiseType {
period,
power,
size,
scale,
} => format!(
"marble/period/{},{},{}/power/{}/size/{}",
period.x, period.y, period.z, power, size,
"marble/period/{},{},{}/power/{}/size/{}/scale/{}",
period.x, period.y, period.z, power, size, scale
),
}
}
@@ -79,10 +82,12 @@ impl NoiseType {
period,
power,
size,
scale,
} => vec![
("Period", period.to_string()),
("Power", power.to_string()),
("Size", size.to_string()),
("Scale", scale.to_string()),
],
}
}