use sciforge::hub::prelude::constants::elements::{atomic_mass, electronegativity};
#[derive(Debug, Clone)]
pub struct PbrMaterial {
pub albedo: [f32; 4],
pub roughness: f32,
pub metallic: f32,
pub normalstrength: f32,
pub emissive: [f32; 3],
}
fn metallicfromiron(fewtfrac: f64) -> f32 {
let mfe = atomic_mass(26);
let mo = atomic_mass(8);
let fefractioninfeo = mfe / (mfe + mo);
let purefe = fewtfrac * fefractioninfeo;
let en = electronegativity(26).unwrap_or(1.83);
let metallicscale = (1.0 - en / 4.0).max(0.0);
(purefe * metallicscale).clamp(0.0, 1.0) as f32
}
impl PbrMaterial {
pub fn ammoniacloud() -> Self {
Self {
albedo: [0.90, 0.85, 0.70, 0.8],
roughness: 0.25,
metallic: 0.0,
normalstrength: 0.3,
emissive: [0.0; 3],
}
}
pub fn nh4shcloud() -> Self {
Self {
albedo: [0.70, 0.55, 0.35, 0.85],
roughness: 0.4,
metallic: 0.0,
normalstrength: 0.5,
emissive: [0.0; 3],
}
}
pub fn deepatmosphere() -> Self {
Self {
albedo: [0.15, 0.10, 0.05, 1.0],
roughness: 0.1,
metallic: 0.01,
normalstrength: 0.2,
emissive: [0.0; 3],
}
}
pub fn hazelayer() -> Self {
Self {
albedo: [0.80, 0.75, 0.60, 0.35],
roughness: 0.1,
metallic: 0.0,
normalstrength: 0.1,
emissive: [0.0; 3],
}
}
pub fn corerock() -> Self {
Self {
albedo: [0.25, 0.20, 0.15, 1.0],
roughness: 0.95,
metallic: metallicfromiron(0.20),
normalstrength: 1.0,
emissive: [0.0; 3],
}
}
pub fn metallichydrogen() -> Self {
Self {
albedo: [0.55, 0.55, 0.55, 0.95],
roughness: 0.05,
metallic: 0.85,
normalstrength: 0.3,
emissive: [0.005, 0.005, 0.008],
}
}
pub fn stormregion() -> Self {
Self {
albedo: [0.55, 0.30, 0.15, 1.0],
roughness: 0.35,
metallic: 0.0,
normalstrength: 0.9,
emissive: [0.0; 3],
}
}
}