From 72245f453cfce74dff4b04966ea8653e0bbd2016 Mon Sep 17 00:00:00 2001 From: hybridherbst Date: Tue, 12 Dec 2023 10:49:48 +0100 Subject: [PATCH] feat: add normalNode and emissiveNode support for MaterialXLoader (#27356) --- examples/jsm/loaders/MaterialXLoader.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/jsm/loaders/MaterialXLoader.js b/examples/jsm/loaders/MaterialXLoader.js index 5a1f5fad5bfb36..0eafc99f32499e 100644 --- a/examples/jsm/loaders/MaterialXLoader.js +++ b/examples/jsm/loaders/MaterialXLoader.js @@ -588,11 +588,30 @@ class MaterialXNode { // + let normalNode = null; + + if ( inputs.normal ) normalNode = inputs.normal; + + // + + let emissiveNode = null; + + if ( inputs.emission ) emissiveNode = inputs.emission; + if ( inputs.emissionColor ) { + + emissiveNode = emissiveNode ? mul( emissiveNode, inputs.emissionColor ) : emissiveNode; + + } + + // + material.colorNode = colorNode || color( 0.8, 0.8, 0.8 ); material.roughnessNode = roughnessNode || float( 0.2 ); material.metalnessNode = metalnessNode || float( 0 ); material.clearcoatNode = clearcoatNode || float( 0 ); material.clearcoatRoughnessNode = clearcoatRoughnessNode || float( 0 ); + if ( normalNode ) material.normalNode = normalNode; + if ( emissiveNode ) material.emissiveNode = emissiveNode; }