Skip to content

Commit

Permalink
Merge pull request #1343 from autodesk-forks/adsk_contrib/138_main_sync
Browse files Browse the repository at this point in the history
1.38.3 ILM main sync
  • Loading branch information
kwokcb authored Dec 14, 2021
2 parents 6a89433 + bfb21f6 commit c52c013
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 65 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# Change Log

## [1.38.3] - Development
## [1.38.3] - 2021-12-14

### Added
- Added an inheritance structure for versions of Autodesk Standard Surface.
- Added versioning and customization support to MaterialX namespaces in C++.
- Added preprocessor definitions for the API version to MaterialXCore.
- Added an initial ClangFormat file for the MaterialX codebase.
- Added color transform methods to the Image class.
- Added an initial ClangFormat file for the MaterialX codebase.
- Added initial support for FreeBSD.
- Added support for Xcode 13.

### Changed
- Refactored BSDF handling in shader generation, allowing for more flexible and efficient vertical layering.
- Optimized GLSL implementations for GGX specular, moving common computations to tangent space.
- Merged the ViewHandler and viewer camera into a new Camera class in MaterialXRender.
- Updated CMake configuration generation logic, adding handling for shared library builds.
- Updated the PyBind11 library to version 2.7.1

### Fixed
- Fixed a performance regression in MaterialXView for multi-UDIM assets.
- Fixed a bug that caused shader inputs to be skipped in createUIPropertyGroups.
- Fixed the value of transmission roughness in UsdPreviewSurface.
- Fixed Vulkan compatibility for generated GLSL code.

## [1.38.2] - 2021-10-07

Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,16 @@ endif()
# Namespace
set(MATERIALX_NAMESPACE_SUFFIX "" CACHE STRING "Add a suffix to the main MaterialX C++ namespace: Options include dev, staging, <YOURFACILITY> etc.")
if(MATERIALX_NAMESPACE_SUFFIX STREQUAL "")
set(MATERIALX_NAMESPACE "MaterialX_v${MATERIALX_MAJOR_VERSION}_${MATERIALX_MINOR_VERSION}_${MATERIALX_BUILD_VERSION}")
set(MATERIALX_NAMESPACE "MaterialX_v${MATERIALX_MAJOR_VERSION}_${MATERIALX_MINOR_VERSION}_${MATERIALX_BUILD_VERSION}")
else()
set(MATERIALX_NAMESPACE "MaterialX_${MATERIALX_NAMESPACE_SUFFIX}_v${MATERIALX_MAJOR_VERSION}_${MATERIALX_MINOR_VERSION}_${MATERIALX_BUILD_VERSION}")
endif()
message(STATUS "Setting namespace to '${MATERIALX_NAMESPACE}'")

# Library name custom suffix
# This helps an application that needs to ship a dynamic library MaterialX ensure
# that it has a unique name that won't conflict with one elsewhere on the
# system.
set (MATERIALX_LIBNAME_SUFFIX "" CACHE STRING
"Specify a suffix to all libraries that are built")
# that it has a unique name that won't conflict with one elsewhere on the system.
set (MATERIALX_LIBNAME_SUFFIX "" CACHE STRING "Specify a suffix to all libraries that are built")

mark_as_advanced(MATERIALX_BUILD_DOCS)
mark_as_advanced(MATERIALX_BUILD_GEN_GLSL)
Expand Down
29 changes: 13 additions & 16 deletions libraries/bxdf/standard_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<!--
Autodesk Standard Surface node definition.
-->
<nodedef name="ND_standard_surface_surfaceshader" node="standard_surface" nodegroup="pbr" doc="Autodesk standard surface shader" version="1.0.1" isdefaultversion="true"
inherit="ND_standard_surface_surfaceshader_100">
<input name="base" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base" doc="Multiplier on the intensity of the diffuse reflection." />
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base" doc="Color of the diffuse reflection." />
<nodedef name="ND_standard_surface_surfaceshader" node="standard_surface" nodegroup="pbr" version="1.0.1" isdefaultversion="true" inherit="ND_standard_surface_surfaceshader_100"
doc="Autodesk standard surface shader">
<input name="base" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
doc="Multiplier on the intensity of the diffuse reflection." />
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
doc="Color of the diffuse reflection." />
</nodedef>

<nodedef name="ND_standard_surface_surfaceshader_100" node="standard_surface" nodegroup="pbr" doc="Autodesk standard surface shader" version="1.0.0" >
<nodedef name="ND_standard_surface_surfaceshader_100" node="standard_surface" nodegroup="pbr" version="1.0.0" doc="Autodesk standard surface shader">
<input name="base" type="float" value="0.8" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
doc="Multiplier on the intensity of the diffuse reflection." />
<input name="base_color" type="color3" value="1.0, 1.0, 1.0" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
Expand Down Expand Up @@ -98,18 +100,13 @@
</nodedef>

<!--
Association between imlementation and definition.
Note that version 1.0.1 only changes some default values and thus reuses the same 1.0.0 nodegraph implementation
-->
<implementation name="IMPL_standard_surface_surfaceshader_101"
nodedef="ND_standard_surface_surfaceshader"
nodegraph="NG_standard_surface_surfaceshader_100" />

<implementation name="IMPL_standard_surface_surfaceshader_100"
nodedef="ND_standard_surface_surfaceshader_100"
nodegraph="NG_standard_surface_surfaceshader_100" />
Association between implementation and definition.
Note that version 1.0.1 only changes default values and thus reuses the same 1.0.0 nodegraph implementation.
-->
<implementation name="IMPL_standard_surface_surfaceshader_101" nodedef="ND_standard_surface_surfaceshader" nodegraph="NG_standard_surface_surfaceshader_100" />
<implementation name="IMPL_standard_surface_surfaceshader_100" nodedef="ND_standard_surface_surfaceshader_100" nodegraph="NG_standard_surface_surfaceshader_100" />

<!--
<!--
Autodesk Standard Surface nodegraph implementation.
-->
<nodegraph name="NG_standard_surface_surfaceshader_100">
Expand Down
7 changes: 6 additions & 1 deletion libraries/pbrlib/pbrlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,14 @@
<input name="anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" />
<output name="out" type="vector2" />
</nodedef>

<!--
Node: <blackbody>
Returns the radiant emittance of a blackbody radiator with the given temperature.
-->
<nodedef name="ND_blackbody" node="blackbody" nodegroup="pbr" doc="Returns the radiant emittance of a blackbody radiator with the given temperature.">
<input name="temperature" type="float" value="5000.0" />
<output name="out" type="float" />
<output name="out" type="color3" />
</nodedef>

<!--
Expand Down
1 change: 0 additions & 1 deletion source/MaterialXCore/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ class MX_CORE_API Implementation : public InterfaceElement
return getAttribute(PortElement::NODE_GRAPH_ATTRIBUTE);
}


/// @}
/// @name NodeDef References
/// @{
Expand Down
5 changes: 2 additions & 3 deletions source/MaterialXCore/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,9 @@ vector<OutputPtr> Document::getMaterialOutputs() const
const string documentUri = getSourceUri();
for (NodeGraphPtr docNodeGraph : getNodeGraphs())
{
// Skip nodegraphs which are either definitions or are from
// an included file
// Skip nodegraphs which are either definitions or are from an included file.
const string graphUri = docNodeGraph->getSourceUri();
if (docNodeGraph->getNodeDef() || (!graphUri.empty() && documentUri != graphUri ))
if (docNodeGraph->getNodeDef() || (!graphUri.empty() && documentUri != graphUri))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXCore/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class MX_CORE_API Document : public GraphElement
/// @}
/// @name Material Outputs
/// @{

/// Return material-type outputs for all nodegraphs in the document.
vector<OutputPtr> getMaterialOutputs() const;

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXCore/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ class MX_CORE_API InterfaceElement : public TypedElement
/// Return true if this instance has an exact input match with the given
/// declaration, where each input of this the instance corresponds to a
/// declaration input of the same name and type.
///
///
/// If an exact input match is not found, and the optional message argument
/// is provided, then an error message will be appended to the given string.
bool hasExactInputMatch(ConstInterfaceElementPtr declaration, string* message = nullptr) const;
Expand Down
1 change: 0 additions & 1 deletion source/MaterialXCore/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,3 @@ vector<OutputPtr> getConnectedOutputs(NodePtr node)
}

MATERIALX_NAMESPACE_END

2 changes: 1 addition & 1 deletion source/MaterialXCore/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class MX_CORE_API NodeGraph : public GraphElement

/// @name Material References
/// @{

/// Return all material-type outputs of the nodegraph.
vector<OutputPtr> getMaterialOutputs() const;

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenOsl/OslSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class OSLFilenameTypeSyntax : public AggregateTypeSyntax
const string prefix = uniform ? "{" : getName() + "(";
const string suffix = uniform ? "}" : ")";
const string filename = port->getValue() ? port->getValue()->getValueString() : EMPTY_STRING;
return prefix + "\"" + filename + "\", \"" + port->getColorspace() + "\"" + suffix;
return prefix + "\"" + filename + "\", \"" + port->getColorSpace() + "\"" + suffix;
}

string getValue(const Value& value, bool uniform) const override
Expand Down
46 changes: 23 additions & 23 deletions source/MaterialXGenShader/ShaderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void ShaderGraph::addUnitTransformNode(ShaderInput* input, const UnitTransform&
shaderInput->setValue(input->getValue());
shaderInput->setPath(input->getPath());
shaderInput->setUnit(input->getUnit());
shaderInput->setColorspace(input->getColorspace());
shaderInput->setColorSpace(input->getColorSpace());

if (input->isBindInput())
{
Expand Down Expand Up @@ -489,8 +489,8 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader(
const string& nodeColorspace = nodeInput->getColorSpace();
if (!nodeColorspace.empty())
{
inputSocket->setColorspace(nodeColorspace);
input->setColorspace(nodeColorspace);
inputSocket->setColorSpace(nodeColorspace);
input->setColorSpace(nodeColorspace);
}
}

Expand Down Expand Up @@ -536,7 +536,7 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader(
const string& inputName = nodeInput->getName();
const string path = nodePath + NAME_PATH_SEPARATOR + inputName;
const string& unit = nodeInput->getUnit();
const string& colorspace = nodeInput->getColorSpace();
const string& colorSpace = nodeInput->getColorSpace();
ShaderInput* input = newNode->getInput(inputName);
if (input)
{
Expand All @@ -548,9 +548,9 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader(
{
input->setUnit(unit);
}
if (input->getColorspace().empty() && !colorspace.empty())
if (input->getColorSpace().empty() && !colorSpace.empty())
{
input->setColorspace(colorspace);
input->setColorSpace(colorSpace);
}
}
ShaderGraphInputSocket* inputSocket = graph->getInputSocket(inputName);
Expand All @@ -564,9 +564,9 @@ ShaderGraphPtr ShaderGraph::createSurfaceShader(
{
inputSocket->setUnit(unit);
}
if (inputSocket->getColorspace().empty() && !colorspace.empty())
if (inputSocket->getColorSpace().empty() && !colorSpace.empty())
{
inputSocket->setColorspace(colorspace);
inputSocket->setColorSpace(colorSpace);
}
}
}
Expand Down Expand Up @@ -630,10 +630,10 @@ ShaderGraphPtr ShaderGraph::create(const ShaderGraph* parent, const string& name
{
outputSocket->setUnit(outputUnit);
}
const string& outputColorspace = output->getColorSpace();
if (!outputColorspace.empty())
const string& outputColorSpace = output->getColorSpace();
if (!outputColorSpace.empty())
{
outputSocket->setColorspace(outputColorspace);
outputSocket->setColorSpace(outputColorSpace);
}

// Start traversal from this output
Expand Down Expand Up @@ -714,11 +714,11 @@ ShaderGraphPtr ShaderGraph::create(const ShaderGraph* parent, const string& name
inputSocket->setUnit(unit);
input->setUnit(unit);
}
const string& colorspace = nodePort->getColorSpace();
if (!colorspace.empty())
const string& colorSpace = nodePort->getColorSpace();
if (!colorSpace.empty())
{
inputSocket->setColorspace(colorspace);
input->setColorspace(colorspace);
inputSocket->setColorSpace(colorSpace);
input->setColorSpace(colorSpace);
}
}

Expand Down Expand Up @@ -831,11 +831,11 @@ ShaderNode* ShaderGraph::createNode(const Node& node, GenContext& context)
ShaderOutput* shaderOutput = newNode->getOutput();
if (shaderOutput)
{
string cs = populateColorTransformMap(colorManagementSystem, shaderOutput, input, targetColorSpace, false);
string colorSpace = populateColorTransformMap(colorManagementSystem, shaderOutput, input, targetColorSpace, false);
ShaderInput* shaderInput = newNode->getInput(input->getName());
if (shaderInput && !cs.empty())
if (shaderInput && !colorSpace.empty())
{
shaderInput->setColorspace(cs);
shaderInput->setColorSpace(colorSpace);
}
populateUnitTransformMap(unitSystem, shaderOutput, input, targetDistanceUnit, false);
}
Expand Down Expand Up @@ -950,7 +950,7 @@ void ShaderGraph::finalize(GenContext& context)
inputSocket->setPath(input->getPath());
inputSocket->setValue(input->getValue());
inputSocket->setUnit(input->getUnit());
inputSocket->setColorspace(input->getColorspace());
inputSocket->setColorSpace(input->getColorSpace());
if (input->isUniform())
{
inputSocket->setUniform();
Expand Down Expand Up @@ -1103,10 +1103,10 @@ void ShaderGraph::bypass(GenContext& context, ShaderNode* node, size_t inputInde
{
downstream->setUnit(inputUnit);
}
const string& inputColorspace = input->getColorspace();
if (!inputColorspace.empty())
const string& inputColorSpace = input->getColorSpace();
if (!inputColorSpace.empty())
{
downstream->setColorspace(inputColorspace);
downstream->setColorSpace(inputColorSpace);
}

// Swizzle the input value. Once done clear the channel to indicate
Expand Down Expand Up @@ -1309,7 +1309,7 @@ string ShaderGraph::populateColorTransformMap(ColorManagementSystemPtr colorMana
if (sourceColorSpace != targetColorSpace)
{
// Cache colorspace on shader port
shaderPort->setColorspace(sourceColorSpace);
shaderPort->setColorSpace(sourceColorSpace);
if (colorManagementSystem)
{
ColorSpaceTransform transform(sourceColorSpace, targetColorSpace, shaderPort->getType());
Expand Down
7 changes: 3 additions & 4 deletions source/MaterialXGenShader/ShaderNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

#include <MaterialXCore/Node.h>

#include <iostream>

MATERIALX_NAMESPACE_BEGIN

class ShaderNode;
class ShaderPort;
class ShaderInput;
Expand Down Expand Up @@ -173,10 +172,10 @@ class MX_GENSHADER_API ShaderPort : public std::enable_shared_from_this<ShaderPo
ValuePtr getValue() const { return _value; }

/// Set a source color space for the value on this port.
void setColorspace(const string& colorspace) { _colorspace = colorspace; }
void setColorSpace(const string& colorspace) { _colorspace = colorspace; }

/// Return the source color space for the value on this port.
const string& getColorspace() const { return _colorspace; }
const string& getColorSpace() const { return _colorspace; }

/// Set a unit type for the value on this port.
void setUnit(const string& unit) { _unit = unit; }
Expand Down
8 changes: 4 additions & 4 deletions source/MaterialXRenderGlsl/GlslProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ const GlslProgram::InputMap& GlslProgram::updateUniformsList()
Input* input = inputIt->second.get();
input->path = v->getPath();
input->unit = v->getUnit();
input->colorspace = v->getColorspace();
input->colorspace = v->getColorSpace();
input->value = v->getValue();
if (input->gltype == glType)
{
Expand All @@ -962,7 +962,7 @@ const GlslProgram::InputMap& GlslProgram::updateUniformsList()
+ "\". Semantic: \"" + v->getSemantic()
+ "\". Value: \"" + (v->getValue() ? v->getValue()->getValueString() : "<none>")
+ "\". Unit: \"" + (!v->getUnit().empty() ? v->getUnit() : "<none>")
+ "\". Colorspace: \"" + (!v->getColorspace().empty() ? v->getColorspace() : "<none>")
+ "\". Colorspace: \"" + (!v->getColorSpace().empty() ? v->getColorSpace() : "<none>")
+ "\". GLType: " + std::to_string(mapTypeToOpenGLType(v->getType()))
);
uniformTypeMismatchFound = true;
Expand All @@ -988,7 +988,7 @@ const GlslProgram::InputMap& GlslProgram::updateUniformsList()
input->value = v->getValue();
input->path = v->getPath();
input->unit = v->getUnit();
input->colorspace = v->getColorspace();
input->colorspace = v->getColorSpace();
}
else
{
Expand All @@ -999,7 +999,7 @@ const GlslProgram::InputMap& GlslProgram::updateUniformsList()
+ "\". Semantic: \"" + v->getSemantic()
+ "\". Value: \"" + (v->getValue() ? v->getValue()->getValueString() : "<none>")
+ "\". Unit: \"" + (!v->getUnit().empty() ? v->getUnit() : "<none>")
+ "\". Colorspace: \"" + (!v->getColorspace().empty() ? v->getColorspace() : "<none>")
+ "\". Colorspace: \"" + (!v->getColorSpace().empty() ? v->getColorSpace() : "<none>")
+ "\". GLType: " + std::to_string(mapTypeToOpenGLType(v->getType()))
);
uniformTypeMismatchFound = true;
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXRenderHw/SimpleWindowLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <X11/Intrinsic.h> // for XtCallbackProc definition

MATERIALX_NAMESPACE_BEGIN

SimpleWindow::SimpleWindow()
{
clearInternalState();
Expand Down
1 change: 0 additions & 1 deletion source/MaterialXTest/MaterialXRender/RenderUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <MaterialXTest/MaterialXGenShader/GenShaderUtil.h>

#include <MaterialXRender/LightHandler.h>
#include <MaterialXRender/ImageHandler.h>
#include <MaterialXRender/Timer.h>
#include <MaterialXRender/Util.h>
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXTest/MaterialXRenderOgsFx/RenderOgsFx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <MaterialXFormat/Util.h>

#include <MaterialXGenShader/Shader.h>
#include <MaterialXRender/LightHandler.h>

#include <MaterialXGenOgsFx/MayaGlslPluginShaderGenerator.h>

Expand Down
2 changes: 2 additions & 0 deletions source/PyMaterialX/PyMaterialXGenShader/PyShaderPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ void bindPyShaderPort(py::module& mod)
.def("getPath", &mx::ShaderPort::getPath)
.def("setUnit", &mx::ShaderPort::setUnit)
.def("getUnit", &mx::ShaderPort::getUnit)
.def("setColorSpace", &mx::ShaderPort::setColorSpace)
.def("getColorSpace", &mx::ShaderPort::getColorSpace)
.def("isUniform", &mx::ShaderPort::isUniform)
.def("isEmitted", &mx::ShaderPort::isEmitted);
}

0 comments on commit c52c013

Please sign in to comment.