18 lines
433 B
Rust
18 lines
433 B
Rust
use crate::perlin::Perlin;
|
|
use crate::{Color, Point3};
|
|
use crate::texture::Texture;
|
|
|
|
pub struct NoiseTexture {
|
|
pub noise: Perlin,
|
|
pub scale: f64
|
|
}
|
|
|
|
impl Texture for NoiseTexture {
|
|
fn value(&self, _u: f64, _v: f64, point: &Point3) -> Color {
|
|
let sin = self.scale * point.z() + 10.0 * self.noise.default_turbulence(point);
|
|
Color::new(1.0, 1.0, 1.0)
|
|
* 0.5
|
|
* (1.0 + sin.sin())
|
|
}
|
|
}
|