aboutsummaryrefslogtreecommitdiff
path: root/src/material/isotropic.rs
diff options
context:
space:
mode:
authorlamp2024-01-21 17:03:07 +0000
committerlamp2024-01-21 17:03:07 +0000
commit45fafbcd4b41a5388ece377c4e051b5846407288 (patch)
tree2192c471ca3b47671f0906e27f6f6088f40b3d8a /src/material/isotropic.rs
parent89a5c9a8a0cdf627cda0e31da454f83ca21315ce (diff)
fmt and tidy
Diffstat (limited to 'src/material/isotropic.rs')
-rw-r--r--src/material/isotropic.rs33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/material/isotropic.rs b/src/material/isotropic.rs
index f59fa7d..9949abd 100644
--- a/src/material/isotropic.rs
+++ b/src/material/isotropic.rs
@@ -1,32 +1,39 @@
use std::sync::Arc;
use super::Material;
-use crate::{hittable::HitRecord, texture::Texture, vec3::Vec3};
-use crate::vec3::Color;
-use crate::texture::SolidColor;
use crate::ray::Ray;
+use crate::vec3::Color;
+use crate::{hittable::HitRecord, texture::Texture, vec3::Vec3};
pub struct Isotropic {
albedo: Arc<dyn Texture>,
}
impl Isotropic {
- pub fn from_color(color: Color) -> Self {
- Self {
- albedo: Arc::new(SolidColor::from_color(color)),
- }
- }
+ // pub fn from_color(color: Color) -> Self {
+ // Self {
+ // albedo: Arc::new(SolidColor::from_color(color)),
+ // }
+ // }
pub fn from_texture(texture: Arc<dyn Texture>) -> Self {
- Self {
- albedo: texture,
- }
+ Self { albedo: texture }
}
}
impl Material for Isotropic {
- fn scatter(&self, ray_in: &Ray, hit_record: &HitRecord, attenuation: &mut Color, scattered: &mut Ray) -> bool {
- *scattered = Ray { origin: hit_record.p.clone(), direction: Vec3::random_in_unit_sphere(), time: ray_in.time };
+ fn scatter(
+ &self,
+ ray_in: &Ray,
+ hit_record: &HitRecord,
+ attenuation: &mut Color,
+ scattered: &mut Ray,
+ ) -> bool {
+ *scattered = Ray {
+ origin: hit_record.p.clone(),
+ direction: Vec3::random_in_unit_sphere(),
+ time: ray_in.time,
+ };
*attenuation = self.albedo.value(hit_record.u, hit_record.v, &hit_record.p);
true
}