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#"