#[derive(Debug, Clone)]
pub struct PbrMaterial {
pub name: &'static str,
pub albedo: [f32; 4],
pub roughness: f32,
pub metallic: f32,
pub normal_strength: f32,
pub emissive: [f32; 3],
pub ior: f32,
pub subsurface: f32,
}
impl PbrMaterial {
pub fn fresnel_r0(&self) -> f64 {
let n = self.ior as f64;
let r = (n - 1.0) / (n + 1.0);
r * r
}
}
pub fn basaltic_plain() -> PbrMaterial {
PbrMaterial {
name: "basaltic_plain",
albedo: [0.45, 0.32, 0.18, 1.0],
roughness: 0.9,
metallic: 0.03,
normal_strength: 1.0,
emissive: [0.0; 3],
ior: 1.58,
subsurface: 0.0,
}
}
pub fn tessera_highland() -> PbrMaterial {
PbrMaterial {
name: "tessera_highland",
albedo: [0.58, 0.46, 0.28, 1.0],
roughness: 0.95,
metallic: 0.02,
normal_strength: 1.2,
emissive: [0.0; 3],
ior: 1.55,
subsurface: 0.0,
}
}
pub fn volcanic_flow() -> PbrMaterial {
PbrMaterial {
name: "volcanic_flow",
albedo: [0.18, 0.10, 0.06, 1.0],
roughness: 0.75,
metallic: 0.08,
normal_strength: 1.4,
emissive: [0.04, 0.01, 0.0],
ior: 1.60,
subsurface: 0.0,
}
}
pub fn weathered_plain() -> PbrMaterial {
PbrMaterial {
name: "weathered_plain",
albedo: [0.52, 0.38, 0.22, 1.0],
roughness: 0.92,
metallic: 0.01,
normal_strength: 0.8,
emissive: [0.0; 3],
ior: 1.50,
subsurface: 0.0,
}
}
pub fn all_venus() -> [PbrMaterial; 4] {
[
basaltic_plain(),
tessera_highland(),
volcanic_flow(),
weathered_plain(),
]
}