Skip to content

Commit 4a523fc

Browse files
committed
Ifguard potentially unsupported MaterialX glTF PBR features
This is not strictly necessary as we add inputs regardless of the provided NodeDef. However, an outdated NodeDef which is f.i. provided by an older MaterialX version still produces document validation errors. In order to avoid these errors, we make the hard assumption that the provided MaterialX glTF PBR implementation is that of the corresponding MaterialX C++ library, allowing us to conditionally disable newer and unsupported features like KHR_materials_emissive_strength and KHR_materials_iridescence.
1 parent fd4ec6c commit 4a523fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libguc/src/materialx.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,15 @@ namespace guc
586586
}
587587
}
588588

589+
#if MATERIALX_MINOR_VERSION > 38 || (MATERIALX_MINOR_VERSION == 38 && MATERIALX_BUILD_VERSION >= 5)
589590
if (material->has_emissive_strength)
590591
{
591592
const cgltf_emissive_strength* emissiveStrength = &material->emissive_strength;
592593

593594
mx::InputPtr emissiveStrengthInput = shaderNode->addInput("emissive_strength", MTLX_TYPE_FLOAT);
594595
emissiveStrengthInput->setValue(emissiveStrength->emissive_strength);
595596
}
597+
#endif
596598

597599
if (material->has_clearcoat)
598600
{
@@ -646,6 +648,7 @@ namespace guc
646648
iorInput->setValue(ior->ior);
647649
}
648650

651+
#if MATERIALX_MINOR_VERSION > 38 || (MATERIALX_MINOR_VERSION == 38 && MATERIALX_BUILD_VERSION >= 6)
649652
if (material->has_iridescence)
650653
{
651654
const cgltf_iridescence* iridescence = &material->iridescence;
@@ -660,6 +663,7 @@ namespace guc
660663
mx::InputPtr iridescenceThicknessInput = shaderNode->addInput("iridescence_thickness", MTLX_TYPE_FLOAT);
661664
setIridescenceThicknessInput(nodeGraph, iridescenceThicknessInput, iridescence);
662665
}
666+
#endif
663667

664668
if (material->has_specular)
665669
{

0 commit comments

Comments
 (0)