#[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 regolith() -> PbrMaterial {
PbrMaterial {
name: "regolith",
albedo: [0.45, 0.22, 0.12, 1.0],
roughness: 0.9,
metallic: 0.0,
normal_strength: 1.0,
emissive: [0.0; 3],
ior: 1.50,
subsurface: 0.0,
}
}
pub fn bright_dust() -> PbrMaterial {
PbrMaterial {
name: "bright_dust",
albedo: [0.55, 0.35, 0.15, 1.0],
roughness: 0.95,
metallic: 0.0,
normal_strength: 0.5,
emissive: [0.0; 3],
ior: 1.50,
subsurface: 0.1,
}
}
pub fn dark_dune() -> PbrMaterial {
PbrMaterial {
name: "dark_dune",
albedo: [0.08, 0.06, 0.05, 1.0],
roughness: 0.7,
metallic: 0.05,
normal_strength: 1.2,
emissive: [0.0; 3],
ior: 1.52,
subsurface: 0.0,
}
}
pub fn basalt() -> PbrMaterial {
PbrMaterial {
name: "basalt",
albedo: [0.12, 0.10, 0.09, 1.0],
roughness: 0.6,
metallic: 0.08,
normal_strength: 1.5,
emissive: [0.0; 3],
ior: 1.58,
subsurface: 0.0,
}
}
pub fn water_ice() -> PbrMaterial {
PbrMaterial {
name: "water_ice",
albedo: [0.80, 0.85, 0.90, 1.0],
roughness: 0.3,
metallic: 0.0,
normal_strength: 0.3,
emissive: [0.0; 3],
ior: 1.31,
subsurface: 0.6,
}
}
pub fn co2_ice() -> PbrMaterial {
PbrMaterial {
name: "co2_ice",
albedo: [0.70, 0.72, 0.75, 1.0],
roughness: 0.2,
metallic: 0.0,
normal_strength: 0.2,
emissive: [0.0; 3],
ior: 1.41,
subsurface: 0.5,
}
}
pub fn sulfate_salt() -> PbrMaterial {
PbrMaterial {
name: "sulfate_salt",
albedo: [0.60, 0.58, 0.45, 1.0],
roughness: 0.8,
metallic: 0.0,
normal_strength: 0.8,
emissive: [0.0; 3],
ior: 1.48,
subsurface: 0.0,
}
}
pub fn volcanic_summit() -> PbrMaterial {
PbrMaterial {
name: "volcanic_summit",
albedo: [0.06, 0.05, 0.04, 1.0],
roughness: 0.5,
metallic: 0.1,
normal_strength: 2.0,
emissive: [0.002, 0.0005, 0.0],
ior: 1.60,
subsurface: 0.0,
}
}
pub fn all_mars() -> [PbrMaterial; 8] {
[
regolith(),
bright_dust(),
dark_dune(),
basalt(),
water_ice(),
co2_ice(),
sulfate_salt(),
volcanic_summit(),
]
}