From 73149fe3e6b05270b0eac51fbb0b9d20e7fa1c3f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 10:20:02 +0000 Subject: [PATCH] Preserve displacement image tiling in MaterialX --- crates/materialx/src/lib.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/materialx/src/lib.rs b/crates/materialx/src/lib.rs index 72afc8ca1..99701366f 100644 --- a/crates/materialx/src/lib.rs +++ b/crates/materialx/src/lib.rs @@ -327,7 +327,13 @@ impl Document { .and_then(|i| i.attr("nodename")) .and_then(|n| nodes.get(n).copied()) .and_then(|d| d.children("input").find(|i| i.attr("name") == Some("displacement"))) - .and_then(|i| resolve_value(&self.root, i, None, &nodes, &outputs, 0, &mut warnings).map(|f| f.value)); + .and_then(|i| resolve_value(&self.root, i, None, &nodes, &outputs, 0, &mut warnings)) + .map(|found| { + if tiling.is_none() { + tiling = found.tiling; + } + found.value + }); Ok(Material { name: mat.attr("name").unwrap_or("Material").to_owned(), shader: kind, @@ -552,6 +558,19 @@ mod tests { assert!(matches!(Document::parse(&vec![b' '; MAX_BYTES + 1]), Err(Error::Xml(XmlError::TooLarge(_))))); } + #[test] + fn displacement_image_supplies_tiling_when_surface_inputs_do_not() { + let xml = br#" + + + + + "#; + let material = Document::parse(xml).unwrap().read_material(None).unwrap(); + assert_eq!(material.displacement, Some(Value::Image("height.png".into()))); + assert_eq!(material.uv_tiling, [4.0, 2.0]); + } + #[test] fn resolves_openpbr_values_images_graphs_and_displacement() { let doc = Document::parse(br#"