use geometry::prelude::*;
use std::sync::Arc;
#[derive(Copy, Clone, PartialEq)]
pub struct TexInfo2D {
pub p: Point2f,
pub dpdx: Vector2f,
pub dpdy: Vector2f,
}
#[derive(Copy, Clone, PartialEq)]
pub struct TexInfo3D {
pub p: Point3f,
pub dpdx: Vector3f,
pub dpdy: Vector3f,
}
pub trait Mapping2D {
fn map(&self, si: &SurfaceInteraction, dxy: &DxyInfo) -> TexInfo2D;
}
pub trait Mapping3D {
fn map(&self, si: &SurfaceInteraction, dxy: &DxyInfo) -> TexInfo3D;
}
pub trait Texture: Send + Sync {
type Texel;
fn evaluate(&self, si: &SurfaceInteraction, dxy: &DxyInfo) -> Self::Texel;
fn mean(&self) -> Self::Texel;
}
impl<'a, T: 'a> Texture for &'a T
where T: Texture
{
type Texel = <T as Texture>::Texel;
#[inline]
fn evaluate(&self, si: &SurfaceInteraction, dxy: &DxyInfo) -> Self::Texel {
(*self).evaluate(si, dxy)
}
#[inline]
fn mean(&self) -> Self::Texel {
(*self).mean()
}
}
impl<T: Texture + ?Sized> Texture for Arc<T> {
type Texel = <T as Texture>::Texel;
#[inline]
fn evaluate(&self, si: &SurfaceInteraction, dxy: &DxyInfo) -> Self::Texel {
(**self).evaluate(si, dxy)
}
#[inline]
fn mean(&self) -> Self::Texel {
(**self).mean()
}
}
pub mod mappings;
pub mod textures;
pub mod prelude;