diff --git a/libraries/adsk/adsklib/colorcorrect.mtlx b/libraries/adsk/adsklib/colorcorrect.mtlx index 2e2da18a6b..a89a0bd454 100644 --- a/libraries/adsk/adsklib/colorcorrect.mtlx +++ b/libraries/adsk/adsklib/colorcorrect.mtlx @@ -1,5 +1,5 @@ - + diff --git a/python/MaterialXTest/main.py b/python/MaterialXTest/main.py index 1de7e854c2..7f39afe412 100644 --- a/python/MaterialXTest/main.py +++ b/python/MaterialXTest/main.py @@ -201,25 +201,25 @@ def test_BuildDocument(self): # Set constant node color. color = mx.Color3(0.1, 0.2, 0.3) - constant.setParameterValue('value', color) - self.assertTrue(constant.getParameterValue('value') == color) + constant.setInputValue('value', color) + self.assertTrue(constant.getInputValue('value') == color) # Set image node file. file = 'image1.tif' - image.setParameterValue('file', file, 'filename') - self.assertTrue(image.getParameterValue('file') == file) + image.setInputValue('file', file, 'filename') + self.assertTrue(image.getInputValue('file') == file) # Create a custom nodedef. nodeDef = doc.addNodeDef('nodeDef1', 'float', 'turbulence3d') - nodeDef.setParameterValue('octaves', 3) - nodeDef.setParameterValue('lacunarity', 2.0) - nodeDef.setParameterValue('gain', 0.5) + nodeDef.setInputValue('octaves', 3) + nodeDef.setInputValue('lacunarity', 2.0) + nodeDef.setInputValue('gain', 0.5) # Reference the custom nodedef. custom = nodeGraph.addNode('turbulence3d', 'turbulence1', 'float') - self.assertTrue(custom.getParameterValue('octaves') == 3) - custom.setParameterValue('octaves', 5) - self.assertTrue(custom.getParameterValue('octaves') == 5) + self.assertTrue(custom.getInputValue('octaves') == 3) + custom.setInputValue('octaves', 5) + self.assertTrue(custom.getInputValue('octaves') == 5) # Validate the document. valid, message = doc.validate() @@ -228,29 +228,31 @@ def test_BuildDocument(self): # Test scoped attributes. nodeGraph.setFilePrefix('folder/') nodeGraph.setColorSpace('lin_rec709') - self.assertTrue(image.getParameter('file').getResolvedValueString() == 'folder/image1.tif') + self.assertTrue(image.getInput('file').getResolvedValueString() == 'folder/image1.tif') self.assertTrue(constant.getActiveColorSpace() == 'lin_rec709') # Create a simple shader interface. shaderDef = doc.addNodeDef('shader1', 'surfaceshader', 'simpleSrf') diffColor = shaderDef.setInputValue('diffColor', mx.Color3(1.0)) specColor = shaderDef.setInputValue('specColor', mx.Color3(0.0)) - roughness = shaderDef.setParameterValue('roughness', 0.25) + roughness = shaderDef.setInputValue('roughness', 0.25) texId = shaderDef.setTokenValue('texId', '01') self.assertTrue(roughness.getValue() == 0.25) + self.assertTrue(roughness.getIsUniform() == False) + roughness.setIsUniform(True); + self.assertTrue(roughness.getIsUniform() == True) # Create a material that instantiates the shader. material = doc.addMaterial() shaderRef = material.addShaderRef('shaderRef1', 'simpleSrf') self.assertTrue(material.getPrimaryShaderName() == 'simpleSrf') - self.assertTrue(len(material.getPrimaryShaderParameters()) == 1) - self.assertTrue(len(material.getPrimaryShaderInputs()) == 2) + self.assertTrue(len(material.getPrimaryShaderInputs()) == 3) self.assertTrue(len(material.getPrimaryShaderTokens()) == 1) self.assertTrue(roughness.getBoundValue(material) == 0.25) - # Bind a shader parameter to a value. - bindParam = shaderRef.addBindParam('roughness') - bindParam.setValue(0.5) + # Bind a shader input to a float value. + bindInput = shaderRef.addBindInput('roughness') + bindInput.setValue(0.5) self.assertTrue(roughness.getBoundValue(material) == 0.5) self.assertTrue(roughness.getDefaultValue() == 0.25) @@ -484,11 +486,6 @@ def test_ReadXml(self): for material in doc.getMaterials(): self.assertTrue(material.getPrimaryShaderNodeDef()) edgeCount = 0 - for param in material.getPrimaryShaderParameters(): - boundValue = param.getBoundValue(material) - self.assertTrue(boundValue is not None) - for _ in param.traverseGraph(material): - edgeCount += 1 for shaderInput in material.getPrimaryShaderInputs(): boundValue = shaderInput.getBoundValue(material) upstreamElement = shaderInput.getUpstreamElement(material) diff --git a/resources/Materials/TestSuite/adsklib/adsk_shaders.mtlx b/resources/Materials/TestSuite/adsklib/adsk_shaders.mtlx index 20c30c8011..73a8e3ab60 100644 --- a/resources/Materials/TestSuite/adsklib/adsk_shaders.mtlx +++ b/resources/Materials/TestSuite/adsklib/adsk_shaders.mtlx @@ -1,5 +1,5 @@ - + diff --git a/resources/Materials/TestSuite/adsklib/shaders/brick/brick_02_shader_impl.mtlx b/resources/Materials/TestSuite/adsklib/shaders/brick/brick_02_shader_impl.mtlx index 50a35de328..0ca73e7794 100644 --- a/resources/Materials/TestSuite/adsklib/shaders/brick/brick_02_shader_impl.mtlx +++ b/resources/Materials/TestSuite/adsklib/shaders/brick/brick_02_shader_impl.mtlx @@ -1,5 +1,5 @@ - + diff --git a/resources/Materials/TestSuite/adsklib/shaders/brick/brick_10_shader_impl.mtlx b/resources/Materials/TestSuite/adsklib/shaders/brick/brick_10_shader_impl.mtlx index 42f348840e..85a11e763c 100644 --- a/resources/Materials/TestSuite/adsklib/shaders/brick/brick_10_shader_impl.mtlx +++ b/resources/Materials/TestSuite/adsklib/shaders/brick/brick_10_shader_impl.mtlx @@ -1,5 +1,5 @@ - + diff --git a/resources/Materials/TestSuite/adsklib/shaders/wood/parquet_03_shader_impl.mtlx b/resources/Materials/TestSuite/adsklib/shaders/wood/parquet_03_shader_impl.mtlx index f2a3aea8e9..559d8fd5ce 100644 --- a/resources/Materials/TestSuite/adsklib/shaders/wood/parquet_03_shader_impl.mtlx +++ b/resources/Materials/TestSuite/adsklib/shaders/wood/parquet_03_shader_impl.mtlx @@ -1,5 +1,5 @@ - + diff --git a/resources/Materials/TestSuite/stdlib/definition/definition_from_nodegraph.mtlx b/resources/Materials/TestSuite/stdlib/definition/definition_from_nodegraph.mtlx index 1ccc767ea5..383cfeb774 100644 --- a/resources/Materials/TestSuite/stdlib/definition/definition_from_nodegraph.mtlx +++ b/resources/Materials/TestSuite/stdlib/definition/definition_from_nodegraph.mtlx @@ -1,5 +1,5 @@ - + diff --git a/resources/Materials/TestSuite/stdlib/upgrade/1_38_parameter_to_input.mtlx b/resources/Materials/TestSuite/stdlib/upgrade/1_38_parameter_to_input.mtlx new file mode 100644 index 0000000000..18c1925d8b --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/upgrade/1_38_parameter_to_input.mtlx @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/JsMaterialX/JsMaterialXCore/JsElement.cpp b/source/JsMaterialX/JsMaterialXCore/JsElement.cpp index 960ac084cf..bd56ca7e21 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsElement.cpp +++ b/source/JsMaterialX/JsMaterialXCore/JsElement.cpp @@ -188,6 +188,8 @@ extern "C" .function("setUnitType", &mx::ValueElement::setUnitType) .function("hasUnitType", &mx::ValueElement::hasUnitType) .function("getUnitType", &mx::ValueElement::getUnitType) + .function("setIsUniform", &mx::ValueElement::setIsUniform) + .function("getIsUniform", &mx::ValueElement::getIsUniform) .class_property("VALUE_ATTRIBUTE", &mx::ValueElement::VALUE_ATTRIBUTE) .class_property("INTERFACE_NAME_ATTRIBUTE", &mx::ValueElement::INTERFACE_NAME_ATTRIBUTE) .class_property("IMPLEMENTATION_NAME_ATTRIBUTE", &mx::ValueElement::IMPLEMENTATION_NAME_ATTRIBUTE) diff --git a/source/JsMaterialX/JsMaterialXCore/JsInterface.cpp b/source/JsMaterialX/JsMaterialXCore/JsInterface.cpp index acaa0d7068..c2b3444336 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsInterface.cpp +++ b/source/JsMaterialX/JsMaterialXCore/JsInterface.cpp @@ -9,7 +9,6 @@ namespace ems = emscripten; namespace mx = MaterialX; #define BIND_INTERFACE_TYPE_INSTANCE(NAME, T) \ -.function("setParameterValue" #NAME, &mx::InterfaceElement::setParameterValue) \ .function("setInputValue" #NAME, &mx::InterfaceElement::setInputValue) extern "C" @@ -17,11 +16,6 @@ extern "C" EMSCRIPTEN_BINDINGS(interface) { - ems::class_>("Parameter") - .smart_ptr_constructor("Parameter", &std::make_shared) - .smart_ptr>("Parameter") - .class_property("CATEGORY", &mx::Parameter::CATEGORY); - ems::class_>("PortElement") .smart_ptr>("PortElement") .smart_ptr>("PortElement") @@ -54,14 +48,7 @@ extern "C" .function("setNodeDefString", &mx::InterfaceElement::setNodeDefString) .function("hasNodeDefString", &mx::InterfaceElement::hasNodeDefString) .function("getNodeDefString", &mx::InterfaceElement::getNodeDefString) - .function("addParameter", &mx::InterfaceElement::addParameter) - .function("getParameter", &mx::InterfaceElement::getParameter) - .function("getParameters", &mx::InterfaceElement::getParameters) - .function("getParameterCount", &mx::InterfaceElement::getParameterCount) - .function("removeParameter", &mx::InterfaceElement::removeParameter) - .function("getActiveParameter", &mx::InterfaceElement::getActiveParameter) - .function("getActiveParameters", &mx::InterfaceElement::getActiveParameters) .function("addInput", &mx::InterfaceElement::addInput) .function("getInput", &mx::InterfaceElement::getInput) .function("getInputs", &mx::InterfaceElement::getInputs) @@ -86,7 +73,6 @@ extern "C" .function("getActiveValueElement", &mx::InterfaceElement::getActiveValueElement) .function("getActiveValueElements", &mx::InterfaceElement::getActiveValueElements) - .function("getParameterValue", &mx::InterfaceElement::getParameterValue) .function("getInputValue", &mx::InterfaceElement::getInputValue) .function("setTokenValue", &mx::InterfaceElement::setTokenValue) diff --git a/source/JsMaterialX/JsMaterialXCore/JsInterface.js b/source/JsMaterialX/JsMaterialXCore/JsInterface.js index 6fe6348729..e8966e2d17 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsInterface.js +++ b/source/JsMaterialX/JsMaterialXCore/JsInterface.js @@ -1,7 +1,5 @@ // jsInterface addWrapper(function(Module, api) { - /** Setup the Parameter class */ - api.Parameter = wrapperFactory(Module.Parameter); /** Setup the PortElement class */ api.PortElement = wrapperFactory(Module.PortElement); @@ -13,22 +11,6 @@ addWrapper(function(Module, api) { api.Output = wrapperFactory(Module.Output); var funcs = [ - 'setParameterValueinteger', - 'setParameterValueboolean', - 'setParameterValuefloat', - 'setParameterValuecolor2', - 'setParameterValuecolor3', - 'setParameterValuecolor4', - 'setParameterValuevector2', - 'setParameterValuevector3', - 'setParameterValuevector4', - 'setParameterValuematrix33', - 'setParameterValuematrix44', - 'setParameterValuestring', - 'setParameterValueintegerarray', - 'setParameterValuebooleanarray', - 'setParameterValuefloatarray', - 'setParameterValuestringarray', 'setInputValueinteger', 'setInputValueboolean', 'setInputValuefloat', @@ -48,11 +30,9 @@ addWrapper(function(Module, api) { ]; var defaultArgs = { - addParameter: [api.DEFAULT_TYPE_STRING, api.DEFAULT_TYPE_STRING], addInput: [api.DEFAULT_TYPE_STRING, api.DEFAULT_TYPE_STRING], addOutput: ['', api.DEFAULT_TYPE_STRING], addToken: [''], - getParameterValue: [REQUIRED, ''], getInputValue: [REQUIRED, ''], getDeclaration: [''] }; diff --git a/source/JsMaterialX/JsMaterialXCore/JsMaterial.cpp b/source/JsMaterialX/JsMaterialXCore/JsMaterial.cpp index 22af4e8426..9f34f24b59 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsMaterial.cpp +++ b/source/JsMaterialX/JsMaterialXCore/JsMaterial.cpp @@ -23,7 +23,6 @@ extern "C" .function("getShaderNodeDefs", &mx::Material::getShaderNodeDefs) .function("getPrimaryShaderNodeDef", &mx::Material::getPrimaryShaderNodeDef) .function("getPrimaryShaderName", &mx::Material::getPrimaryShaderName) - .function("getPrimaryShaderParameters", &mx::Material::getPrimaryShaderParameters) .function("getPrimaryShaderInputs", &mx::Material::getPrimaryShaderInputs) .function("getPrimaryShaderTokens", &mx::Material::getPrimaryShaderTokens) .function("getGeometryBindings", &mx::Material::getGeometryBindings) diff --git a/source/JsMaterialX/JsMaterialXCore/JsMaterial.js b/source/JsMaterialX/JsMaterialXCore/JsMaterial.js index 9e3e482c5d..a11d471102 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsMaterial.js +++ b/source/JsMaterialX/JsMaterialXCore/JsMaterial.js @@ -6,7 +6,6 @@ addWrapper(function(Module, api) { getShaderNodeDefs: ['', ''], getPrimaryShaderNodeDef: ['', ''], getPrimaryShaderName: ['', ''], - getPrimaryShaderParameters: ['', ''], getPrimaryShaderInputs: ['', ''], getPrimaryShaderTokens: ['', ''], getGeometryBindings: [api.UNIVERSAL_GEOM_NAME] diff --git a/source/JsMaterialX/test/codeExamples.spec.js b/source/JsMaterialX/test/codeExamples.spec.js index 12e7421bec..50f747da71 100644 --- a/source/JsMaterialX/test/codeExamples.spec.js +++ b/source/JsMaterialX/test/codeExamples.spec.js @@ -15,10 +15,10 @@ describe('Code Examples', () => { expect(nodes.length).to.equal(1); expect(nodes[0]).to.eql(image); - image.setParameterValuestring('file', 'image1.tif', 'filename'); - const param = image.getParameter('file'); - expect(param).to.not.be.null; - expect(param.getValue().getData()).to.equal('image1.tif'); + image.setInputValuestring('file', 'image1.tif', 'filename'); + const input = image.getInput('file'); + expect(input).to.not.be.null; + expect(input.getValue().getData()).to.equal('image1.tif'); const output = nodeGraph.addOutput(); const outputs = nodeGraph.getOutputs(); @@ -46,10 +46,10 @@ describe('Code Examples', () => { expect(inputValue).to.not.be.null; expect(inputValue.getData()).to.eql(new mx.Color3(0.0, 0.0, 0.0)); - const roughness = simpleSrf.setParameterValuefloat('roughness', 0.25); - const paramValue = simpleSrf.getParameterValue('roughness'); - expect(paramValue).to.not.be.null; - expect(paramValue.getData()).to.equal(0.25); + const roughness = simpleSrf.setInputValuefloat('roughness', 0.25); + inputValue = simpleSrf.getInputValue('roughness'); + expect(inputValue).to.not.be.null; + expect(inputValue.getData()).to.equal(0.25); // Create a material that instantiates the shader. const material = doc.addMaterial(); @@ -63,13 +63,13 @@ describe('Code Examples', () => { expect(shaderRefs[0].getName()).to.equal('SR_simpleSrf'); // Bind roughness to a new value within this material. - const bindParam = refSimpleSrf.addBindParam('roughness'); - const bindParams = refSimpleSrf.getBindParams(); - expect(bindParams.length).to.equal(1); - expect(bindParams[0]).to.eql(bindParam); - bindParam.setValuefloat(0.5); - expect(bindParam.getValue()).to.not.be.null; - expect(bindParam.getValue().getData()).to.equal(0.5); + const bindInput = refSimpleSrf.addBindInput('roughness'); + const bindInputs = refSimpleSrf.getBindInputs(); + expect(bindInputs.length).to.equal(1); + expect(bindInputs[0]).to.eql(bindInput); + bindInput.setValuefloat(0.5); + expect(bindInput.getValue()).to.not.be.null; + expect(bindInput.getValue().getData()).to.equal(0.5); // Validate the value of roughness in the context of this material. expect(roughness.getBoundValue(material).getValueString()).to.equal('0.5'); @@ -98,10 +98,10 @@ describe('Code Examples', () => { // Display the filename of each image node. if (elem instanceof mx.Node) { nodeCount++; - const param = elem.getParameter('file'); - if (param) { + const input = elem.getInput('file'); + if (input) { fileCount++; - const filename = param.getValueString(); + const filename = input.getValueString(); expect(elem.getName()).to.equal('image1'); expect(filename).to.equal('greysphere_calibration.png'); } @@ -122,21 +122,11 @@ describe('Code Examples', () => { mx.readFromXmlString(doc, xmlStr); let materialCount = 0; - let shaderParamCount = 0; let shaderInputCount = 0; // Iterate through 1.37 materials for which there should be none const materials = doc.getMaterials(); materials.forEach((material) => { materialCount++; - // For each shader parameter, compute its value in the context of this material. - const primaryShaderParams = material.getPrimaryShaderParameters(); - primaryShaderParams.forEach((param) => { - const value = param.getBoundValue(material); - expect(value instanceof mx.TypedValue_float).to.be.true; - expect(value.getTypeString()).to.equal('float'); - expect(param.getName()).to.equal('fresnel_exp'); - shaderParamCount++; - }); // For each shader input, find all upstream images in the dataflow graph. const primaryShaderInputs = material.getPrimaryShaderInputs(); @@ -151,7 +141,6 @@ describe('Code Examples', () => { }); expect(materialCount).to.equal(0); - expect(shaderParamCount).to.equal(0); expect(shaderInputCount).to.equal(0); }); }); diff --git a/source/JsMaterialX/test/document.spec.js b/source/JsMaterialX/test/document.spec.js index e229399823..3bf8ebb14d 100644 --- a/source/JsMaterialX/test/document.spec.js +++ b/source/JsMaterialX/test/document.spec.js @@ -42,25 +42,25 @@ describe('Build Document', () => { it('Set constant node color', () => { const color = new mx.Color3(0.1, 0.2, 0.3); - constant.setParameterValuecolor3('value', color); - expect(constant.getParameterValue('value').getData()).to.eql(color); + constant.setInputValuecolor3('value', color); + expect(constant.getInputValue('value').getData()).to.eql(color); }); it('Set image node file', () => { const file = 'image1.tif'; - image.setParameterValuestring('file', file, 'filename'); - expect(image.getParameterValue('file').getData()).to.eql(file); + image.setInputValuestring('file', file, 'filename'); + expect(image.getInputValue('file').getData()).to.eql(file); }); it('Create a custom nodedef', () => { const nodeDef = doc.addNodeDef('nodeDef1', 'float', 'turbulence3d'); - nodeDef.setParameterValueinteger('octaves', 3); - nodeDef.setParameterValuefloat('lacunarity', 2.0); - nodeDef.setParameterValuefloat('gain', 0.5); + nodeDef.setInputValueinteger('octaves', 3); + nodeDef.setInputValuefloat('lacunarity', 2.0); + nodeDef.setInputValuefloat('gain', 0.5); const custom = nodeGraph.addNode('turbulence3d', 'turbulence1', 'float'); - expect(custom.getParameterValue('octaves').getData()).to.equal(3); - custom.setParameterValueinteger('octaves', 5); - expect(custom.getParameterValue('octaves').getData()).to.equal(5); + expect(custom.getInputValue('octaves').getData()).to.equal(3); + custom.setInputValueinteger('octaves', 5); + expect(custom.getInputValue('octaves').getData()).to.equal(5); }); it('Validate the document', () => { @@ -70,7 +70,7 @@ describe('Build Document', () => { it('Test scoped attributes', () => { nodeGraph.setFilePrefix('folder/'); nodeGraph.setColorSpace('lin_rec709'); - expect(image.getParameter('file').getResolvedValueString()).to.equal('folder/image1.tif'); + expect(image.getInput('file').getResolvedValueString()).to.equal('folder/image1.tif'); expect(constant.getActiveColorSpace()).to.equal('lin_rec709'); }); @@ -79,8 +79,11 @@ describe('Build Document', () => { const shaderDef = doc.addNodeDef('shader1', 'surfaceshader', 'simpleSrf'); diffColor = shaderDef.setInputValuecolor3('diffColor', new mx.Color3(1.0, 1.0, 1.0)); specColor = shaderDef.setInputValuecolor3('specColor', new mx.Color3(0.0, 0.0, 0.0)); - roughness = shaderDef.setParameterValuefloat('roughness', 0.25); + roughness = shaderDef.setInputValuefloat('roughness', 0.25); texId = shaderDef.setTokenValue('texId', '01'); + expect(roughness.getIsUniform()).to.equal(false); + roughness.setIsUniform(true); + expect(roughness.getIsUniform()).to.equal(true); expect(roughness.getValue().getData()).to.equal(0.25); }); @@ -89,21 +92,20 @@ describe('Build Document', () => { material = doc.addMaterial(); shaderRef = material.addShaderRef('shaderRef1', 'simpleSrf'); expect(material.getPrimaryShaderName()).to.equal('simpleSrf'); - expect(material.getPrimaryShaderParameters().length).to.equal(1); - expect(material.getPrimaryShaderInputs().length).to.equal(2); + expect(material.getPrimaryShaderInputs().length).to.equal(3); expect(material.getPrimaryShaderTokens().length).to.equal(1); expect(roughness.getBoundValue(material).getData()).to.equal(0.25); }); - it('Bind a shader parameter to a value', () => { - const bindParam = shaderRef.addBindParam('roughness'); - bindParam.setValuefloat(0.5); + it('Bind a shader input to a float value', () => { + const bindInput = shaderRef.addBindInput('roughness'); + bindInput.setValuefloat(0.5); expect(roughness.getBoundValue(material).getData()).to.equal(0.5); expect(roughness.getDefaultValue().getData()).to.equal(0.25); }); let bindInput; - it('Bind a shader input to a value', () => { + it('Bind a shader input to a color value', () => { bindInput = shaderRef.addBindInput('specColor'); bindInput.setValuecolor3(new mx.Color3(0.5, 0.5, 0.5)); expect(specColor.getBoundValue(material).getData()).to.eql(new mx.Color3(0.5, 0.5, 0.5)); diff --git a/source/JsMaterialX/test/readXml.spec.js b/source/JsMaterialX/test/readXml.spec.js index cef4d82c41..fbb97a0627 100644 --- a/source/JsMaterialX/test/readXml.spec.js +++ b/source/JsMaterialX/test/readXml.spec.js @@ -60,14 +60,6 @@ describe('Build Document', () => { materials.forEach((material) => { expect(material.getPrimaryShaderNodeDef()).to.exist; let edgeCount = 0; - const primaryShaderParams = material.getPrimaryShaderParameters(); - primaryShaderParams.forEach((param) => { - const boundValue = param.getBoundValue(material); - expect(boundValue).to.be.not.null; - traverse(param.traverseGraph(material), () => { - edgeCount++; - }); - }); const primaryShaderInputs = material.getPrimaryShaderInputs(); primaryShaderInputs.forEach((shaderInput) => { diff --git a/source/MaterialXCore/Document.cpp b/source/MaterialXCore/Document.cpp index 0393ab82bf..305e445994 100644 --- a/source/MaterialXCore/Document.cpp +++ b/source/MaterialXCore/Document.cpp @@ -109,7 +109,7 @@ bool convertMaterialsToNodes(DocumentPtr doc) } else if (valueElement->isA()) { - portChild = shaderNode->addParameter(valueElement->getName(), valueElement->getType()); + portChild = shaderNode->addInput(valueElement->getName(), valueElement->getType()); } if (portChild) { @@ -883,7 +883,7 @@ void Document::upgradeVersion(bool applyFutureUpdates) ParameterPtr cutoff = node->getParameter("cutoff"); if (cutoff) { - InputPtr value2 = node->addInput("value2"); + InputPtr value2 = node->addInput("value2", DEFAULT_TYPE_STRING); value2->copyContentFrom(cutoff); node->removeChild(cutoff->getName()); } @@ -983,7 +983,7 @@ void Document::upgradeVersion(bool applyFutureUpdates) } // Upgrade from 1.37 to 1.38 - if (majorVersion == 1 && minorVersion == 37) + if (majorVersion == 1 && (minorVersion == 37 || applyFutureUpdates)) { convertMaterialsToNodes(asA()); @@ -993,15 +993,22 @@ void Document::upgradeVersion(bool applyFutureUpdates) const string IN2 = "in2"; const string ROTATE3D = "rotate3d"; const string AXIS = "axis"; + const string INPUT_ONE = "1.0"; // Update nodedefs + bool upgradeAtan2Instances = false; for (auto nodedef : getMatchingNodeDefs(ATAN2)) { InputPtr input = nodedef->getInput(IN1); InputPtr input2 = nodedef->getInput(IN2); string inputValue = input->getValueString(); - input->setValueString(input2->getValueString()); - input2->setValueString(inputValue); + // Only flip value if nodedef value is the previous versions. + if (inputValue == INPUT_ONE) + { + input->setValueString(input2->getValueString()); + input2->setValueString(inputValue); + upgradeAtan2Instances = true; + } } for (auto nodedef : getMatchingNodeDefs(ROTATE3D)) { @@ -1022,7 +1029,7 @@ void Document::upgradeVersion(bool applyFutureUpdates) continue; } const string& nodeCategory = node->getCategory(); - if (nodeCategory == ATAN2) + if (upgradeAtan2Instances && nodeCategory == ATAN2) { InputPtr input = node->getInput(IN1); InputPtr input2 = node->getInput(IN2); @@ -1094,8 +1101,40 @@ void Document::upgradeVersion(bool applyFutureUpdates) node->setName(newNodeName); } } + } + + // Convert all parameters to be inputs. If needed set them to be "uniform". + const StringSet uniformTypes = { FILENAME_TYPE_STRING, STRING_TYPE_STRING }; + const string PARAMETER_CATEGORY_STRING("parameter"); + for (ElementPtr e : traverseTree()) + { + InterfaceElementPtr elem = e->asA(); + if (!elem) + { + continue; + } + vector children = elem->getChildren(); + for (ElementPtr child : children) + { + if (child->getCategory() == PARAMETER_CATEGORY_STRING) + { + InputPtr newInput = updateChildSubclass(elem, child); + if (uniformTypes.count(child->getAttribute(TYPE_ATTRIBUTE))) + { + newInput->setIsUniform(true); + } + else + { + // TODO: Determine based on usage whether to make + // the input a uniform. + newInput->setIsUniform(false); + } + } + } } - minorVersion = 38; + + // While we are in the process of supporting 1.38. Leave files as 1.37 + minorVersion = 37; } if (majorVersion == MATERIALX_MAJOR_VERSION && diff --git a/source/MaterialXCore/Element.cpp b/source/MaterialXCore/Element.cpp index 24ab0cd1d4..db6064c60b 100644 --- a/source/MaterialXCore/Element.cpp +++ b/source/MaterialXCore/Element.cpp @@ -42,6 +42,7 @@ const string ValueElement::UI_STEP_ATTRIBUTE = "uistep"; const string ValueElement::UI_ADVANCED_ATTRIBUTE = "uiadvanced"; const string ValueElement::UNIT_ATTRIBUTE = "unit"; const string ValueElement::UNITTYPE_ATTRIBUTE = "unittype"; +const string ValueElement::UNIFORM_ATTRIBUTE = "uniform"; Element::CreatorMap Element::_creatorMap; diff --git a/source/MaterialXCore/Element.h b/source/MaterialXCore/Element.h index 52d00b97c5..b37467acfd 100644 --- a/source/MaterialXCore/Element.h +++ b/source/MaterialXCore/Element.h @@ -1150,6 +1150,22 @@ class ValueElement : public TypedElement return getAttribute(UNITTYPE_ATTRIBUTE); } + /// @} + /// @name Uniform attribute + /// @{ + + /// Set the uniform attribute flag on this element. + void setIsUniform(bool value) + { + setTypedAttribute(UNIFORM_ATTRIBUTE, value); + } + + /// The the uniform attribute flag for this element. + bool getIsUniform() const + { + return getTypedAttribute(UNIFORM_ATTRIBUTE); + } + /// @} /// @name Validation /// @{ @@ -1177,6 +1193,7 @@ class ValueElement : public TypedElement static const string UI_ADVANCED_ATTRIBUTE; static const string UNIT_ATTRIBUTE; static const string UNITTYPE_ATTRIBUTE; + static const string UNIFORM_ATTRIBUTE; }; /// @class Token diff --git a/source/MaterialXCore/Interface.h b/source/MaterialXCore/Interface.h index 887ee975e1..c9ae9ef259 100644 --- a/source/MaterialXCore/Interface.h +++ b/source/MaterialXCore/Interface.h @@ -469,15 +469,24 @@ class InterfaceElement : public TypedElement /// Add an Input to this interface. /// @param name The name of the new Input. - /// If no name is specified, then a unique name will automatically be + /// If an empty string is specified, then a unique name will automatically be /// generated. - /// @param type An optional type string. + /// @param type The input type string. + /// @param isUniform Option to mark the input as a uniform. By default the input + /// is not marked as being a uniform. "string" and "filename" types are always + /// marked as being a uniform. /// @return A shared pointer to the new Input. - InputPtr addInput(const string& name = DEFAULT_TYPE_STRING, - const string& type = DEFAULT_TYPE_STRING) + InputPtr addInput(const string& name, + const string& type, + bool isUniform = false) { InputPtr child = addChild(name); child->setType(type); + const StringSet uniformTypes = { FILENAME_TYPE_STRING, STRING_TYPE_STRING }; + if (isUniform || uniformTypes.count(type)) + { + child->setIsUniform(true); + } return child; } @@ -732,7 +741,7 @@ template InputPtr InterfaceElement::setInputValue(const string& name, { InputPtr input = getChildOfType(name); if (!input) - input = addInput(name); + input = addInput(name, type); input->setValue(value, type); return input; } diff --git a/source/MaterialXCore/Material.cpp b/source/MaterialXCore/Material.cpp index 1925291926..5da0beb05a 100644 --- a/source/MaterialXCore/Material.cpp +++ b/source/MaterialXCore/Material.cpp @@ -86,22 +86,6 @@ vector Material::getGeometryBindings(const string& geom) cons return matAssigns; } -vector Material::getPrimaryShaderParameters(const string& target, const string& type) const -{ - NodeDefPtr nodeDef = getPrimaryShaderNodeDef(target, type); - vector res; - if (nodeDef) - { - InterfaceElementPtr implement = nodeDef->getImplementation(); - for (ParameterPtr nodeDefParam : nodeDef->getActiveParameters()) - { - ParameterPtr implementParam = implement ? implement->getParameter(nodeDefParam->getName()) : nullptr; - res.push_back(implementParam ? implementParam : nodeDefParam); - } - } - return res; -} - vector Material::getPrimaryShaderInputs(const string& target, const string& type) const { NodeDefPtr nodeDef = getPrimaryShaderNodeDef(target, type); diff --git a/source/MaterialXCore/Material.h b/source/MaterialXCore/Material.h index 0e7e5f2a25..e389e572fd 100644 --- a/source/MaterialXCore/Material.h +++ b/source/MaterialXCore/Material.h @@ -155,17 +155,6 @@ class Material : public Element return nodeDef ? nodeDef->getNodeString() : EMPTY_STRING; } - /// Return the parameters of the first shader referenced by this material, - /// optionally filtered by the given target and shader type. - /// @param target An optional target name, which will be used to filter - /// the shader nodedefs that are considered. - /// @param type An optional shader type (e.g. "surfaceshader"), which will - /// be used to filter the shader nodedefs that are considered. - /// @return The parameters of the first matching shader referenced by this - /// material, or an empty vector if no matching shader was found. - vector getPrimaryShaderParameters(const string& target = EMPTY_STRING, - const string& type = EMPTY_STRING) const; - /// Return the inputs of the first shader referenced by this material, /// optionally filtered by the given target and shader type. /// @param target An optional target name, which will be used to filter diff --git a/source/MaterialXCore/Node.cpp b/source/MaterialXCore/Node.cpp index 133211a2e6..2653e899ad 100644 --- a/source/MaterialXCore/Node.cpp +++ b/source/MaterialXCore/Node.cpp @@ -26,7 +26,7 @@ void Node::setConnectedNode(const string& inputName, NodePtr node) InputPtr input = getInput(inputName); if (!input) { - input = addInput(inputName); + input = addInput(inputName, DEFAULT_TYPE_STRING); } if (node) { @@ -50,7 +50,7 @@ void Node::setConnectedNodeName(const string& inputName, const string& nodeName) InputPtr input = getInput(inputName); if (!input) { - input = addInput(inputName); + input = addInput(inputName, DEFAULT_TYPE_STRING); } input->setNodeName(nodeName); } @@ -495,11 +495,7 @@ ValueElementPtr Node::addInputFromNodeDef(const string& name) if (nodeDefElem->isA()) { - newChild = addInput(inputName); - } - else if (nodeDefElem->isA()) - { - newChild = addParameter(inputName); + newChild = addInput(inputName, nodeDefElem->getType()); } if (newChild) { @@ -525,8 +521,7 @@ void NodeGraph::addInterface(const string& childPath, const string& interfaceNam ElementPtr elem = getDescendant(childPath); ValueElementPtr valueElem = elem->asA(); InputPtr input = valueElem ? valueElem->asA() : nullptr; - ParameterPtr param = valueElem ? valueElem->asA() : nullptr; - if ((!input && !param) || (input && input->getConnectedNode())) + if (!input || (input && input->getConnectedNode())) { throw Exception("Invalid nodegraph child to create interface for: " + childPath); } @@ -542,14 +537,6 @@ void NodeGraph::addInterface(const string& childPath, const string& interfaceNam nodeDefInput->setValueString(value->getValueString()); } } - else - { - ParameterPtr nodeDefParam = nodeDef->addParameter(interfaceName, param->getType()); - if (value) - { - nodeDefParam->setValueString(value->getValueString()); - } - } } void NodeGraph::removeInterface(const string& childPath) diff --git a/source/MaterialXCore/Types.cpp b/source/MaterialXCore/Types.cpp index 9c904c77a3..dc77269a12 100644 --- a/source/MaterialXCore/Types.cpp +++ b/source/MaterialXCore/Types.cpp @@ -11,6 +11,7 @@ namespace MaterialX const string DEFAULT_TYPE_STRING = "color3"; const string FILENAME_TYPE_STRING = "filename"; const string GEOMNAME_TYPE_STRING = "geomname"; +const string STRING_TYPE_STRING = "string"; const string SURFACE_SHADER_TYPE_STRING = "surfaceshader"; const string DISPLACEMENT_SHADER_TYPE_STRING = "displacementshader"; const string VOLUME_SHADER_TYPE_STRING = "volumeshader"; diff --git a/source/MaterialXCore/Types.h b/source/MaterialXCore/Types.h index 278a87019c..5d49f01cc5 100644 --- a/source/MaterialXCore/Types.h +++ b/source/MaterialXCore/Types.h @@ -22,6 +22,7 @@ namespace MaterialX extern const string DEFAULT_TYPE_STRING; extern const string FILENAME_TYPE_STRING; extern const string GEOMNAME_TYPE_STRING; +extern const string STRING_TYPE_STRING; extern const string SURFACE_SHADER_TYPE_STRING; extern const string DISPLACEMENT_SHADER_TYPE_STRING; extern const string VOLUME_SHADER_TYPE_STRING; diff --git a/source/MaterialXGenShader/Nodes/HwImageNode.cpp b/source/MaterialXGenShader/Nodes/HwImageNode.cpp index 93e949fa8b..ed6444d4df 100644 --- a/source/MaterialXGenShader/Nodes/HwImageNode.cpp +++ b/source/MaterialXGenShader/Nodes/HwImageNode.cpp @@ -36,7 +36,7 @@ void HwImageNode::setValues(const Node& node, ShaderNode& shaderNode, GenContext // have been mapped to a single texture atlas which must be accessed in 0..1 space. if (context.getOptions().hwNormalizeUdimTexCoords) { - ParameterPtr file = node.getParameter("file"); + InputPtr file = node.getInput("file"); if (file) { // set the uv scale and offset properly. diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 90198b7198..2ceff6bf4a 100644 --- a/source/MaterialXGenShader/ShaderGraph.cpp +++ b/source/MaterialXGenShader/ShaderGraph.cpp @@ -57,7 +57,7 @@ void ShaderGraph::addInputSockets(const InterfaceElement& elem, GenContext& cont inputSocket->setValue(port->getValue()); } } - if (port->isA()) + if (port->getIsUniform()) { inputSocket->setUniform(); } @@ -500,46 +500,7 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader( const string& targetDistanceUnit = context.getOptions().targetDistanceUnit; UnitSystemPtr unitSystem = context.getShaderGenerator().getUnitSystem(); - // Set node parameter values onto graph input sockets - for (ParameterPtr elem : nodeDef->getActiveParameters()) - { - ShaderGraphInputSocket* inputSocket = graph->getInputSocket(elem->getName()); - ShaderInput* input = newNode->getInput(elem->getName()); - if (!inputSocket || !input) - { - throw ExceptionShaderGenError("Shader parameter '" + elem->getName() + "' doesn't match an existing input on graph '" + graph->getName() + "'"); - } - - ParameterPtr nodeParam = node->getParameter(elem->getName()); - if (nodeParam) - { - // Copy value from binding - ValuePtr nodeParamValue = nodeParam->getResolvedValue(); - if (nodeParamValue) - { - inputSocket->setValue(nodeParamValue); - - graph->populateColorTransformMap(colorManagementSystem, input, nodeParam, targetColorSpace, true); - graph->populateUnitTransformMap(unitSystem, input, nodeParam, targetDistanceUnit, true); - } - inputSocket->setPath(nodeParam->getNamePath()); - input->setPath(inputSocket->getPath()); - const string& nodeParamUnit = nodeParam->getUnit(); - if (!nodeParamUnit.empty()) - { - inputSocket->setUnit(nodeParamUnit); - input->setUnit(nodeParamUnit); - } - } - - // Connect graph input socket to the node input - inputSocket->makeConnection(input); - - // Share metadata. - inputSocket->setMetadata(input->getMetadata()); - } - - // Set node input values onto grah input sockets + // Set node input values onto graph input sockets for (const InputPtr& nodeDefInput : nodeDef->getActiveInputs()) { ShaderGraphInputSocket* inputSocket = graph->getInputSocket(nodeDefInput->getName()); @@ -570,25 +531,34 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader( } } - GeomPropDefPtr geomprop = nodeDefInput->getDefaultGeomProp(); - if (geomprop) + // Check if the input is a uniform + bool isUniform = nodeDefInput->getIsUniform(); + if (isUniform) { - inputSocket->setGeomProp(geomprop->getName()); - input->setGeomProp(geomprop->getName()); + inputSocket->makeConnection(input); } - - // If no explicit connection, connect to geometric node if a geomprop is used - // or otherwise to the graph interface. - const string& connection = nodeInput ? nodeInput->getOutputString() : EMPTY_STRING; - if (connection.empty()) + else { + GeomPropDefPtr geomprop = nodeDefInput->getDefaultGeomProp(); if (geomprop) { - graph->addDefaultGeomNode(input, *geomprop, context); + inputSocket->setGeomProp(geomprop->getName()); + input->setGeomProp(geomprop->getName()); } - else + + // If no explicit connection, connect to geometric node if a geomprop is used + // or otherwise to the graph interface. + const string& connection = nodeInput ? nodeInput->getOutputString() : EMPTY_STRING; + if (connection.empty()) { - inputSocket->makeConnection(input); + if (geomprop) + { + graph->addDefaultGeomNode(input, *geomprop, context); + } + else + { + inputSocket->makeConnection(input); + } } } @@ -1058,6 +1028,8 @@ ShaderNode* ShaderGraph::createNode(const Node& node, GenContext& context) } } + // + // Handle colorspace and unit conversion if needed. string targetColorSpace; ColorManagementSystemPtr colorManagementSystem = context.getShaderGenerator().getColorManagementSystem(); if (colorManagementSystem) @@ -1066,56 +1038,29 @@ ShaderNode* ShaderGraph::createNode(const Node& node, GenContext& context) _document->getActiveColorSpace() : context.getOptions().targetColorSpaceOverride; } - if (colorManagementSystem && !targetColorSpace.empty()) - { - for (InputPtr input : node.getInputs()) - { - ShaderInput* shaderInput = newNode->getInput(input->getName()); - populateColorTransformMap(colorManagementSystem, shaderInput, input, targetColorSpace, true); - } - for (auto parameter : node.getParameters()) - { - if (parameter->getType() == FILENAME_TYPE_STRING) - { - ShaderOutput* shaderOutput = newNode->getOutput(); - if (shaderOutput) - { - populateColorTransformMap(colorManagementSystem, shaderOutput, parameter, targetColorSpace, false); - } - } - else - { - ShaderInput* shaderInput = newNode->getInput(parameter->getName()); - populateColorTransformMap(colorManagementSystem, shaderInput, parameter, targetColorSpace, true); - } - } - } - - // Unit Conversion: Only applicable if Unit system and a "targetDistanceUnit" is defined for now. UnitSystemPtr unitSystem = context.getShaderGenerator().getUnitSystem(); const string& targetDistanceUnit = context.getOptions().targetDistanceUnit; - if (unitSystem && !targetDistanceUnit.empty()) + + for (InputPtr input : node.getInputs()) { - for (InputPtr input : node.getInputs()) - { - ShaderInput* inputPort = newNode->getInput(input->getName()); - populateUnitTransformMap(unitSystem, inputPort, input, targetDistanceUnit, true); - } - for (auto parameter : node.getParameters()) + // It is sufficient that the input type is a filename regardless of whether it is marked as a uniform + if (input->getType() == FILENAME_TYPE_STRING) { - ShaderInput* inputPort = newNode->getInput(parameter->getName()); - if (parameter->getType() == FILENAME_TYPE_STRING) + ShaderOutput* shaderOutput = newNode->getOutput(); + if (shaderOutput) { - // Check output port for any parameters which are file names - ShaderOutput* shaderOutput = newNode->getOutput(); - if (shaderOutput) - { - populateUnitTransformMap(unitSystem, shaderOutput, parameter, targetDistanceUnit, false); - } + populateColorTransformMap(colorManagementSystem, shaderOutput, input, targetColorSpace, false); + populateUnitTransformMap(unitSystem, shaderOutput, input, targetDistanceUnit, false); } - populateUnitTransformMap(unitSystem, inputPort, parameter, targetDistanceUnit, true); + } + else + { + ShaderInput* shaderInput = newNode->getInput(input->getName()); + populateColorTransformMap(colorManagementSystem, shaderInput, input, targetColorSpace, true); + populateUnitTransformMap(unitSystem, shaderInput, input, targetDistanceUnit, true); } } + return newNode.get(); } @@ -1615,7 +1560,7 @@ void ShaderGraph::setVariableNames(GenContext& context) void ShaderGraph::populateColorTransformMap(ColorManagementSystemPtr colorManagementSystem, ShaderPort* shaderPort, ValueElementPtr input, const string& targetColorSpace, bool asInput) { - if (!colorManagementSystem) + if (!colorManagementSystem || targetColorSpace.empty()) { return; } @@ -1647,6 +1592,11 @@ void ShaderGraph::populateColorTransformMap(ColorManagementSystemPtr colorManage void ShaderGraph::populateUnitTransformMap(UnitSystemPtr unitSystem, ShaderPort* shaderPort, ValueElementPtr input, const string& globalTargetUnitSpace, bool asInput) { + if (!unitSystem || globalTargetUnitSpace.empty()) + { + return; + } + const string& sourceUnitSpace = input->getUnit(); if (!shaderPort || sourceUnitSpace.empty()) { diff --git a/source/MaterialXGenShader/ShaderNode.cpp b/source/MaterialXGenShader/ShaderNode.cpp index 1916cae7ff..b8926439ed 100644 --- a/source/MaterialXGenShader/ShaderNode.cpp +++ b/source/MaterialXGenShader/ShaderNode.cpp @@ -258,7 +258,7 @@ ShaderNodePtr ShaderNode::create(const ShaderGraph* parent, const string& name, input->setValue(port->getResolvedValue()); } } - if (port->isA()) + if (port->getIsUniform()) { input->setUniform(); } diff --git a/source/MaterialXRender/Util.cpp b/source/MaterialXRender/Util.cpp index 911f1bf3b4..4e1d5e92d1 100644 --- a/source/MaterialXRender/Util.cpp +++ b/source/MaterialXRender/Util.cpp @@ -27,7 +27,7 @@ ShaderPtr createConstantShader(GenContext& context, doc->importLibrary(stdLib); NodeGraphPtr nodeGraph = doc->addNodeGraph(); NodePtr constant = nodeGraph->addNode("constant"); - constant->setParameterValue("value", color); + constant->setInputValue("value", color); OutputPtr output = nodeGraph->addOutput(); output->setConnectedNode(constant); @@ -88,8 +88,8 @@ ShaderPtr createBlurShader(GenContext& context, NodePtr imageNode = nodeGraph->addNode("image", "image"); NodePtr blurNode = nodeGraph->addNode("blur", "blur"); blurNode->setConnectedNode("in", imageNode); - blurNode->setParameterValue("size", filterSize); - blurNode->setParameterValue("filtertype", filterType); + blurNode->setInputValue("size", filterSize); + blurNode->setInputValue("filtertype", filterType); OutputPtr output = nodeGraph->addOutput(); output->setConnectedNode(blurNode); @@ -115,7 +115,7 @@ unsigned int getUIProperties(ConstValueElementPtr nodeDefElement, UIProperties& if (!uiProperties.uiFolder.empty()) propertyCount++; - if (nodeDefElement->isA()) + if (nodeDefElement->getIsUniform()) { string enumString = nodeDefElement->getAttribute(ValueElement::ENUM_ATTRIBUTE); if (!enumString.empty()) diff --git a/source/MaterialXRenderGlsl/GlslProgram.cpp b/source/MaterialXRenderGlsl/GlslProgram.cpp index 464f563e85..e5cc133387 100644 --- a/source/MaterialXRenderGlsl/GlslProgram.cpp +++ b/source/MaterialXRenderGlsl/GlslProgram.cpp @@ -777,20 +777,6 @@ void GlslProgram::bindLighting(LightHandlerPtr lightHandler, ImageHandlerPtr ima } } - // Set all parameters. Note that upstream connections are not currently handled. - for (auto param : light->getParameters()) - { - // Make sure we have a value to set - if (param->hasValue()) - { - input = uniformList.find(prefix + "." + param->getName()); - if (input != uniformList.end()) - { - bindUniform(input->second->location, *param->getValue()); - } - } - } - ++index; } } diff --git a/source/MaterialXRenderGlsl/TextureBaker.cpp b/source/MaterialXRenderGlsl/TextureBaker.cpp index 5ca69f881c..e2d577fed9 100644 --- a/source/MaterialXRenderGlsl/TextureBaker.cpp +++ b/source/MaterialXRenderGlsl/TextureBaker.cpp @@ -215,8 +215,8 @@ void TextureBaker::writeBakedMaterial(const FilePath& filename, const StringVec& // Add the image node. NodePtr bakedImage = bakedNodeGraph->addNode("image", bindInput->getName() + "_baked", bindInput->getType()); - ParameterPtr param = bakedImage->addParameter("file", "filename"); - param->setValueString(generateTextureFilename(output, _shaderRef->getName(), udimSet.empty() ? EMPTY_STRING : UDIM_TOKEN)); + InputPtr input = bakedImage->addInput("file", "filename"); + input->setValueString(generateTextureFilename(output, _shaderRef->getName(), udimSet.empty() ? EMPTY_STRING : UDIM_TOKEN)); // Check if is a normal node and transform normals into world space if (_worldSpaceShaderInputs.count(bindInput->getName())) diff --git a/source/MaterialXRuntime/RtFileIo.cpp b/source/MaterialXRuntime/RtFileIo.cpp index f11dba1dc4..83dc2470aa 100644 --- a/source/MaterialXRuntime/RtFileIo.cpp +++ b/source/MaterialXRuntime/RtFileIo.cpp @@ -733,7 +733,7 @@ namespace const PvtInput* input = attr->asA(); if (input->isUniform()) { - destPort = destNodeDef->addParameter(attr->getName(), attr->getType().str()); + destPort = destNodeDef->addInput(attr->getName(), attr->getType().str()); } else { @@ -786,7 +786,7 @@ namespace ValueElementPtr valueElem; if (input.isUniform()) { - valueElem = destNode->addParameter(input.getName(), input.getType()); + valueElem = destNode->addInput(input.getName(), input.getType()); if (input.isConnected()) { RtOutput source = input.getConnection(); @@ -939,7 +939,7 @@ namespace ValueElementPtr v = nullptr; if (nodegraphInput.isUniform()) { - v = destNodeGraph->addParameter(nodegraphInput.getName(), nodegraphInput.getType()); + v = destNodeGraph->addInput(nodegraphInput.getName(), nodegraphInput.getType()); } else { @@ -1293,10 +1293,8 @@ void RtFileIo::read(const FilePath& documentPath, const FileSearchPath& searchPa { DocumentPtr document = createDocument(); XmlReadOptions xmlReadOptions; - //xmlReadOptions.skipConflictingElements = true; if (options) { - //xmlReadOptions.skipConflictingElements = true; xmlReadOptions.applyFutureUpdates = options->applyFutureUpdates; } readFromXmlFile(document, documentPath, searchPaths, &xmlReadOptions); @@ -1316,10 +1314,8 @@ void RtFileIo::read(std::istream& stream, const RtReadOptions* options) { DocumentPtr document = createDocument(); XmlReadOptions xmlReadOptions; - //xmlReadOptions.skipConflictingElements = true; if (options) { - //xmlReadOptions.skipConflictingElements = true; xmlReadOptions.applyFutureUpdates = options->applyFutureUpdates; } readFromXmlStream(document, stream, &xmlReadOptions); diff --git a/source/MaterialXTest/MaterialXCore/Document.cpp b/source/MaterialXTest/MaterialXCore/Document.cpp index 2afebe3024..15cc3aecfa 100644 --- a/source/MaterialXTest/MaterialXCore/Document.cpp +++ b/source/MaterialXTest/MaterialXCore/Document.cpp @@ -20,7 +20,7 @@ TEST_CASE("Document", "[document]") // Create a node graph with a constant color output. mx::NodeGraphPtr nodeGraph = doc->addNodeGraph(); mx::NodePtr constant = nodeGraph->addNode("constant"); - constant->setParameterValue("value", mx::Color3(0.5f)); + constant->setInputValue("value", mx::Color3(0.5f)); mx::OutputPtr output = nodeGraph->addOutput(); output->setConnectedNode(constant); REQUIRE(doc->validate()); @@ -48,8 +48,12 @@ TEST_CASE("Document", "[document]") // Create a simple shader interface. mx::NodeDefPtr shader = doc->addNodeDef("", "surfaceshader", "simpleSrf"); mx::InputPtr diffColor = shader->addInput("diffColor", "color3"); - shader->addInput("specColor", "color3"); - mx::ParameterPtr roughness = shader->addParameter("roughness", "float"); + REQUIRE(!diffColor->getIsUniform()); + mx::InputPtr specColor = shader->addInput("specColor", "color3", true); + REQUIRE(specColor->getIsUniform()); + specColor->setIsUniform(false); + REQUIRE(!specColor->getIsUniform()); + mx::InputPtr roughness = shader->addInput("roughness", "float"); // Create a material that instantiates the shader. mx::MaterialPtr material = doc->addMaterial(); @@ -61,14 +65,14 @@ TEST_CASE("Document", "[document]") REQUIRE(diffColor->getUpstreamElement(material) == output); // Bind the roughness parameter to a value. - mx::BindParamPtr bindParam = shaderRef->addBindParam("roughness"); - bindParam->setValue(0.5f); + bindInput = shaderRef->addBindInput("roughness"); + bindInput->setValue(0.5f); REQUIRE(roughness->getBoundValue(material)->asA() == 0.5f); // Create and test a type mismatch in a data binding. - bindParam->setValue(5); + bindInput->setValue(5); REQUIRE(!doc->validate()); - bindParam->setValue(0.5f); + bindInput->setValue(0.5f); REQUIRE(doc->validate()); // Create a collection @@ -170,7 +174,7 @@ TEST_CASE("Version", "[document]") REQUIRE(doc->validate()); mx::XmlWriteOptions writeOptions; - writeOptions.writeXIncludeEnable = true; + writeOptions.writeXIncludeEnable = false; mx::writeToXmlFile(doc, "1_37_to_1_38_updated.mtlx", &writeOptions); mx::DocumentPtr doc2 = mx::createDocument(); diff --git a/source/MaterialXTest/MaterialXCore/Geom.cpp b/source/MaterialXTest/MaterialXCore/Geom.cpp index 974d52e203..53ba42ecf0 100644 --- a/source/MaterialXTest/MaterialXCore/Geom.cpp +++ b/source/MaterialXTest/MaterialXCore/Geom.cpp @@ -42,16 +42,16 @@ TEST_CASE("Geom elements", "[geom]") nodeGraph->setFilePrefix("folder/"); REQUIRE_THROWS_AS(doc->addNodeGraph(nodeGraph->getName()), mx::Exception&); mx::NodePtr image = nodeGraph->addNode("image"); - image->setParameterValue("file", "_diffuse_.tif", mx::FILENAME_TYPE_STRING); + image->setInputValue("file", "_diffuse_.tif", mx::FILENAME_TYPE_STRING); // Test filename string substitutions. - mx::ParameterPtr fileParam = image->getParameter("file"); + mx::InputPtr fileInput = image->getInput("file"); mx::StringResolverPtr resolver1 = image->createStringResolver("/robot1"); resolver1->setUdimString("1001"); mx::StringResolverPtr resolver2 = image->createStringResolver("/robot2"); resolver2->setUdimString("1002"); - REQUIRE(fileParam->getResolvedValue(resolver1)->asA() == "folder/robot01_diffuse_1001.tif"); - REQUIRE(fileParam->getResolvedValue(resolver2)->asA() == "folder/robot02_diffuse_1002.tif"); + REQUIRE(fileInput->getResolvedValue(resolver1)->asA() == "folder/robot01_diffuse_1001.tif"); + REQUIRE(fileInput->getResolvedValue(resolver2)->asA() == "folder/robot02_diffuse_1002.tif"); // Create a geominfo with an attribute. mx::GeomInfoPtr geominfo4 = doc->addGeomInfo("geominfo4", "/robot1"); diff --git a/source/MaterialXTest/MaterialXCore/Material.cpp b/source/MaterialXTest/MaterialXCore/Material.cpp index ad93e86348..3c333263f6 100644 --- a/source/MaterialXTest/MaterialXCore/Material.cpp +++ b/source/MaterialXTest/MaterialXCore/Material.cpp @@ -18,17 +18,17 @@ TEST_CASE("Material", "[material]") mx::NodeDefPtr simpleSrf = doc->addNodeDef("ND_simpleSrf", "surfaceshader", "simpleSrf"); simpleSrf->setInputValue("diffColor", mx::Color3(1.0f)); mx::InputPtr specColor = simpleSrf->setInputValue("specColor", mx::Color3(0.0f)); - mx::ParameterPtr roughness = simpleSrf->setParameterValue("roughness", 0.25f); + mx::InputPtr roughness = simpleSrf->setInputValue("roughness", 0.25f); mx::TokenPtr texId = simpleSrf->setTokenValue("texId", "01"); REQUIRE(simpleSrf->getInputValue("diffColor")->asA() == mx::Color3(1.0f)); REQUIRE(simpleSrf->getInputValue("specColor")->asA() == mx::Color3(0.0f)); - REQUIRE(simpleSrf->getParameterValue("roughness")->asA() == 0.25f); + REQUIRE(simpleSrf->getInputValue("roughness")->asA() == 0.25f); REQUIRE(simpleSrf->getTokenValue("texId") == "01"); // Create an inherited shader nodedef. mx::NodeDefPtr anisoSrf = doc->addNodeDef("ND_anisoSrf", "surfaceshader", "anisoSrf"); anisoSrf->setInheritsFrom(simpleSrf); - anisoSrf->setParameterValue("anisotropy", 0.0f); + anisoSrf->setInputValue("anisotropy", 0.0f); REQUIRE(anisoSrf->getInheritsFrom() == simpleSrf); // Create a material. @@ -40,8 +40,7 @@ TEST_CASE("Material", "[material]") REQUIRE(anisoSrf->getInstantiatingShaderRefs()[0] == refAnisoSrf); REQUIRE(refAnisoSrf->getNodeDef() == anisoSrf); REQUIRE(material->getPrimaryShaderName() == refAnisoSrf->getNodeString()); - REQUIRE(material->getPrimaryShaderParameters().size() == 2); - REQUIRE(material->getPrimaryShaderInputs().size() == 2); + REQUIRE(material->getPrimaryShaderInputs().size() == 4); REQUIRE(material->getPrimaryShaderTokens().size() == 1); // Set nodedef and shader reference qualifiers. @@ -55,13 +54,13 @@ TEST_CASE("Material", "[material]") REQUIRE(refAnisoSrf->getNodeDef() == anisoSrf); // Bind a shader parameter to a value. - mx::BindParamPtr bindParam = refAnisoSrf->addBindParam("roughness"); - bindParam->setValue(0.5f); + mx::BindInputPtr bindInput = refAnisoSrf->addBindInput("roughness"); + bindInput->setValue(0.5f); REQUIRE(roughness->getBoundValue(material)->asA() == 0.5f); REQUIRE(roughness->getDefaultValue()->asA() == 0.25f); // Bind a shader input to a value. - mx::BindInputPtr bindInput = refAnisoSrf->addBindInput("specColor"); + bindInput = refAnisoSrf->addBindInput("specColor"); bindInput->setValue(mx::Color3(0.5f)); REQUIRE(specColor->getBoundValue(material)->asA() == mx::Color3(0.5f)); REQUIRE(specColor->getDefaultValue()->asA() == mx::Color3(0.0f)); @@ -84,8 +83,7 @@ TEST_CASE("Material", "[material]") mx::MaterialPtr material2 = doc->addMaterial(); material2->setInheritsFrom(material); REQUIRE(material2->getPrimaryShaderName() == refAnisoSrf->getNodeString()); - REQUIRE(material2->getPrimaryShaderParameters().size() == 2); - REQUIRE(material2->getPrimaryShaderInputs().size() == 2); + REQUIRE(material2->getPrimaryShaderInputs().size() == 4); REQUIRE(material2->getPrimaryShaderTokens().size() == 1); REQUIRE(roughness->getBoundValue(material2)->asA() == 0.5f); @@ -98,7 +96,6 @@ TEST_CASE("Material", "[material]") // Disconnect the inherited material. material2->setInheritsFrom(nullptr); REQUIRE(material2->getPrimaryShaderName().empty()); - REQUIRE(material2->getPrimaryShaderParameters().empty()); REQUIRE(material2->getPrimaryShaderInputs().empty()); REQUIRE(material2->getPrimaryShaderTokens().empty()); REQUIRE(roughness->getBoundValue(material2)->asA() == 0.25f); @@ -107,7 +104,6 @@ TEST_CASE("Material", "[material]") material->removeShaderRef(refAnisoSrf->getName()); REQUIRE(anisoSrf->getInstantiatingShaderRefs().empty()); REQUIRE(material->getPrimaryShaderName().empty()); - REQUIRE(material->getPrimaryShaderParameters().empty()); REQUIRE(material->getPrimaryShaderInputs().empty()); REQUIRE(material->getPrimaryShaderTokens().empty()); } diff --git a/source/MaterialXTest/MaterialXCore/Node.cpp b/source/MaterialXTest/MaterialXCore/Node.cpp index 69d7cf3be5..d15905061f 100644 --- a/source/MaterialXTest/MaterialXCore/Node.cpp +++ b/source/MaterialXTest/MaterialXCore/Node.cpp @@ -48,15 +48,15 @@ TEST_CASE("Node", "[node]") // Set constant node color. mx::Color3 color(0.1f, 0.2f, 0.3f); - constant->setParameterValue("value", color); - REQUIRE(constant->getParameterValue("value")->isA()); - REQUIRE(constant->getParameterValue("value")->asA() == color); + constant->setInputValue("value", color); + REQUIRE(constant->getInputValue("value")->isA()); + REQUIRE(constant->getInputValue("value")->asA() == color); // Set image node file. std::string file("image1.tif"); - image->setParameterValue("file", file, mx::FILENAME_TYPE_STRING); - REQUIRE(image->getParameterValue("file")->isA()); - REQUIRE(image->getParameterValue("file")->asA() == file); + image->setInputValue("file", file, mx::FILENAME_TYPE_STRING); + REQUIRE(image->getInputValue("file")->isA()); + REQUIRE(image->getInputValue("file")->asA() == file); // Create connected outputs. mx::OutputPtr output1 = doc->addOutput(); @@ -71,18 +71,18 @@ TEST_CASE("Node", "[node]") // Create a custom nodedef. mx::NodeDefPtr customNodeDef = doc->addNodeDef("ND_turbulence3d", "float", "turbulence3d"); customNodeDef->setNodeGroup(mx::NodeDef::PROCEDURAL_NODE_GROUP); - customNodeDef->setParameterValue("octaves", 3); - customNodeDef->setParameterValue("lacunarity", 2.0f); - customNodeDef->setParameterValue("gain", 0.5f); + customNodeDef->setInputValue("octaves", 3); + customNodeDef->setInputValue("lacunarity", 2.0f); + customNodeDef->setInputValue("gain", 0.5f); // Reference the custom nodedef. mx::NodePtr custom = doc->addNodeInstance(customNodeDef); REQUIRE(custom->getNodeDefString() == customNodeDef->getName()); REQUIRE(custom->getNodeDef()->getNodeGroup() == mx::NodeDef::PROCEDURAL_NODE_GROUP); - REQUIRE(custom->getParameterValue("octaves")->isA()); - REQUIRE(custom->getParameterValue("octaves")->asA() == 3); - custom->setParameterValue("octaves", 5); - REQUIRE(custom->getParameterValue("octaves")->asA() == 5); + REQUIRE(custom->getInputValue("octaves")->isA()); + REQUIRE(custom->getInputValue("octaves")->asA() == 3); + custom->setInputValue("octaves", 5); + REQUIRE(custom->getInputValue("octaves")->asA() == 5); // Remove the nodedef attribute from the node, requiring that it fall back // to type and version matching. @@ -111,11 +111,11 @@ TEST_CASE("Node", "[node]") // Reference the custom type. std::string d65("400.0,82.75,500.0,109.35,600.0,90.01,700.0,71.61,800.0,59.45"); - constant->setParameterValue("value", d65, "spectrum"); - REQUIRE(constant->getParameter("value")->getType() == "spectrum"); - REQUIRE(constant->getParameter("value")->getValueString() == d65); - REQUIRE(constant->getParameterValue("value")->isA()); - REQUIRE(constant->getParameterValue("value")->asA() == d65); + constant->setInputValue("value", d65, "spectrum"); + REQUIRE(constant->getInput("value")->getType() == "spectrum"); + REQUIRE(constant->getInput("value")->getValueString() == d65); + REQUIRE(constant->getInputValue("value")->isA()); + REQUIRE(constant->getInputValue("value")->asA() == d65); // Validate the document. REQUIRE(doc->validate()); @@ -604,6 +604,7 @@ TEST_CASE("Node Definition Creation", "[nodedef]") for (auto node : newGraph->getNodes()) { mx::NodeDefPtr nodeNodeDef = node->getNodeDef(); + REQUIRE(nodeNodeDef); for (auto nodeDefValueElem : nodeNodeDef->getActiveValueElements()) { const std::string& valueElemName = nodeDefValueElem->getName(); @@ -641,26 +642,6 @@ TEST_CASE("Node Definition Creation", "[nodedef]") REQUIRE(nodeDef->getChild(newInterfaceName)); } } - else - { - mx::ParameterPtr param = valueElem->asA(); - if (param) - { - std::string interfaceName = param->getNamePath(); - interfaceName = nodeDef->createValidChildName(interfaceName); - newGraph->addInterface(param->getNamePath(newGraph), interfaceName); - REQUIRE(nodeDef->getChild(interfaceName)); - try - { - // Check duplicate failure case - newGraph->addInterface(param->getNamePath(newGraph), interfaceName); - } - catch (mx::Exception& e) - { - REQUIRE(e.what()); - } - } - } } } diff --git a/source/MaterialXTest/MaterialXCore/Observer.cpp b/source/MaterialXTest/MaterialXCore/Observer.cpp index 2ef997fb1e..1876091f12 100644 --- a/source/MaterialXTest/MaterialXCore/Observer.cpp +++ b/source/MaterialXTest/MaterialXCore/Observer.cpp @@ -120,7 +120,7 @@ TEST_CASE("Observer", "[observer]") // Create a node graph with a constant color output. mx::NodeGraphPtr nodeGraph = doc->addNodeGraph(); mx::NodePtr constant = nodeGraph->addNode("constant"); - constant->setParameterValue("value", mx::Color3(0.1f, 0.2f, 0.3f)); + constant->setInputValue("value", mx::Color3(0.1f, 0.2f, 0.3f)); mx::OutputPtr output = nodeGraph->addOutput(); output->setConnectedNode(constant); @@ -128,7 +128,7 @@ TEST_CASE("Observer", "[observer]") mx::NodeDefPtr shader = doc->addNodeDef("ND_simpleSrf", "surfaceshader", "simpleSrf"); shader->addInput("diffColor", "color3"); shader->addInput("specColor", "color3"); - shader->addParameter("roughness", "float"); + shader->addInput("roughness", "float"); // Create a material that uses a shader instance. mx::NodePtr materialNode = doc->addNode("surfacematerial"); diff --git a/source/MaterialXTest/MaterialXCore/Unit.cpp b/source/MaterialXTest/MaterialXCore/Unit.cpp index a3a90907ac..68568a0f7b 100644 --- a/source/MaterialXTest/MaterialXCore/Unit.cpp +++ b/source/MaterialXTest/MaterialXCore/Unit.cpp @@ -28,13 +28,13 @@ TEST_CASE("UnitAttribute", "[unit]") // Basic get/set unit testing mx::NodePtr constant = nodeGraph->addNode("constant"); constant->setName("constant1"); - constant->setParameterValue("value", mx::Color3(0.5f)); - mx::ParameterPtr param = constant->getParameter("value"); - param->setName("param1"); - param->setUnitType("distance"); - param->setUnit("meter"); - REQUIRE(param->hasUnit()); - REQUIRE(!param->getUnit().empty()); + constant->setInputValue("value", mx::Color3(0.5f)); + mx::InputPtr input = constant->getInput("value"); + input->setName("param1"); + input->setUnitType("distance"); + input->setUnit("meter"); + REQUIRE(input->hasUnit()); + REQUIRE(!input->getUnit().empty()); // Test for valid unit names mx::OutputPtr output = nodeGraph->addOutput(); @@ -50,7 +50,7 @@ TEST_CASE("UnitAttribute", "[unit]") // Test for target unit specified on a nodedef mx::NodeDefPtr customNodeDef = doc->addNodeDef("ND_dummy", "float", "dummy"); - mx::InputPtr input = customNodeDef->setInputValue("angle", 23.0f, "float"); + input = customNodeDef->setInputValue("angle", 23.0f, "float"); input->setUnit("degree"); mx::NodePtr custom = doc->addNodeInstance(customNodeDef); input = custom->setInputValue("angle", 45.0f, "float"); @@ -186,47 +186,6 @@ TEST_CASE("UnitDocument", "[unit]") } } } - - if (pNode->getParameterCount()) - { - for (auto param: pNode->getParameters()) - { - const std::string type = param->getType(); - const mx::ValuePtr value = param->getValue(); - if (param->hasUnit() && value) - { - if (type == "float") - { - float originalval = value->asA(); - float convertedValue = uconverter->convert(originalval, param->getUnit(), DISTANCE_DEFAULT); - float reconvert = uconverter->convert(convertedValue, DISTANCE_DEFAULT, param->getUnit()); - REQUIRE((originalval - reconvert) < EPSILON); - } - else if (type == "vector2") - { - mx::Vector2 originalval = value->asA(); - mx::Vector2 convertedValue = uconverter->convert(originalval, param->getUnit(), DISTANCE_DEFAULT); - mx::Vector2 reconvert = uconverter->convert(convertedValue, DISTANCE_DEFAULT, param->getUnit()); - REQUIRE(originalval == reconvert); - } - else if (type == "vector3") - { - mx::Vector3 originalval = value->asA(); - mx::Vector3 convertedValue = uconverter->convert(originalval, param->getUnit(), DISTANCE_DEFAULT); - mx::Vector3 reconvert = uconverter->convert(convertedValue, DISTANCE_DEFAULT, param->getUnit()); - REQUIRE(originalval == reconvert); - } - else if (type == "vector4") - { - mx::Vector4 originalval = value->asA(); - mx::Vector4 convertedValue = uconverter->convert(originalval, param->getUnit(), DISTANCE_DEFAULT); - mx::Vector4 reconvert = uconverter->convert(convertedValue, DISTANCE_DEFAULT, param->getUnit()); - REQUIRE(originalval == reconvert); - } - } - } - } - } } } diff --git a/source/MaterialXTest/MaterialXFormat/XmlIo.cpp b/source/MaterialXTest/MaterialXFormat/XmlIo.cpp index f64ee59795..d508d506c0 100644 --- a/source/MaterialXTest/MaterialXFormat/XmlIo.cpp +++ b/source/MaterialXTest/MaterialXFormat/XmlIo.cpp @@ -68,14 +68,6 @@ TEST_CASE("Load content", "[xmlio]") { REQUIRE(material->getPrimaryShaderNodeDef()); int edgeCount = 0; - for (mx::ParameterPtr param : material->getPrimaryShaderParameters()) - { - REQUIRE(param->getBoundValue(material)); - for (mx::Edge edge : param->traverseGraph(material)) - { - edgeCount++; - } - } for (mx::InputPtr input : material->getPrimaryShaderInputs()) { REQUIRE((input->getBoundValue(material) || input->getUpstreamElement(material))); diff --git a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp index 9132d7953b..8089d33428 100644 --- a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp +++ b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp @@ -1001,7 +1001,7 @@ bool TestSuiteOptions::readOptions(const std::string& optionFile) MaterialX::NodeDefPtr optionDefs = doc->getNodeDef(RENDER_TEST_OPTIONS_STRING); if (optionDefs) { - for (auto p : optionDefs->getParameters()) + for (auto p : optionDefs->getInputs()) { const std::string& name = p->getName(); MaterialX::ValuePtr val = p->getValue(); diff --git a/source/MaterialXTest/MaterialXRenderOsl/GenReference.cpp b/source/MaterialXTest/MaterialXRenderOsl/GenReference.cpp index c849d83921..c5fbcbb0d3 100644 --- a/source/MaterialXTest/MaterialXRenderOsl/GenReference.cpp +++ b/source/MaterialXTest/MaterialXRenderOsl/GenReference.cpp @@ -234,11 +234,6 @@ TEST_CASE("GenReference: OSL Reference", "[genreference]") mx::InputPtr input = impl->addInput(elem->getName(), elem->getType()); input->setImplementationName(port->getVariable()); } - else - { - mx::ParameterPtr param = impl->addParameter(elem->getName(), elem->getType()); - param->setImplementationName(port->getVariable()); - } } } } diff --git a/source/MaterialXView/Material.cpp b/source/MaterialXView/Material.cpp index 6382e7404a..9a7e2cfbed 100644 --- a/source/MaterialXView/Material.cpp +++ b/source/MaterialXView/Material.cpp @@ -163,7 +163,7 @@ bool Material::generateEnvironmentShader(mx::GenContext& context, { return false; } - image->setParameterValue("file", imagePath.asString(), mx::FILENAME_TYPE_STRING); + image->setInputValue("file", imagePath.asString(), mx::FILENAME_TYPE_STRING); mx::OutputPtr output = envGraph->getOutput("out"); if (!output) { @@ -516,20 +516,6 @@ void Material::bindLights(const mx::GenContext& genContext, mx::LightHandlerPtr } } - // Set all parameters. Note that upstream node connections are not currently supported. - for (mx::ParameterPtr param : light->getParameters()) - { - // Make sure we have a value to set - if (param->hasValue()) - { - std::string paramName(prefix + "." + param->getName()); - if (_glShader->uniform(paramName, false) != -1) - { - bindUniform(paramName, param->getValue()); - } - } - } - ++index; } } diff --git a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp index 28c73e804f..80e49f5f72 100644 --- a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp +++ b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp @@ -164,6 +164,8 @@ void bindPyElement(py::module& mod) .def("setUnitType", &mx::ValueElement::setUnitType) .def("hasUnitType", &mx::ValueElement::hasUnitType) .def("getUnitType", &mx::ValueElement::getUnitType) + .def("getIsUniform", &mx::ValueElement::getIsUniform) + .def("setIsUniform", &mx::ValueElement::setIsUniform) .def_readonly_static("VALUE_ATTRIBUTE", &mx::ValueElement::VALUE_ATTRIBUTE) .def_readonly_static("INTERFACE_NAME_ATTRIBUTE", &mx::ValueElement::INTERFACE_NAME_ATTRIBUTE) .def_readonly_static("IMPLEMENTATION_NAME_ATTRIBUTE", &mx::ValueElement::IMPLEMENTATION_NAME_ATTRIBUTE) diff --git a/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp b/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp index 3132eee45b..21dbd7e2a2 100644 --- a/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp +++ b/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp @@ -62,7 +62,8 @@ void bindPyInterface(py::module& mod) .def("getActiveParameter", &mx::InterfaceElement::getActiveParameter) .def("getActiveParameters", &mx::InterfaceElement::getActiveParameters) .def("addInput", &mx::InterfaceElement::addInput, - py::arg("name") = mx::EMPTY_STRING, py::arg("type") = mx::DEFAULT_TYPE_STRING) + py::arg("name") = mx::EMPTY_STRING, py::arg("type") = mx::DEFAULT_TYPE_STRING, + py::arg("isUniform") = false) .def("getInput", &mx::InterfaceElement::getInput) .def("getInputs", &mx::InterfaceElement::getInputs) .def("getInputCount", &mx::InterfaceElement::getInputCount) diff --git a/source/PyMaterialX/PyMaterialXCore/PyMaterial.cpp b/source/PyMaterialX/PyMaterialXCore/PyMaterial.cpp index 14d58dd8c4..e6b1c46ab7 100644 --- a/source/PyMaterialX/PyMaterialXCore/PyMaterial.cpp +++ b/source/PyMaterialX/PyMaterialXCore/PyMaterial.cpp @@ -27,8 +27,6 @@ void bindPyMaterial(py::module& mod) py::arg("target") = mx::EMPTY_STRING, py::arg("type") = mx::EMPTY_STRING) .def("getPrimaryShaderName", &mx::Material::getPrimaryShaderName, py::arg("target") = mx::EMPTY_STRING, py::arg("type") = mx::EMPTY_STRING) - .def("getPrimaryShaderParameters", &mx::Material::getPrimaryShaderParameters, - py::arg("target") = mx::EMPTY_STRING, py::arg("type") = mx::EMPTY_STRING) .def("getPrimaryShaderInputs", &mx::Material::getPrimaryShaderInputs, py::arg("target") = mx::EMPTY_STRING, py::arg("type") = mx::EMPTY_STRING) .def("getPrimaryShaderTokens", &mx::Material::getPrimaryShaderTokens,