MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / alpha_cutoff_from_material

Function alpha_cutoff_from_material

native/shared/src/models.rs:1767–1773  ·  view source on GitHub ↗

Convert a KHR_materials_pbrSpecularGlossiness (diffuse + specular + glossiness) material to the metallic-roughness model. Uses the reference Khronos two-path formula so materials authored in Substance/3ds Max/FBX pipelines (Lumberyard Bistro, many ORCA assets) render correctly on a metal-rough pipeline. High-level idea: assume a 0.04 dielectric reflectance baseline, solve for the metallic factor

(mat: &gltf::Material)

Source from the content-addressed store, hash-verified

1765/// foliage + fabric as fully opaque — an alpha-cutout leaf
1766/// card is at least the right *shape*.
1767fn alpha_cutoff_from_material(mat: &gltf::Material) -> f32 {
1768 match mat.alpha_mode() {
1769 gltf::material::AlphaMode::Opaque => 0.0,
1770 gltf::material::AlphaMode::Mask => mat.alpha_cutoff().unwrap_or(0.5),
1771 gltf::material::AlphaMode::Blend => 0.5,
1772 }
1773}
1774
1775/// Fake KHR_materials_transmission as a near-mirror dielectric.
1776///

Callers 2

load_gltf_with_texturesFunction · 0.85
load_gltf_stagedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected