1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// pbrt
use crate::core::interaction::SurfaceInteraction;
use crate::core::texture::Texture;

// see constant.h

pub struct ConstantTexture<T> {
    pub value: T,
}

impl<T: Copy> ConstantTexture<T> {
    pub fn new(value: T) -> Self {
        ConstantTexture { value }
    }
}

impl<T: Copy> Texture<T> for ConstantTexture<T> {
    fn evaluate(&self, _si: &SurfaceInteraction) -> T {
        self.value
    }
}