Initial pbrt material parsing

This commit is contained in:
hal8174 2025-08-18 11:40:25 +02:00
parent 0dfa2128dd
commit 9a95ca8fd7
Signed by: hal8174
SSH key fingerprint: SHA256:NN98ZYwnrreQLSOV/g+amY7C3yL/mS1heD7bi5t6PPw
7 changed files with 401 additions and 108 deletions

View file

@ -3,7 +3,7 @@ use super::*;
#[derive(Debug)]
pub(super) struct FloatCheckerboardTexture2d {
pub(super) mapping: UVMapping,
pub(super) tex: [ValueTexture<Float, Arc<dyn Pbrt_2d_float_texture>>; 2],
pub(super) tex: [Either<Float, Arc<dyn Pbrt_2d_float_texture>>; 2],
}
impl Pbrt_2d_float_texture for FloatCheckerboardTexture2d {
@ -21,8 +21,8 @@ impl Pbrt_2d_float_texture for FloatCheckerboardTexture2d {
};
match &self.tex[even as usize] {
ValueTexture::Value(v) => *v,
ValueTexture::Texture(t) => t.get(u, v),
Either::A(v) => *v,
Either::B(t) => t.get(u, v),
}
}
}
@ -43,7 +43,7 @@ impl PbrtTexture for FloatCheckerboardTexture2d {
#[derive(Debug)]
pub(super) struct SpectrumCheckerboardTexture2d {
pub(super) mapping: UVMapping,
pub(super) tex: [ValueTexture<Color, Arc<dyn Pbrt_2d_spectrum_texture>>; 2],
pub(super) tex: [Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>; 2],
}
impl Pbrt_2d_spectrum_texture for SpectrumCheckerboardTexture2d {
@ -61,8 +61,8 @@ impl Pbrt_2d_spectrum_texture for SpectrumCheckerboardTexture2d {
};
match &self.tex[even as usize] {
ValueTexture::Value(v) => *v,
ValueTexture::Texture(t) => t.get(u, v),
Either::A(v) => *v,
Either::B(t) => t.get(u, v),
}
}
}

View file

@ -2,8 +2,8 @@ use super::*;
#[derive(Debug)]
pub(super) struct SpectrumScaleTexture2d {
pub(super) tex: ValueTexture<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
pub(super) scale: ValueTexture<Float, Arc<dyn Pbrt_2d_float_texture>>,
pub(super) tex: Either<Color, Arc<dyn Pbrt_2d_spectrum_texture>>,
pub(super) scale: Either<Float, Arc<dyn Pbrt_2d_float_texture>>,
}
impl PbrtTexture for SpectrumScaleTexture2d {
@ -23,13 +23,13 @@ impl PbrtTexture for SpectrumScaleTexture2d {
impl Pbrt_2d_spectrum_texture for SpectrumScaleTexture2d {
fn get(&self, u: Float, v: Float) -> Color {
let x = match &self.tex {
ValueTexture::Value(x) => *x,
ValueTexture::Texture(t) => t.get(u, v),
Either::A(x) => *x,
Either::B(t) => t.get(u, v),
};
let s = match &self.scale {
ValueTexture::Value(s) => *s,
ValueTexture::Texture(t) => t.get(u, v),
Either::A(s) => *s,
Either::B(t) => t.get(u, v),
};
x * s