blob: 4feca3be0317e5b385f0b68aa6fd6a0c33a78fa2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use std::sync::Arc;
use super::Material;
use crate::ray::Ray;
use crate::texture::SolidColor;
use crate::vec3::Color;
use crate::{hittable::HitRecord, texture::Texture, vec3::Point3};
pub struct DiffuseLight {
emit: Arc<dyn Texture>,
}
impl DiffuseLight {
pub fn from_color(color: Color) -> Self {
Self {
emit: Arc::new(SolidColor::from_color(color)),
}
}
}
impl Material for DiffuseLight {
fn scatter(&self, _: &Ray, _: &HitRecord, _: &mut Color, _: &mut Ray) -> bool {
false
}
fn emitted(&self, u: f64, v: f64, point: &Point3) -> Color {
self.emit.value(u, v, point)
}
}
|