ft (wip): texture/material overhaul
This commit is contained in:
@@ -2,16 +2,10 @@ use image::{DynamicImage, ImageReader};
|
||||
use log::trace;
|
||||
|
||||
use crate::{
|
||||
objects::{hit::Hit, materials::traits::Material},
|
||||
ray::Ray,
|
||||
objects::hit::Hit,
|
||||
vec3::Vec3,
|
||||
};
|
||||
|
||||
// TODO: overhaul texture implementation so we can support textures for arbitrary materials.
|
||||
// Basically remove this struct, and instead make lambertian/metal/dielectric/take either a texture
|
||||
// or a flat colour
|
||||
// I think we can use an enum ColourSource with a function to fetch a specific colour depending on
|
||||
// if we have a texture/flat colour. and yeah.
|
||||
#[derive(Debug)]
|
||||
pub struct Texture {
|
||||
source: DynamicImage,
|
||||
@@ -69,12 +63,9 @@ impl Texture {
|
||||
b[self.stride * idx + 1],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Material for Texture {
|
||||
fn scatter(&self, hit: &Hit, _ray: &Ray) -> Option<(Option<Ray>, Vec3)> {
|
||||
pub fn colour_at(&self, hit: &Hit) -> Vec3 {
|
||||
let (u, v) = hit.uv();
|
||||
let col = self._at(u, 1. - v);
|
||||
Some((None, col))
|
||||
self._at(u, 1. - v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user