Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

A material re-covering a glb takes real transmission, ior and thickness (systems/material surface.rs): a glass or frosted-veil <StandardMaterial> over a glTF part drew opaque, since over() copied every given field but those three. Test: transmission_ior_and_thickness_re_cover_a_glb_material

shinyobjectz4fe5eb115bd1
diff --git a/systems/material/src/surface.rs b/systems/material/src/surface.rs
index 5cc8da93..ba7743da 100644
--- a/systems/material/src/surface.rs
+++ b/systems/material/src/surface.rs
@@ -112,6 +112,17 @@ fn over(base: &StandardMaterial, s: &Surface) -> StandardMaterial {
if has("depth_map") {
m.depth_map = s.made.depth_map.clone();
}
+ // real transmission (glass, a frosted veil), as a mesh's material takes it (maps.rs); before this a glass
+ // <StandardMaterial> re-covering a glb drew opaque
+ if has("transmission") {
+ m.specular_transmission = s.made.specular_transmission;
+ }
+ if has("ior") {
+ m.ior = s.made.ior;
+ }
+ if has("thickness") {
+ m.thickness = s.made.thickness;
+ }
if has("fields") {
super::fields::copy(&mut m, &s.made, &s.fields);
}
@@ -176,6 +187,23 @@ mod tests {
Surface { material: material.map(str::to_string), made: StandardMaterial::default(), given: Vec::new(), fields: Vec::new(), baked: baked.then(|| super::super::lightmap::Baked { mesh: "box".into(), made }) }
}
+ #[test]
+ fn transmission_ior_and_thickness_re_cover_a_glb_material() {
+ // a glass re-cover over an opaque glTF material: the three fields given land, the rest stay the glb's
+ let mut s = spec(None, false);
+ s.made.specular_transmission = 1.0;
+ s.made.ior = 1.3;
+ s.made.thickness = 0.03;
+ s.given = vec!["transmission".into(), "ior".into(), "thickness".into()];
+ let base = StandardMaterial { perceptual_roughness: 0.8, ..default() };
+ let m = over(&base, &s);
+ assert_eq!((m.specular_transmission, m.ior, m.thickness), (1.0, 1.3, 0.03));
+ assert_eq!(m.perceptual_roughness, 0.8);
+ // not given: the glb's own
+ let plain = over(&base, &spec(None, false));
+ assert_eq!(plain.specular_transmission, base.specular_transmission);
+ }
+
#[test]
fn a_bake_is_never_the_material_a_glb_material_takes() {
// a <Lightmap> names no material: it isn't the fallback for every material either