diff --git a/.travis.yml b/.travis.yml
index 2d2e00abac..e1de52f382 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,7 +14,7 @@ addons:
- libxi-dev
- libx11-dev
- g++-6
- - g++-8
+ - g++-9
- clang-8
matrix:
@@ -47,7 +47,7 @@ matrix:
env: MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- os: linux
compiler: gcc
- env: MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
+ env: MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
- os: linux
compiler: clang
env: MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a124543427..24f81b61ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,26 @@
# Change Log
-## [1.36.4] - Development
+## [1.36.5] - Development
+
+## [1.36.4] - 2019-09-26
### Added
-- Added support for Clang 8.
+- Added a Save Material option to the viewer.
+- Added property accessors to PropertyAssign and PropertySetAssign
+- Added Python bindings for TypeDesc and array-type Values.
+- Added Python functions getTypeString, getValueString, and createValueFromStrings.
+- Added support for GCC 9 and Clang 8.
+
+### Changed
+- Updated the interface of readFromXmlFile and writeToXmlFile to support FilePath and FileSearchPath arguments.
+- Extended Python bindings for FilePath and FileSearchPath.
+
+### Removed
+- Deprecated Python functions typeToName, valueToString, and stringToValue.
+- Removed deprecated Python functions objectToString and stringToObject.
+
+### Fixed
+- Fixed the OSL implementation of roughness_dual.
## [1.36.3] - 2019-08-02
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2782ba9fb..b0792d2fa0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,18 +1,16 @@
project(MaterialX)
set(MATERIALX_MAJOR_VERSION 1)
set(MATERIALX_MINOR_VERSION 36)
-set(MATERIALX_BUILD_VERSION 4)
+set(MATERIALX_BUILD_VERSION 5)
set(MATERIALX_LIBRARY_VERSION ${MATERIALX_MAJOR_VERSION}.${MATERIALX_MINOR_VERSION}.${MATERIALX_BUILD_VERSION})
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_MACOSX_RPATH ON)
-include(CheckCXXCompilerFlag)
-include(CMakeDependentOption)
enable_testing()
-option(MATERIALX_BUILD_PYTHON "Build the MaterialX Python package from C++ bindings. Requires Python 2.6 or greater." OFF)
+option(MATERIALX_BUILD_PYTHON "Build the MaterialX Python package from C++ bindings. Requires Python 2.7 or greater." OFF)
option(MATERIALX_BUILD_VIEWER "Build the MaterialX Viewer." ON)
option(MATERIALX_BUILD_DOCS "Create HTML documentation using Doxygen. Requires that Doxygen be installed." OFF)
option(MATERIALX_PYTHON_LTO "Enable link-time optimizations for MaterialX Python." ON)
@@ -109,22 +107,26 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7")
endif()
else()
- add_compile_options(-Wall -Wno-missing-braces -Wno-unused-function)
- if(APPLE)
- add_compile_options(-Wno-deprecated-declarations)
- endif()
+ add_compile_options(-Wall -Wno-missing-braces)
if(MATERIALX_WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
- if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
- add_compile_options(-Wno-deprecated-register)
- CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template UNDEFINED_VAR_TEMPLATE_FLAG)
- if(UNDEFINED_VAR_TEMPLATE_FLAG)
- add_compile_options(-Wno-undefined-var-template)
- endif()
- endif()
endif()
+# Shared functions
+function(assign_source_group prefix)
+ foreach(_source IN ITEMS ${ARGN})
+ if(IS_ABSOLUTE "${_source}")
+ file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
+ else()
+ set(_source_rel "${_source}")
+ endif()
+ get_filename_component(_source_path "${_source_rel}" PATH)
+ string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
+ source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
+ endforeach()
+endfunction(assign_source_group)
+
# Add core subdirectories
add_subdirectory(source/MaterialXCore)
add_subdirectory(source/MaterialXFormat)
@@ -202,6 +204,6 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.2")
endif()
endif()
-# install MaterialX find_package module
+# Install MaterialX find_package module
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
- DESTINATION "${CMAKE_INSTALL_PREFIX}" MESSAGE_NEVER)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}" MESSAGE_NEVER)
diff --git a/documents/DeveloperGuide/ShaderGeneration.md b/documents/DeveloperGuide/ShaderGeneration.md
index 1f4dfe7cda..ecbad0aec1 100644
--- a/documents/DeveloperGuide/ShaderGeneration.md
+++ b/documents/DeveloperGuide/ShaderGeneration.md
@@ -91,7 +91,7 @@ For nodes that can’t be implemented by inline expressions a function definitio
-
+
// Implementation element
diff --git a/documents/DeveloperGuide/Viewer.md b/documents/DeveloperGuide/Viewer.md
index 1dc679b6e5..f974a0e2f0 100644
--- a/documents/DeveloperGuide/Viewer.md
+++ b/documents/DeveloperGuide/Viewer.md
@@ -1,6 +1,6 @@
# MaterialX Viewer
-The MaterialX Viewer leverages shader generation to build GLSL shaders from MaterialX graphs, rendering the results using the NanoGUI framework. Both the standard set of MaterialX nodes and the PBR node set are supported.
+The MaterialX Viewer leverages shader generation to build GLSL shaders from MaterialX graphs, rendering the results using the NanoGUI framework. The standard set of pattern and physically-based shading nodes is supported, and libraries of custom nodes can be included as additional library paths.
### Example Images
@@ -15,26 +15,27 @@ Select the `MATERIALX_BUILD_VIEWER` option to build the MaterialX Viewer. Insta
### Summary of Viewer Options
-1. **Load Mesh**: Load in geometry for viewing. There is currently support for OBJ file loading.
-2. **Load Material**: Load in a MaterialX document containing elements to render.
-3. **Property Editor**: View or edit the properties for the current element selected.
-4. **Advanced Settings** : Loading and fidelity options.
+1. **Load Mesh**: Load a new model for viewing.
+2. **Load Material**: Load a MaterialX document containing materials to render.
+3. **Save Material**: Save the current material.
+4. **Property Editor**: View or edit properties of the current material.
+5. **Advanced Settings** : Asset and rendering options.
### Geometry
-Upon launching MaterialXView, a teapot model is automatically loaded.
-To change this preview geometry, click `Load Mesh` and navigate to `/resources/Geometry` for a list of available models.
+Upon launching MaterialXView, a shader ball model is automatically loaded.
+To change this geometry, click `Load Mesh` and navigate to the [Geometry](../../resources/Geometry) folder for a list of available models.
-Currently, files using the OBJ file format are supported. If a file contains more than one `group`, then a `Select Geometry` option is available which lists the available groups. One group is chosen as the current *active* group. To change the *active* group, click the `Select Geometry` list to choose from a list of available groups.
+Currently, files using the OBJ file format are supported. If a file contains more than one `group`, then a `Select Geometry` option is available which lists the available groups. One group is chosen as the current *active* group. To change the active group, click the `Select Geometry` list to choose from a list of available groups.
Under `Advanced Settings` it is possible to have a wireframe overlay displayed for the active group by choosing `Outline Selected Geometry`.
### Materials
To experiment with different materials, click `Load Material`. Navigate to
-`resources/Materials/Examples/StandardSurface` for a selection of `.mtlx` files.
+the [Materials/Examples/StandardSurface](../../resources/Materials/Examples/StandardSurface) or [Materials/Examples/UsdPreviewSurface](../../resources/Materials/Examples/UsdPreviewSurface) folders for selections of renderable materials.
-To adjust the attributes on the materials, click `Property Editor` to show or hide the material properties. Note that this changes the generated shader inputs and not the original MaterialX document.
+To adjust the attributes on the materials, click `Property Editor` to show or hide the material properties. An edited material may be saved to the file system with the `Save Material` option.
Multiple materials can be loaded using the following options:
@@ -47,12 +48,12 @@ If more than one material has been loaded they will be listed in a pop-up menu u
To assign a renderable item to either an existing group or the entire object, click on the pop-up menu to switch among (between) the available materials. Alternatively the `LEFT` and `RIGHT` arrows can be used to cycle through the list.
-Note: Once you have loaded a material, it remains in the list even after you disable `Add Materials`.
-To clear the entries, disable `Add Materials` and load in a new `.mtlx` file. The list will be refreshed to include only the renderable items from that document.
+Note: Once you have loaded a material, it remains in the list even after you disable `Merge Materials`.
+To clear the entries, disable `Merge Materials` and load in a new `.mtlx` file. The list will be refreshed to include only the renderable items from that document.
### Looks
-Assignment of materials to geometry can be performed by loading a MaterialX document which contains one or more looks (e.g. `resources\Materials\Examples\StandardSurface\standard_surface_look_brass_tiled.mtlx`). If the geometry string referenced by a look matches the name of a group in the current mesh, then the given material assignment will be applied to that mesh group.
+Assignment of materials to geometry can be performed by loading a MaterialX document which contains look elements (e.g. [Materials/Examples/StandardSurface/standard_surface_look_brass_tiled](../../resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx)). If the geometry string referenced by a look matches the name of a group in the current mesh, then the material assignment will be applied to that mesh group.
### Lighting
@@ -62,7 +63,7 @@ To improve the indirect lighting highlights on your material, increase the `Adva
### Keyboard Shortcuts
-- `R`: Reload the current document from file.
+- `R`: Reload the current material from file.
- `S`: Save the current shader source to file.
- `L`: Load shader source from file. Editing the source files before loading provides a way to debug and experiment with shader source code.
- `D`: Save each node graph in the current material as a DOT file. See www.graphviz.org for more details on this format.
diff --git a/python/MaterialX/datatype.py b/python/MaterialX/datatype.py
index 02fe0460fc..13b2044419 100644
--- a/python/MaterialX/datatype.py
+++ b/python/MaterialX/datatype.py
@@ -5,67 +5,59 @@
# Native Python helper functions for MaterialX data types.
#--------------------------------------------------------------------------------
-_nameToType = { 'integer' : int,
- 'float' : float,
- 'boolean' : bool,
- 'color2' : Color2,
- 'color3' : Color3,
- 'color4' : Color4,
- 'vector2' : Vector2,
- 'vector3' : Vector3,
- 'vector4' : Vector4,
- 'matrix33' : Matrix33,
- 'matrix44' : Matrix44,
- 'string' : str }
-_typeToName = dict(reversed(i) for i in _nameToType.items())
-
-_integerTypeAliases = [long] if sys.version_info[0] < 3 else []
-_stringTypeAliases = [unicode] if sys.version_info[0] < 3 else [bytes]
-_typeToName.update(dict.fromkeys(_integerTypeAliases, 'integer'))
-_typeToName.update(dict.fromkeys(_stringTypeAliases, 'string'))
+_typeToName = { int : 'integer',
+ float : 'float',
+ bool : 'boolean',
+ Color2 : 'color2',
+ Color3 : 'color3',
+ Color4 : 'color4',
+ Vector2 : 'vector2',
+ Vector3 : 'vector3',
+ Vector4 : 'vector4',
+ Matrix33 : 'matrix33',
+ Matrix44 : 'matrix44',
+ str : 'string' }
+
+if sys.version_info[0] < 3:
+ _typeToName[long] = 'integer'
+ _typeToName[unicode] = 'string'
+else:
+ _typeToName[bytes] = 'string'
#--------------------------------------------------------------------------------
-def typeToName(t):
- """Return the MaterialX type string associated with the given Python type
- If the given Python type is not recognized by MaterialX, then None is
- returned.
+def getTypeString(value):
+ """Return the MaterialX type string associated with the given Python value
+ If the type of the given Python value is not recognized by MaterialX,
+ then None is returned.
Examples:
- typeToName(int) -> 'integer'
- typeToName(mx.Color3) -> 'color3'"""
-
- if t in _typeToName:
- return _typeToName[t]
+ getTypeString(1.0) -> 'float'
+ getTypeString(mx.Color3(1)) -> 'color3'"""
+
+ valueType = type(value)
+ if valueType in _typeToName:
+ return _typeToName[valueType]
+ if valueType in (tuple, list):
+ if len(value):
+ elemType = type(value[0])
+ if elemType in _typeToName:
+ return _typeToName[elemType] + 'array'
+ return 'stringarray'
return None
#--------------------------------------------------------------------------------
-def nameToType(name):
- """Return the Python type associated with the given MaterialX type string.
- If the given type string is not recognized by MaterialX, then the Python
- str type is returned.
+def getValueString(value):
+ """Return the MaterialX value string associated with the given Python value
+ If the type of the given Python value is not recognized by MaterialX,
+ then None is returned
Examples:
- nameToType('integer') -> int
- nameToType('color3') -> mx.Color3"""
-
- if name in _nameToType:
- return _nameToType[name]
- return str
-
-
-#--------------------------------------------------------------------------------
-def valueToString(value):
- """Convert a Python value of any supported type to its correponding
- MaterialX value string. If the Python type of the value is not
- recognized by MaterialX, then None is returned.
+ getValueString(0.1) -> '0.1'
+ getValueString(mx.Color3(0.1, 0.2, 0.3)) -> '0.1, 0.2, 0.3'"""
- Examples:
- valueToString(0.1) -> '0.1'
- valueToString(mx.Color3(0.1, 0.2, 0.3)) -> '0.1, 0.2, 0.3'"""
-
- typeString = typeToName(type(value))
+ typeString = getTypeString(value)
if not typeString:
return None
method = globals()['TypedValue_' + typeString].createValue
@@ -73,19 +65,16 @@ def valueToString(value):
#--------------------------------------------------------------------------------
-def stringToValue(string, t):
- """Convert a MaterialX value string and Python type to the corresponding
+def createValueFromStrings(valueString, typeString):
+ """Convert a MaterialX value and type strings to the corresponding
Python value. If the given conversion cannot be performed, then None
is returned.
Examples:
- stringToValue('0.1', float) -> 0.1
- stringToValue('0.1, 0.2, 0.3', mx.Color3) -> mx.Color3(0.1, 0.2, 0.3)"""
+ createValueFromStrings('0.1', 'float') -> 0.1
+ createValueFromStrings('0.1, 0.2, 0.3', 'color3') -> mx.Color3(0.1, 0.2, 0.3)"""
- typeString = typeToName(t)
- if not typeString:
- return None
- valueObj = Value.createValueFromStrings(string, typeString)
+ valueObj = Value.createValueFromStrings(valueString, typeString)
if not valueObj:
return None
return valueObj.getData()
diff --git a/python/MaterialX/main.py b/python/MaterialX/main.py
index 152ee4d981..8466082402 100644
--- a/python/MaterialX/main.py
+++ b/python/MaterialX/main.py
@@ -65,7 +65,7 @@ def _removeChildOfType(self, elementClass, name):
def _setValue(self, value, typeString = ''):
"Set the typed value of an element."
- method = getattr(self.__class__, "_setValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setValue" + getTypeString(value))
method(self, value, typeString)
def _getValue(self):
@@ -98,7 +98,7 @@ def _getDefaultValue(self):
def _setParameterValue(self, name, value, typeString = ''):
"""Set the typed value of a parameter by its name, creating a child element
to hold the parameter if needed."""
- method = getattr(self.__class__, "_setParameterValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setParameterValue" + getTypeString(value))
return method(self, name, value, typeString)
def _getParameterValue(self, name, target = ''):
@@ -118,7 +118,7 @@ def _getParameterValueString(self, name):
def _setInputValue(self, name, value, typeString = ''):
"""Set the typed value of an input by its name, creating a child element
to hold the input if needed."""
- method = getattr(self.__class__, "_setInputValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setInputValue" + getTypeString(value))
return method(self, name, value, typeString)
def _getInputValue(self, name, target = ''):
@@ -169,7 +169,7 @@ def _addOverride(self, name):
def _setOverrideValue(self, name, value, typeString = ''):
"""Set the value of an override by its name, creating a child element
to hold the override if needed."""
- method = getattr(self.__class__, "_setOverrideValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setOverrideValue" + getTypeString(value))
return method(self, name, value, typeString)
def _addShaderRef(self, name = '', node = ''):
@@ -212,7 +212,7 @@ def _getReferencedShaderDef(self):
def _setPropertyValue(self, name, value, typeString = ''):
"""Set the typed value of a property by its name, creating a child element
to hold the property if needed."""
- method = getattr(self.__class__, "_setPropertyValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setPropertyValue" + getTypeString(value))
return method(self, name, value, typeString)
def _getPropertyValue(self, name, target = ''):
@@ -236,7 +236,7 @@ def _addGeomAttr(self, name):
def _setGeomAttrValue(self, name, value, typeString = ''):
"""Set the value of a geomattr by its name, creating a child element
to hold the geomattr if needed."""
- method = getattr(self.__class__, "_setGeomAttrValue" + typeToName(value.__class__))
+ method = getattr(self.__class__, "_setGeomAttrValue" + getTypeString(value))
return method(self, name, value, typeString)
GeomInfo.addGeomAttr = _addGeomAttr
@@ -266,18 +266,24 @@ def _generateRequireString(self):
# Value
#
-def _objectToString(value):
- "(Deprecated) Convert a value of MaterialX type to a string."
- warnings.warn("This function is deprecated; call valueToString instead.", DeprecationWarning, stacklevel = 2)
- return valueToString(value)
+def _typeToName(t):
+ "(Deprecated) Return the MaterialX type string associated with the given Python type."
+ warnings.warn("This function is deprecated; call MaterialX.getTypeString instead.", DeprecationWarning, stacklevel = 2)
+ return getTypeString(t())
-def _stringToObject(string, t):
- "(Deprecated) Convert a string to a value of MaterialX type."
- warnings.warn("This function is deprecated; call stringToValue instead.", DeprecationWarning, stacklevel = 2)
- return stringToValue(string, t)
+def _valueToString(value):
+ "(Deprecated) Convert a Python value to its correponding MaterialX value string."
+ warnings.warn("This function is deprecated; call MaterialX.getValueString instead.", DeprecationWarning, stacklevel = 2)
+ return getValueString(value)
-objectToString = _objectToString
-stringToObject = _stringToObject
+def _stringToValue(string, t):
+ "(Deprecated) Convert a MaterialX value string and Python type to the corresponding Python value."
+ warnings.warn("This function is deprecated; call MaterialX.createValueFromStrings instead.", DeprecationWarning, stacklevel = 2)
+ return createValueFromStrings(string, getTypeString(t()))
+
+typeToName = _typeToName
+valueToString = _valueToString
+stringToValue = _stringToValue
#
diff --git a/python/MaterialXTest/genshader.py b/python/MaterialXTest/genshader.py
index 87f4241b17..58a1917de4 100644
--- a/python/MaterialXTest/genshader.py
+++ b/python/MaterialXTest/genshader.py
@@ -74,9 +74,9 @@ def test_ShaderInterface(self):
shadergen = OslShaderGenerator.create()
context = GenContext(shadergen)
# Add path to find all source code snippets
- context.registerSourceCodeSearchPath(mx.FilePath(searchPath))
+ context.registerSourceCodeSearchPath(searchPath)
# Add path to find OSL include files
- context.registerSourceCodeSearchPath(mx.FilePath(os.path.join(searchPath, "stdlib/osl")))
+ context.registerSourceCodeSearchPath(os.path.join(searchPath, "stdlib/osl"))
# Test complete mode
context.getOptions().shaderInterfaceType = int(ShaderInterfaceType.SHADER_INTERFACE_COMPLETE);
diff --git a/python/MaterialXTest/main.py b/python/MaterialXTest/main.py
index 94abc24876..eb4ce4a162 100644
--- a/python/MaterialXTest/main.py
+++ b/python/MaterialXTest/main.py
@@ -18,7 +18,11 @@
mx.Vector4(1.0, 2.0, 3.0, 4.0),
mx.Matrix33(0.0),
mx.Matrix44(1.0),
- 'value')
+ 'value',
+ [1, 2, 3],
+ [False, True, False],
+ [1.0, 2.0, 3.0],
+ ['one', 'two', 'three'])
_fileDir = os.path.dirname(os.path.abspath(__file__))
_libraryDir = os.path.join(_fileDir, '../../libraries/stdlib/')
@@ -43,15 +47,11 @@
class TestMaterialX(unittest.TestCase):
def test_DataTypes(self):
for value in _testValues:
- # Convert between values and strings.
- string = mx.valueToString(value)
- newValue = mx.stringToValue(string, type(value))
+ valueString = mx.getValueString(value)
+ typeString = mx.getTypeString(value)
+ newValue = mx.createValueFromStrings(valueString, typeString)
self.assertTrue(newValue == value)
-
- # Convert between types and strings.
- string = mx.typeToName(type(value))
- newType = mx.nameToType(string)
- self.assertTrue(newType == type(value))
+ self.assertTrue(mx.getTypeString(newValue) == typeString)
def test_Vectors(self):
v1 = mx.Vector3(1, 2, 3)
@@ -292,9 +292,11 @@ def test_BuildDocument(self):
self.assertTrue(len(material.getGeometryBindings("/robot2/left_arm")) == 0)
# Create a property assignment.
- propertyAssign = look.addPropertyAssign("twosided")
+ propertyAssign = look.addPropertyAssign()
+ propertyAssign.setProperty("twosided")
propertyAssign.setGeom("/robot1")
propertyAssign.setValue(True)
+ self.assertTrue(propertyAssign.getProperty() == "twosided")
self.assertTrue(propertyAssign.getGeom() == "/robot1")
self.assertTrue(propertyAssign.getValue() == True)
@@ -302,8 +304,10 @@ def test_BuildDocument(self):
propertySet = doc.addPropertySet()
propertySet.setPropertyValue('matte', False)
self.assertTrue(propertySet.getPropertyValue('matte') == False)
- propertySetAssign = look.addPropertySetAssign(propertySet.getName())
+ propertySetAssign = look.addPropertySetAssign()
+ propertySetAssign.setPropertySet(propertySet)
propertySetAssign.setGeom('/robot1')
+ self.assertTrue(propertySetAssign.getPropertySet() == propertySet)
self.assertTrue(propertySetAssign.getGeom() == '/robot1')
# Create a variant set.
diff --git a/python/Scripts/nodedef_documentation.md b/python/Scripts/nodedef_documentation.md
new file mode 100644
index 0000000000..e597046fee
--- /dev/null
+++ b/python/Scripts/nodedef_documentation.md
@@ -0,0 +1,48 @@
+- *Nodedef*: ND_standard_surface_surfaceshader
+- *Type*: surfaceshader
+- *Doc*: Autodesk standard surface shader
+
+| Name | Type | Default Value | UI min | UI max | UI group | Description | UI Advanced | Connectable |
+| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
+| base | float | 0.800000011921 | 0.0 | 1.0 | Base | Multiplier on the intensity of the diffuse reflection. | | true |
+| base_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Base | Color of the diffuse reflection. | | true |
+| diffuse_roughness | float | 0.0 | 0.0 | 1.0 | Base | Roughness of the diffuse reflection. Higher values cause the surface to appear flatter and darker. | true | true |
+| metalness | float | 0.0 | 0.0 | 1.0 | Base | Specifies how metallic the material appears. At its maximum, the surface behaves like a metal, using fully specular reflection and complex fresnel. | | true |
+| specular | float | 1.0 | 0.0 | 1.0 | Specular | Multiplier on the intensity of the specular reflection. | | true |
+| specular_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Specular | Color tint on the specular reflection. | | true |
+| specular_roughness | float | 0.20000000298 | 0.0 | 1.0 | Specular | The roughness of the specular reflection. Lower numbers produce sharper reflections, higher numbers produce blurrier reflections. | | true |
+| specular_IOR | float | 1.5 | 0.0 | 3.0 | Specular | Index of refraction for specular reflection. | | true |
+| specular_anisotropy | float | 0.0 | 0.0 | 1.0 | Specular | The directional bias of reflected and transmitted light resulting in materials appearing rougher or glossier in certain directions. | true | true |
+| specular_rotation | float | 0.0 | 0.0 | 1.0 | Specular | Rotation of the axis of specular anisotropy around the surface normal. | true | true |
+| transmission | float | 0.0 | 0.0 | 1.0 | Transmission | Transmission of light through the surface for materials such as glass or water. The greater the value the more transparent the material. | true | true |
+| transmission_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Transmission | Color tint on the transmitted light. | true | true |
+| transmission_depth | float | 0.0 | 0.0 | 100.0 | Transmission | Specifies the distance light travels inside the material before its becomes exactly the transmission color according to Beer's law. | true | true |
+| transmission_scatter | color3 | 0, 0, 0 | 0,0,0 | 1,1,1 | Transmission | Scattering coefficient of the interior medium. Suitable for a large body of liquid or one that is fairly thick, such as an ocean, honey, ice, or frosted glass. | true | true |
+| transmission_scatter_anisotropy | float | 0.0 | 0.0 | 1.0 | Transmission | The amount of directional bias, or anisotropy, of the scattering. | true | true |
+| transmission_dispersion | float | 0.0 | 0.0 | 100.0 | Transmission | Dispersion amount, describing how much the index of refraction varies across wavelengths. | true | true |
+| transmission_extra_roughness | float | 0.0 | 0.0 | 1.0 | Transmission | Additional roughness on top of specular roughness. Positive values blur refractions more than reflections, and negative values blur refractions less. | true | true |
+| subsurface | float | 0.0 | 0.0 | 1.0 | Subsurface | The blend between diffuse reflection and subsurface scattering. A value of 1.0 indicates full subsurface scattering and a value 0 for diffuse reflection only. | true | true |
+| subsurface_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Subsurface | The color of the subsurface scattering effect. | true | true |
+| subsurface_radius | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Subsurface | The mean free path. The distance which light can travel before being scattered inside the surface. | true | true |
+| subsurface_scale | float | 1.0 | 0.0 | 10.0 | Subsurface | Scalar weight for the subsurface radius value. | true | true |
+| subsurface_anisotropy | float | 0.0 | 0.0 | 1.0 | Subsurface | The direction of subsurface scattering. 0 scatters light evenly, positive values scatter forward and negative values scatter backward. | true | true |
+| sheen | float | 0.0 | 0.0 | 1.0 | Sheen | The weight of a sheen layer that can be used to approximate microfibers or fabrics such as velvet and satin. | true | true |
+| sheen_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Sheen | The color of the sheen layer. | true | true |
+| sheen_roughness | float | 0.300000011921 | 0.0 | 1.0 | Sheen | The roughness of the sheen layer. | true | true |
+| coat | float | 0.0 | 0.0 | 1.0 | Coat | The weight of a reflective clear-coat layer on top of the material. Use for materials such as car paint or an oily layer. | | true |
+| coat_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Coat | The color of the clear-coat layer's transparency. | | true |
+| coat_roughness | float | 0.10000000149 | 0.0 | 1.0 | Coat | The roughness of the clear-coat reflections. The lower the value, the sharper the reflection. | | true |
+| coat_anisotropy | float | 0.0 | 0.0 | 1.0 | Coat | The amount of directional bias, or anisotropy, of the clear-coat layer. | true | true |
+| coat_rotation | float | 0.0 | 0.0 | 1.0 | Coat | The rotation of the anisotropic effect of the clear-coat layer. | true | true |
+| coat_IOR | float | 1.5 | 0.0 | 3.0 | Coat | The index of refraction of the clear-coat layer. | | true |
+| coat_normal | vector3 | None | 0,0,0 | 1,1,1 | Coat | Input normal for clear-coat layer | | true |
+| coat_affect_color | float | 0.0 | 0,0,0 | 1,1,1 | Coat | Controls the saturation of diffuse reflection and subsurface scattering below the clear-coat. | true | true |
+| coat_affect_roughness | float | 0.0 | | | Coat | Controls the roughness of the specular reflection in the layers below the clear-coat. | true | true |
+| thin_film_thickness | float | 0.0 | 0.0 | 2000.0 | Thin Film | The thickness of the thin film layer on a surface. Use for materials such as multitone car paint or soap bubbles. | true | true |
+| thin_film_IOR | float | 1.5 | 0.0 | 3.0 | Thin Film | The index of refraction of the medium surrounding the material. | true | true |
+| emission | float | 0.0 | 0.0 | 1.0 | Emission | The amount of emitted incandescent light. | | true |
+| emission_color | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Emission | The color of the emitted light. | | true |
+| opacity | color3 | 1, 1, 1 | 0,0,0 | 1,1,1 | Geometry | The opacity of the entire material. | | true |
+| thin_walled | boolean | False | | | Geometry | If tue the surface is double-sided and represents an infinitely thin shell. Suiteable for thin objects such as tree leafs or paper | true | true |
+| normal | vector3 | None | | | Geometry | Input geometric normal | | true |
+| tangent | vector3 | None | | | Geometry | Input geometric tangent | | true |
diff --git a/source/MaterialXCore/CMakeLists.txt b/source/MaterialXCore/CMakeLists.txt
index e671731ef0..428f32a892 100644
--- a/source/MaterialXCore/CMakeLists.txt
+++ b/source/MaterialXCore/CMakeLists.txt
@@ -1,10 +1,9 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
add_library(MaterialXCore STATIC ${materialx_source} ${materialx_headers})
@@ -22,15 +21,13 @@ set_target_properties(
target_link_libraries(
MaterialXCore
- ${CMAKE_DL_LIBS}
-)
+ ${CMAKE_DL_LIBS})
install(TARGETS MaterialXCore
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(FILES ${materialx_headers}
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXCore/)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXCore/)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXCore.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
\ No newline at end of file
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXCore/Element.cpp b/source/MaterialXCore/Element.cpp
index cb6bd77601..2707135dad 100644
--- a/source/MaterialXCore/Element.cpp
+++ b/source/MaterialXCore/Element.cpp
@@ -463,7 +463,6 @@ bool Element::validate(string* message) const
res = child->validate(message) && res;
}
validateRequire(!hasInheritanceCycle(), res, message, "Cycle in element inheritance chain");
-
return res;
}
diff --git a/source/MaterialXCore/Look.cpp b/source/MaterialXCore/Look.cpp
index 3612a6662f..3469491330 100644
--- a/source/MaterialXCore/Look.cpp
+++ b/source/MaterialXCore/Look.cpp
@@ -16,21 +16,6 @@ const string Visibility::VIEWER_COLLECTION_ATTRIBUTE = "viewercollection";
const string Visibility::VISIBILITY_TYPE_ATTRIBUTE = "vistype";
const string Visibility::VISIBLE_ATTRIBUTE = "visible";
-//
-// MaterialAssign methods
-//
-
-vector MaterialAssign::getActiveVariantAssigns() const
-{
- vector activeAssigns;
- for (ConstElementPtr elem : traverseInheritance())
- {
- vector assigns = elem->asA()->getVariantAssigns();
- activeAssigns.insert(activeAssigns.end(), assigns.begin(), assigns.end());
- }
- return activeAssigns;
-}
-
//
// Look methods
//
@@ -109,4 +94,15 @@ MaterialPtr MaterialAssign::getReferencedMaterial() const
return resolveRootNameReference(getMaterial());
}
+vector MaterialAssign::getActiveVariantAssigns() const
+{
+ vector activeAssigns;
+ for (ConstElementPtr elem : traverseInheritance())
+ {
+ vector assigns = elem->asA()->getVariantAssigns();
+ activeAssigns.insert(activeAssigns.end(), assigns.begin(), assigns.end());
+ }
+ return activeAssigns;
+}
+
} // namespace MaterialX
diff --git a/source/MaterialXCore/Property.cpp b/source/MaterialXCore/Property.cpp
index d6040d6fa5..228f5745a3 100644
--- a/source/MaterialXCore/Property.cpp
+++ b/source/MaterialXCore/Property.cpp
@@ -10,8 +10,14 @@
namespace MaterialX
{
+const string PropertyAssign::PROPERTY_ATTRIBUTE = "property";
const string PropertyAssign::GEOM_ATTRIBUTE = "geom";
const string PropertyAssign::COLLECTION_ATTRIBUTE = "collection";
+const string PropertySetAssign::PROPERTY_SET_ATTRIBUTE = "propertyset";
+
+//
+// PropertyAssign methods
+//
void PropertyAssign::setCollection(ConstCollectionPtr collection)
{
@@ -30,4 +36,25 @@ CollectionPtr PropertyAssign::getCollection() const
return resolveRootNameReference(getCollectionString());
}
+//
+// PropertySetAssign methods
+//
+
+void PropertySetAssign::setPropertySet(ConstPropertySetPtr propertySet)
+{
+ if (propertySet)
+ {
+ setPropertySetString(propertySet->getName());
+ }
+ else
+ {
+ removeAttribute(PROPERTY_SET_ATTRIBUTE);
+ }
+}
+
+PropertySetPtr PropertySetAssign::getPropertySet() const
+{
+ return resolveRootNameReference(getPropertySetString());
+}
+
} // namespace MaterialX
diff --git a/source/MaterialXCore/Property.h b/source/MaterialXCore/Property.h
index 3c93ab7f1a..cd2705877f 100644
--- a/source/MaterialXCore/Property.h
+++ b/source/MaterialXCore/Property.h
@@ -67,6 +67,28 @@ class PropertyAssign : public ValueElement
}
virtual ~PropertyAssign() { }
+ /// @name Property
+ /// @{
+
+ /// Set the property string of this element.
+ void setProperty(const string& property)
+ {
+ setAttribute(PROPERTY_ATTRIBUTE, property);
+ }
+
+ /// Return true if this element has a property string.
+ bool hasProperty() const
+ {
+ return hasAttribute(PROPERTY_ATTRIBUTE);
+ }
+
+ /// Return the property string of this element.
+ const string& getProperty() const
+ {
+ return getAttribute(PROPERTY_ATTRIBUTE);
+ }
+
+ /// @}
/// @name Geometry
/// @{
@@ -120,6 +142,7 @@ class PropertyAssign : public ValueElement
public:
static const string CATEGORY;
+ static const string PROPERTY_ATTRIBUTE;
static const string GEOM_ATTRIBUTE;
static const string COLLECTION_ATTRIBUTE;
};
@@ -210,8 +233,38 @@ class PropertySetAssign : public GeomElement
}
virtual ~PropertySetAssign() { }
+ /// @name Property Set
+ /// @{
+
+ /// Set the property set string of this element.
+ void setPropertySetString(const string& propertySet)
+ {
+ setAttribute(PROPERTY_SET_ATTRIBUTE, propertySet);
+ }
+
+ /// Return true if this element has a property set string.
+ bool hasPropertySetString() const
+ {
+ return hasAttribute(PROPERTY_SET_ATTRIBUTE);
+ }
+
+ /// Return the property set string of this element.
+ const string& getPropertySetString() const
+ {
+ return getAttribute(PROPERTY_SET_ATTRIBUTE);
+ }
+
+ /// Assign a property set to this element.
+ void setPropertySet(ConstPropertySetPtr propertySet);
+
+ /// Return the property set that is assigned to this element.
+ PropertySetPtr getPropertySet() const;
+
+ /// @}
+
public:
static const string CATEGORY;
+ static const string PROPERTY_SET_ATTRIBUTE;
};
} // namespace MaterialX
diff --git a/source/MaterialXCore/Types.h b/source/MaterialXCore/Types.h
index 045d0f2057..81b2584738 100644
--- a/source/MaterialXCore/Types.h
+++ b/source/MaterialXCore/Types.h
@@ -345,7 +345,7 @@ template class MatrixN : public MatrixBase
/// Return true if the given matrix is equivalent to another
/// matrix within a given floating point tolerance
- bool isEquivalent(const M& rhs, S tolerance)
+ bool isEquivalent(const M& rhs, S tolerance) const
{
for (size_t i = 0; i < N; i++)
{
diff --git a/source/MaterialXCore/UnitConverter.cpp b/source/MaterialXCore/UnitConverter.cpp
index d520491cd2..f28c6d9eaf 100644
--- a/source/MaterialXCore/UnitConverter.cpp
+++ b/source/MaterialXCore/UnitConverter.cpp
@@ -3,19 +3,6 @@
// All rights reserved. See LICENSE.txt for license.
//
-/**
-* Copyright 2019 Autodesk, Inc.
-* All rights reserved.
-*
-* This computer source code and related instructions and comments are the unpublished confidential
-* and proprietary information of Autodesk, Inc. and are protected under Federal copyright and state
-* trade secret law. They may not be disclosed to, copied or used by any third party without the
-* prior written consent of Autodesk, Inc.
-*
-* @file Units.cpp
-* @brief Units support
-*/
-
#include
#include
#include
diff --git a/source/MaterialXCore/UnitConverter.h b/source/MaterialXCore/UnitConverter.h
index 29cb87fd3d..90a16d42d9 100644
--- a/source/MaterialXCore/UnitConverter.h
+++ b/source/MaterialXCore/UnitConverter.h
@@ -3,23 +3,12 @@
// All rights reserved. See LICENSE.txt for license.
//
-/**
-* Copyright 2019 Autodesk, Inc.
-* All rights reserved.
-*
-* This computer source code and related instructions and comments are the
-* unpublished confidential and proprietary information of Autodesk, Inc. and
-* are protected under Federal copyright and state trade secret law. They may
-* not be disclosed to, copied or used by any third party without the prior
-* written consent of Autodesk, Inc.
-*
-* @file UnitConverter.h
-* @brief Unit converter classes.
-*/
-
#ifndef MATERIALX_UNITCONVERTER_H_
#define MATERIALX_UNITCONVERTER_H_
+/// @file UnitConverter.h
+/// Unit converter classes.
+
#include
#include
diff --git a/source/MaterialXCore/Value.cpp b/source/MaterialXCore/Value.cpp
index 2da8f0e4d3..50436f358e 100644
--- a/source/MaterialXCore/Value.cpp
+++ b/source/MaterialXCore/Value.cpp
@@ -279,10 +279,6 @@ template class ValueRegistry
// Template instantiations
//
-using IntVec = vector;
-using BoolVec = vector;
-using FloatVec = vector;
-
#define INSTANTIATE_TYPE(T, name) \
template <> const string TypedValue::TYPE = name; \
template bool Value::isA() const; \
diff --git a/source/MaterialXCore/Value.h b/source/MaterialXCore/Value.h
index 17e5ea043e..3d120d4df8 100644
--- a/source/MaterialXCore/Value.h
+++ b/source/MaterialXCore/Value.h
@@ -17,6 +17,13 @@
namespace MaterialX
{
+/// A vector of integers.
+using IntVec = vector;
+/// A vector of booleans.
+using BoolVec = vector;
+/// A vector of floats.
+using FloatVec = vector;
+
class Value;
/// A shared pointer to a Value
@@ -185,7 +192,7 @@ template class TypedValue : public Value
class ScopedFloatFormatting
{
public:
- ScopedFloatFormatting(Value::FloatFormat format, int precision = 6);
+ explicit ScopedFloatFormatting(Value::FloatFormat format, int precision = 6);
~ScopedFloatFormatting();
private:
diff --git a/source/MaterialXFormat/CMakeLists.txt b/source/MaterialXFormat/CMakeLists.txt
index 45931560cb..4a47c2ef36 100644
--- a/source/MaterialXFormat/CMakeLists.txt
+++ b/source/MaterialXFormat/CMakeLists.txt
@@ -1,17 +1,14 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
-file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-file(GLOB pugixml_source "${CMAKE_CURRENT_SOURCE_DIR}/PugiXML/*.cpp")
-file(GLOB pugixml_headers "${CMAKE_CURRENT_SOURCE_DIR}/PugiXML/*.hpp")
+file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
-source_group("Source Files\\PugiXml" FILES ${pugixml_source})
-source_group("Header Files\\PugiXml" FILES ${pugixml_headers})
+assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXFormat STATIC ${materialx_source} ${materialx_headers} ${pugixml_source} ${pugixml_headers})
+add_library(MaterialXFormat STATIC ${materialx_source} ${materialx_headers})
set_target_properties(
MaterialXFormat PROPERTIES
@@ -24,15 +21,14 @@ set_target_properties(
target_link_libraries(
MaterialXFormat
MaterialXCore
- ${CMAKE_DL_LIBS}
-)
+ ${CMAKE_DL_LIBS})
install(TARGETS MaterialXFormat
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
-install(FILES ${materialx_headers}
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXFormat/)
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXFormat/ MESSAGE_NEVER
+ FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXFormat.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXFormat/File.cpp b/source/MaterialXFormat/File.cpp
index 612b29d021..42f861408f 100644
--- a/source/MaterialXFormat/File.cpp
+++ b/source/MaterialXFormat/File.cpp
@@ -17,9 +17,9 @@
#include
#endif
+#include
#include
#include
-#include
#include
namespace MaterialX
@@ -223,7 +223,7 @@ FilePathVec FilePath::getSubDirectories() const
return dirs;
}
-void FilePath::createDirectory()
+void FilePath::createDirectory() const
{
#if defined(_WIN32)
_mkdir(asString().c_str());
@@ -235,19 +235,19 @@ void FilePath::createDirectory()
FilePath FilePath::getCurrentPath()
{
#if defined(_WIN32)
- char buf[MAX_PATH];
- if (!GetCurrentDirectory(MAX_PATH, buf))
+ std::array buf;
+ if (!GetCurrentDirectory(MAX_PATH, buf.data()))
{
throw Exception("Error in getCurrentPath: " + std::to_string(GetLastError()));
}
- return FilePath(buf);
+ return FilePath(buf.data());
#else
- char buf[PATH_MAX];
- if (getcwd(buf, PATH_MAX) == NULL)
+ std::array buf;
+ if (getcwd(buf.data(), PATH_MAX) == NULL)
{
throw Exception("Error in getCurrentPath: " + string(strerror(errno)));
}
- return FilePath(buf);
+ return FilePath(buf.data());
#endif
}
diff --git a/source/MaterialXFormat/File.h b/source/MaterialXFormat/File.h
index 8f50fa06be..481921fdff 100644
--- a/source/MaterialXFormat/File.h
+++ b/source/MaterialXFormat/File.h
@@ -72,7 +72,7 @@ class FilePath
/// Construct a path from a C-style string.
FilePath(const char* str)
{
- assign(string(str));
+ assign(str ? string(str) : EMPTY_STRING);
}
/// Convert a path to a standard string.
@@ -101,7 +101,7 @@ class FilePath
/// Return the base name of the given path, with leading directory
/// information removed.
- string getBaseName() const
+ const string& getBaseName() const
{
if (isEmpty())
{
@@ -125,7 +125,7 @@ class FilePath
/// Return the file extension of the given path.
string getExtension() const
{
- string baseName = getBaseName();
+ const string& baseName = getBaseName();
size_t i = baseName.rfind('.');
return i != string::npos ? baseName.substr(i + 1) : EMPTY_STRING;
}
@@ -151,7 +151,7 @@ class FilePath
FilePathVec getSubDirectories() const;
/// Create a directory on the file system at the given path.
- void createDirectory();
+ void createDirectory() const;
/// @}
diff --git a/source/MaterialXFormat/XmlIo.cpp b/source/MaterialXFormat/XmlIo.cpp
index 0c033f815b..b9f88c0f2f 100644
--- a/source/MaterialXFormat/XmlIo.cpp
+++ b/source/MaterialXFormat/XmlIo.cpp
@@ -105,7 +105,14 @@ void elementToXml(ConstElementPtr elem, xml_node& xmlNode, const XmlWriteOptions
{
xml_node includeNode = xmlNode.append_child(XINCLUDE_TAG.c_str());
xml_attribute includeAttr = includeNode.append_attribute("href");
- includeAttr.set_value(sourceUri.c_str());
+ FilePath includePath(sourceUri);
+
+ // Write relative include paths in Posix format, and absolute
+ // include paths in native format.
+ FilePath::Format includeFormat = includePath.isAbsolute() ?
+ FilePath::FormatNative : FilePath::FormatPosix;
+ includeAttr.set_value(includePath.asString(includeFormat).c_str());
+
writtenSourceFiles.insert(sourceUri);
}
continue;
@@ -132,13 +139,11 @@ void xmlDocumentFromFile(xml_document& xmlDoc, FilePath filename, FileSearchPath
{
throw ExceptionFileMissing("Failed to open file for reading: " + filename.asString());
}
- else
- {
- string desc = result.description();
- string offset = std::to_string(result.offset);
- throw ExceptionParseError("XML parse error in file: " + filename.asString() +
- " (" + desc + " at character " + offset + ")");
- }
+
+ string desc = result.description();
+ string offset = std::to_string(result.offset);
+ throw ExceptionParseError("XML parse error in file: " + filename.asString() +
+ " (" + desc + " at character " + offset + ")");
}
}
diff --git a/source/MaterialXGenGlsl/CMakeLists.txt b/source/MaterialXGenGlsl/CMakeLists.txt
index 95ddbec801..a2f56e15ba 100644
--- a/source/MaterialXGenGlsl/CMakeLists.txt
+++ b/source/MaterialXGenGlsl/CMakeLists.txt
@@ -1,31 +1,14 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
+
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXGenGlsl STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXGenGlsl STATIC ${materialx_source} ${materialx_headers})
set_target_properties(
MaterialXGenGlsl PROPERTIES
@@ -42,12 +25,11 @@ target_link_libraries(
${CMAKE_DL_LIBS})
install(TARGETS MaterialXGenGlsl
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXGenGlsl/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenGlsl.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXGenGlsl/Nodes/BitangentNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/BitangentNodeGlsl.h
index d78c144d2d..697892b58f 100644
--- a/source/MaterialXGenGlsl/Nodes/BitangentNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/BitangentNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'bitangent' node for GLSL
+/// Bitangent node implementation for GLSL
class BitangentNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/FrameNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/FrameNodeGlsl.h
index ce7693fd87..8e98c13afe 100644
--- a/source/MaterialXGenGlsl/Nodes/FrameNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/FrameNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of frame node for GLSL
+/// Frame node implementation for GLSL
class FrameNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/GeomAttrValueNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/GeomAttrValueNodeGlsl.h
index 953633f562..4fd6ab1627 100644
--- a/source/MaterialXGenGlsl/Nodes/GeomAttrValueNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/GeomAttrValueNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'geomattrvalue' node for GLSL
+/// GeomAttrValue node implementation for GLSL
class GeomAttrValueNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/GeomColorNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/GeomColorNodeGlsl.h
index 2e74af2184..febbdf806c 100644
--- a/source/MaterialXGenGlsl/Nodes/GeomColorNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/GeomColorNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'geomcolor' node for GLSL
+/// GeomColor node implementation for GLSL
class GeomColorNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.h
index 4b871bbd7e..30e0248a4a 100644
--- a/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of height-field to normal for GLSL
+/// HeightToNormal node implementation for GLSL
class HeightToNormalNodeGlsl : public ConvolutionNode
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/LightCompoundNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/LightCompoundNodeGlsl.h
index 7c904c0688..51d50b1673 100644
--- a/source/MaterialXGenGlsl/Nodes/LightCompoundNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/LightCompoundNodeGlsl.h
@@ -15,7 +15,7 @@ namespace MaterialX
class GlslShaderGenerator;
-/// Implementation of 'light' node for GLSL
+/// LightCompound node implementation for GLSL
class LightCompoundNodeGlsl : public CompoundNode
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.h
index 520587339f..ff81530596 100644
--- a/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'light' node for GLSL
+/// Light node implementation for GLSL
class LightNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/LightShaderNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/LightShaderNodeGlsl.h
index 00dc5b0560..40a540ec50 100644
--- a/source/MaterialXGenGlsl/Nodes/LightShaderNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/LightShaderNodeGlsl.h
@@ -12,7 +12,7 @@
namespace MaterialX
{
-/// Implementation of light shaders for GLSL.
+/// LightShader node implementation for GLSL
/// Used for all light shaders implemented in source code.
class LightShaderNodeGlsl : public SourceCodeNode
{
diff --git a/source/MaterialXGenGlsl/Nodes/NormalNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/NormalNodeGlsl.h
index 0cafb737fb..4cc46ed4a2 100644
--- a/source/MaterialXGenGlsl/Nodes/NormalNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/NormalNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'normal' node for GLSL
+/// Normal node implementation for GLSL
class NormalNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/PositionNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/PositionNodeGlsl.h
index ee45c73296..0417dfcba4 100644
--- a/source/MaterialXGenGlsl/Nodes/PositionNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/PositionNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'position' node for GLSL
+/// Position node implementation for GLSL
class PositionNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/SurfaceNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/SurfaceNodeGlsl.h
index 7c38de18ba..cf15bed401 100644
--- a/source/MaterialXGenGlsl/Nodes/SurfaceNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/SurfaceNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'surface' node for GLSL
+/// Surface node implementation for GLSL
class SurfaceNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/SurfaceShaderNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/SurfaceShaderNodeGlsl.h
index 22e91a4de8..85b5b6fd3c 100644
--- a/source/MaterialXGenGlsl/Nodes/SurfaceShaderNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/SurfaceShaderNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of surface shaders for GLSL.
+/// SurfaceShader node implementation for GLSL
/// Used for all surface shaders implemented in source code.
class SurfaceShaderNodeGlsl : public SourceCodeNode
{
diff --git a/source/MaterialXGenGlsl/Nodes/TangentNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TangentNodeGlsl.h
index 3b116aa67c..18738ab402 100644
--- a/source/MaterialXGenGlsl/Nodes/TangentNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TangentNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'tangent' node for GLSL
+/// Tangent node implementation for GLSL
class TangentNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/TexCoordNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TexCoordNodeGlsl.h
index 4f8a309532..f8a0cb5739 100644
--- a/source/MaterialXGenGlsl/Nodes/TexCoordNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TexCoordNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of 'texcoord' node for GLSL
+/// TexCoord node implementation for GLSL
class TexCoordNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/TimeNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TimeNodeGlsl.h
index f1ae2ccbcf..4eed0942f0 100644
--- a/source/MaterialXGenGlsl/Nodes/TimeNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TimeNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of time node for GLSL
+/// Time node implementation for GLSL
class TimeNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/TransformNormalNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TransformNormalNodeGlsl.h
index b732ec1e11..5f19367c78 100644
--- a/source/MaterialXGenGlsl/Nodes/TransformNormalNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TransformNormalNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of transformsnormal node for GLSL
+/// TransformNormal node implementation for GLSL
class TransformNormalNodeGlsl : public TransformVectorNodeGlsl
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/TransformPointNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TransformPointNodeGlsl.h
index 8dfdce2498..fe81c16021 100644
--- a/source/MaterialXGenGlsl/Nodes/TransformPointNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TransformPointNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of transformspoint node for GLSL
+/// TransformPoint node implementation for GLSL
class TransformPointNodeGlsl : public TransformVectorNodeGlsl
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/TransformVectorNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/TransformVectorNodeGlsl.h
index ff72e6855e..b1665d026f 100644
--- a/source/MaterialXGenGlsl/Nodes/TransformVectorNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/TransformVectorNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of transformsvector node for GLSL
+/// TransformVector node implementation for GLSL
class TransformVectorNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenGlsl/Nodes/ViewDirectionNodeGlsl.h b/source/MaterialXGenGlsl/Nodes/ViewDirectionNodeGlsl.h
index 0c9e90ed10..70ec209b59 100644
--- a/source/MaterialXGenGlsl/Nodes/ViewDirectionNodeGlsl.h
+++ b/source/MaterialXGenGlsl/Nodes/ViewDirectionNodeGlsl.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of view direction for GLSL
+/// ViewDirection node implementation for GLSL
class ViewDirectionNodeGlsl : public GlslImplementation
{
public:
diff --git a/source/MaterialXGenOsl/CMakeLists.txt b/source/MaterialXGenOsl/CMakeLists.txt
index 757e440b6c..e38fabb211 100644
--- a/source/MaterialXGenOsl/CMakeLists.txt
+++ b/source/MaterialXGenOsl/CMakeLists.txt
@@ -1,31 +1,14 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
+
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXGenOsl STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXGenOsl STATIC ${materialx_source} ${materialx_headers})
set_target_properties(
MaterialXGenOsl PROPERTIES
@@ -42,12 +25,11 @@ target_link_libraries(
${CMAKE_DL_LIBS})
install(TARGETS MaterialXGenOsl
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXGenOsl/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenOsl.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXGenShader/CMakeLists.txt b/source/MaterialXGenShader/CMakeLists.txt
index e64d1c14ad..381aef85be 100644
--- a/source/MaterialXGenShader/CMakeLists.txt
+++ b/source/MaterialXGenShader/CMakeLists.txt
@@ -1,31 +1,14 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
+
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXGenShader STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXGenShader STATIC ${materialx_source} ${materialx_headers})
set_target_properties(
MaterialXGenShader PROPERTIES
@@ -42,14 +25,14 @@ target_link_libraries(
${CMAKE_DL_LIBS})
install(TARGETS MaterialXGenShader
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXGenShader/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenShader.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
-install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../resources" DESTINATION ${CMAKE_INSTALL_PREFIX} MESSAGE_NEVER)
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../resources"
+ DESTINATION ${CMAKE_INSTALL_PREFIX} MESSAGE_NEVER)
diff --git a/source/MaterialXGenShader/ColorManagementSystem.h b/source/MaterialXGenShader/ColorManagementSystem.h
index 9cb7902fd2..2434e36277 100644
--- a/source/MaterialXGenShader/ColorManagementSystem.h
+++ b/source/MaterialXGenShader/ColorManagementSystem.h
@@ -25,7 +25,7 @@ class ShaderGenerator;
/// A shared pointer to a ColorManagementSystem
using ColorManagementSystemPtr = shared_ptr;
-/// @struct @ColorSpaceTransform
+/// @struct ColorSpaceTransform
/// Structure that represents color space transform information
struct ColorSpaceTransform
{
@@ -45,8 +45,7 @@ struct ColorSpaceTransform
};
/// @class ColorManagementSystem
-/// Abstract base class for a ColorManagementSystem.
-///
+/// Abstract base class for color management systems
class ColorManagementSystem
{
public:
diff --git a/source/MaterialXGenShader/GenContext.h b/source/MaterialXGenShader/GenContext.h
index c2e9d70a14..c04124210b 100644
--- a/source/MaterialXGenShader/GenContext.h
+++ b/source/MaterialXGenShader/GenContext.h
@@ -89,12 +89,6 @@ class GenContext
return _options;
}
- /// Add to the search path used for finding source code.
- void registerSourceCodeSearchPath(const string& path)
- {
- _sourceCodeSearchPath.append(FilePath(path));
- }
-
/// Add to the search path used for finding source code.
void registerSourceCodeSearchPath(const FilePath& path)
{
diff --git a/source/MaterialXGenShader/Nodes/BlurNode.cpp b/source/MaterialXGenShader/Nodes/BlurNode.cpp
index 0d6fc5cca7..333adf7cf9 100644
--- a/source/MaterialXGenShader/Nodes/BlurNode.cpp
+++ b/source/MaterialXGenShader/Nodes/BlurNode.cpp
@@ -71,11 +71,11 @@ void BlurNode::emitFunctionCall(const ShaderNode& node, GenContext& context, Sha
const ShaderInput* inInput = node.getInput(IN_STRING);
// Get input type name string
- const string& inputTypeString = acceptsInputType(inInput->getType()) ?
+ const string& inputTypeString = inInput && acceptsInputType(inInput->getType()) ?
shadergen.getSyntax().getTypeName(inInput->getType()) : EMPTY_STRING;
const ShaderInput* filterTypeInput = node.getInput(FILTER_TYPE_STRING);
- if (!inInput || !filterTypeInput || inputTypeString.empty())
+ if (!filterTypeInput || inputTypeString.empty())
{
throw ExceptionShaderGenError("Node '" + node.getName() + "' is not a valid Blur node");
}
diff --git a/source/MaterialXGenShader/Nodes/BlurNode.h b/source/MaterialXGenShader/Nodes/BlurNode.h
index 8e3564e3ab..3f0d93877e 100644
--- a/source/MaterialXGenShader/Nodes/BlurNode.h
+++ b/source/MaterialXGenShader/Nodes/BlurNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of blur convolution
+/// Blur node implementation
class BlurNode : public ConvolutionNode
{
public:
diff --git a/source/MaterialXGenShader/Nodes/CombineNode.h b/source/MaterialXGenShader/Nodes/CombineNode.h
index 3aef48f2e7..31e076695b 100644
--- a/source/MaterialXGenShader/Nodes/CombineNode.h
+++ b/source/MaterialXGenShader/Nodes/CombineNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of coombine node
+/// Combine node implementation
class CombineNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/Nodes/CompareNode.h b/source/MaterialXGenShader/Nodes/CompareNode.h
index 60cd4b4d9e..12bab43de5 100644
--- a/source/MaterialXGenShader/Nodes/CompareNode.h
+++ b/source/MaterialXGenShader/Nodes/CompareNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of compare node
+/// Compare node implementation
class CompareNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/Nodes/CompoundNode.h b/source/MaterialXGenShader/Nodes/CompoundNode.h
index e5aa1fc570..390f3274c7 100644
--- a/source/MaterialXGenShader/Nodes/CompoundNode.h
+++ b/source/MaterialXGenShader/Nodes/CompoundNode.h
@@ -13,9 +13,10 @@
namespace MaterialX
{
+/// Compound node implementation
class CompoundNode : public ShaderNodeImpl
{
-public:
+ public:
static ShaderNodeImplPtr create();
void initialize(const InterfaceElement& element, GenContext& context) override;
@@ -28,7 +29,7 @@ class CompoundNode : public ShaderNodeImpl
ShaderGraph* getGraph() const override { return _rootGraph.get(); }
-protected:
+ protected:
ShaderGraphPtr _rootGraph;
string _functionName;
};
diff --git a/source/MaterialXGenShader/Nodes/ConvertNode.h b/source/MaterialXGenShader/Nodes/ConvertNode.h
index 3892f5ba29..76bbf54cb3 100644
--- a/source/MaterialXGenShader/Nodes/ConvertNode.h
+++ b/source/MaterialXGenShader/Nodes/ConvertNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of convert node
+/// Convert node implementation
class ConvertNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/Nodes/SourceCodeNode.h b/source/MaterialXGenShader/Nodes/SourceCodeNode.h
index a33be37f36..877acd0034 100644
--- a/source/MaterialXGenShader/Nodes/SourceCodeNode.h
+++ b/source/MaterialXGenShader/Nodes/SourceCodeNode.h
@@ -11,9 +11,9 @@
namespace MaterialX
{
-/// Implementation using data driven static source code.
-/// This is the defaul implementation used for all nodes that
-/// does not have a custom ShaderNodeImpl class.
+/// Node implementation using data-driven static source code.
+/// This is the default implementation used for all nodes that
+/// do not have a custom ShaderNodeImpl class.
class SourceCodeNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/Nodes/SwitchNode.h b/source/MaterialXGenShader/Nodes/SwitchNode.h
index 49163b7571..1035015db3 100644
--- a/source/MaterialXGenShader/Nodes/SwitchNode.h
+++ b/source/MaterialXGenShader/Nodes/SwitchNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of switch node
+/// Switch node implementation
class SwitchNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/Nodes/SwizzleNode.h b/source/MaterialXGenShader/Nodes/SwizzleNode.h
index 8698cfc467..33d04462d9 100644
--- a/source/MaterialXGenShader/Nodes/SwizzleNode.h
+++ b/source/MaterialXGenShader/Nodes/SwizzleNode.h
@@ -11,7 +11,7 @@
namespace MaterialX
{
-/// Implementation of swizzle node
+/// Swizzle node implementation
class SwizzleNode : public ShaderNodeImpl
{
public:
diff --git a/source/MaterialXGenShader/ShaderStage.h b/source/MaterialXGenShader/ShaderStage.h
index 46044df8a5..388b302794 100644
--- a/source/MaterialXGenShader/ShaderStage.h
+++ b/source/MaterialXGenShader/ShaderStage.h
@@ -31,8 +31,6 @@
namespace MaterialX
{
-/// @class Stage
-/// Shader stage identifiers.
namespace Stage
{
/// Identifier for pixel stage.
diff --git a/source/MaterialXGenShader/Syntax.h b/source/MaterialXGenShader/Syntax.h
index 092e1ca852..d105480881 100644
--- a/source/MaterialXGenShader/Syntax.h
+++ b/source/MaterialXGenShader/Syntax.h
@@ -223,7 +223,7 @@ class TypeSyntax
static const StringVec EMPTY_MEMBERS;
};
-/// Syntax class for scalar types.
+/// Specialization of TypeSyntax for scalar types.
class ScalarTypeSyntax : public TypeSyntax
{
public:
@@ -234,7 +234,7 @@ class ScalarTypeSyntax : public TypeSyntax
string getValue(const StringVec& values, bool uniform) const override;
};
-/// Syntax class for string types.
+/// Specialization of TypeSyntax for string types.
class StringTypeSyntax : public ScalarTypeSyntax
{
public:
@@ -244,7 +244,7 @@ class StringTypeSyntax : public ScalarTypeSyntax
string getValue(const Value& value, bool uniform) const override;
};
-/// Syntax class for aggregate types.
+/// Specialization of TypeSyntax for aggregate types.
class AggregateTypeSyntax : public TypeSyntax
{
public:
diff --git a/source/MaterialXRender/CMakeLists.txt b/source/MaterialXRender/CMakeLists.txt
index 8663d148d0..ee965a991a 100644
--- a/source/MaterialXRender/CMakeLists.txt
+++ b/source/MaterialXRender/CMakeLists.txt
@@ -1,36 +1,22 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
if(NOT MATERIALX_BUILD_OIIO)
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/OiioImageLoader.h")
list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/OiioImageLoader.cpp")
endif()
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
+
+if(UNIX)
+ add_compile_options(-Wno-unused-function)
+endif()
-add_library(MaterialXRender STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXRender STATIC ${materialx_source} ${materialx_headers})
if(MSVC)
target_link_libraries(
@@ -39,30 +25,28 @@ if(MSVC)
MaterialXCore
Opengl32
${CMAKE_DL_LIBS})
-elseif (APPLE)
+elseif(APPLE)
target_link_libraries(
MaterialXRender
MaterialXGenShader
MaterialXCore
- ${CMAKE_DL_LIBS}
-)
-elseif (UNIX AND NOT APPLE)
+ ${CMAKE_DL_LIBS})
+elseif(UNIX)
target_link_libraries(
MaterialXRender
MaterialXGenShader
MaterialXCore
- ${CMAKE_DL_LIBS}
- )
+ ${CMAKE_DL_LIBS})
endif(MSVC)
if(MATERIALX_BUILD_OIIO)
- set(OPENIMAGEIO_ROOT_DIR ${MATERIALX_OIIO_DIR})
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/OpenImageIO")
- find_package(OpenImageIO REQUIRED)
- if(OPENIMAGEIO_FOUND)
- include_directories(${OPENIMAGEIO_INCLUDE_DIR})
- target_link_libraries(MaterialXRender ${OPENIMAGEIO_LIBRARIES})
- endif()
+ set(OPENIMAGEIO_ROOT_DIR ${MATERIALX_OIIO_DIR})
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/OpenImageIO")
+ find_package(OpenImageIO REQUIRED)
+ if(OPENIMAGEIO_FOUND)
+ include_directories(${OPENIMAGEIO_INCLUDE_DIR})
+ target_link_libraries(MaterialXRender ${OPENIMAGEIO_LIBRARIES})
+ endif()
endif()
set_target_properties(
@@ -74,12 +58,11 @@ set_target_properties(
SOVERSION "${MATERIALX_MAJOR_VERSION}")
install(TARGETS MaterialXRender
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXRender/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRender.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXRender/GeometryHandler.h b/source/MaterialXRender/GeometryHandler.h
index d9791c3cb0..b52877fac2 100644
--- a/source/MaterialXRender/GeometryHandler.h
+++ b/source/MaterialXRender/GeometryHandler.h
@@ -34,7 +34,7 @@ class GeometryLoader
/// Returns a list of supported extensions
/// @return List of support extensions
- const StringSet& supportedExtensions()
+ const StringSet& supportedExtensions() const
{
return _extensions;
}
diff --git a/source/MaterialXRender/ImageHandler.h b/source/MaterialXRender/ImageHandler.h
index 16888699f2..a77f805e7c 100644
--- a/source/MaterialXRender/ImageHandler.h
+++ b/source/MaterialXRender/ImageHandler.h
@@ -173,7 +173,7 @@ class ImageLoader
/// Returns a list of supported extensions
/// @return List of support extensions
- const StringSet& supportedExtensions()
+ const StringSet& supportedExtensions() const
{
return _extensions;
}
@@ -295,7 +295,7 @@ class ImageHandler
}
/// Return the image search path
- const FileSearchPath& getSearchPath()
+ const FileSearchPath& getSearchPath() const
{
return _searchPath;
}
diff --git a/source/MaterialXRender/ShaderValidator.h b/source/MaterialXRender/ShaderValidator.h
index beb40bbd07..32e86cba99 100644
--- a/source/MaterialXRender/ShaderValidator.h
+++ b/source/MaterialXRender/ShaderValidator.h
@@ -70,7 +70,7 @@ class ShaderValidator
/// Get geometry handler
/// @return Reference to a geometry handler
- GeometryHandlerPtr getGeometryHandler()
+ GeometryHandlerPtr getGeometryHandler() const
{
return _geometryHandler;
}
diff --git a/source/MaterialXRender/StbImageLoader.cpp b/source/MaterialXRender/StbImageLoader.cpp
index 5b15b227b7..e798d1755e 100644
--- a/source/MaterialXRender/StbImageLoader.cpp
+++ b/source/MaterialXRender/StbImageLoader.cpp
@@ -4,9 +4,9 @@
//
#if defined(_WIN32)
- #pragma warning( push )
- #pragma warning( disable: 4100)
- #pragma warning( disable: 4505)
+ #pragma warning(push)
+ #pragma warning(disable: 4100)
+ #pragma warning(disable: 4505)
#endif
// Make the functions static to avoid multiple definitions if other libraries
@@ -20,7 +20,7 @@
#include
#if defined(_WIN32)
- #pragma warning( pop )
+ #pragma warning(pop)
#endif
#include
@@ -52,7 +52,7 @@ bool StbImageLoader::saveImage(const FilePath& filePath,
const string filePathName = filePath.asString();
- string extension = (filePathName.substr(filePathName.find_last_of(".") + 1));
+ string extension = filePath.getExtension();
if (!isFloat)
{
if (extension == PNG_EXTENSION)
@@ -104,7 +104,7 @@ bool StbImageLoader::loadImage(const FilePath& filePath, ImageDesc &imageDesc,
const string fileName = filePath.asString();
// If HDR, switch to float reader
- string extension = (fileName.substr(fileName.find_last_of(".") + 1));
+ string extension = filePath.getExtension();
if (extension == HDR_EXTENSION)
{
// Early out if base type is unsupported
diff --git a/source/MaterialXRender/TinyObjLoader.h b/source/MaterialXRender/TinyObjLoader.h
index f84e2adb41..cecfd150b9 100644
--- a/source/MaterialXRender/TinyObjLoader.h
+++ b/source/MaterialXRender/TinyObjLoader.h
@@ -18,8 +18,7 @@ namespace MaterialX
using TinyObjLoaderPtr = std::shared_ptr;
/// @class TinyObjLoader
-/// Wrapper for geometry loader to read in OBJ files using the TinyObjLoader library.
-///
+/// Wrapper for geometry loader to read in OBJ files using the TinyObj library.
class TinyObjLoader : public GeometryLoader
{
public:
diff --git a/source/MaterialXRender/ViewHandler.h b/source/MaterialXRender/ViewHandler.h
index 3e5f4c6be6..e7ca909a1a 100644
--- a/source/MaterialXRender/ViewHandler.h
+++ b/source/MaterialXRender/ViewHandler.h
@@ -42,7 +42,7 @@ class ViewHandler
float nearP, float farP);
/// Set the world matrix
- void setWorldMatrix(Matrix44& m)
+ void setWorldMatrix(const Matrix44& m)
{
_worldMatrix = m;
}
diff --git a/source/MaterialXRenderGlsl/CMakeLists.txt b/source/MaterialXRenderGlsl/CMakeLists.txt
index e2b2a0be04..682e4c79ee 100644
--- a/source/MaterialXRenderGlsl/CMakeLists.txt
+++ b/source/MaterialXRenderGlsl/CMakeLists.txt
@@ -1,62 +1,41 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
# Linux checks for X and OpenGL
-if (UNIX AND NOT APPLE)
- find_package(PkgConfig REQUIRED)
- find_package(X11 REQUIRED)
- if (NOT X11_FOUND)
- message("Error in building MaterialXRender: X11 was not found")
- endif(NOT X11_FOUND)
- if (NOT X11_Xt_FOUND)
- message("Error in building MaterialXRender: Xt was not found")
- endif(NOT X11_Xt_FOUND)
-
- find_package(OpenGL REQUIRED)
- if (NOT OPENGL_FOUND)
- message("Error in building MaterialXRender: OpenGL was not found")
- endif(NOT OPENGL_FOUND)
-
- include_directories(
- ${X11_INCLUDE_DIR}
- )
+if(UNIX AND NOT APPLE)
+ find_package(PkgConfig REQUIRED)
+ find_package(X11 REQUIRED)
+ if(NOT X11_FOUND)
+ message("Error in building MaterialXRender: X11 was not found")
+ endif(NOT X11_FOUND)
+ if(NOT X11_Xt_FOUND)
+ message("Error in building MaterialXRender: Xt was not found")
+ endif(NOT X11_Xt_FOUND)
+ find_package(OpenGL REQUIRED)
+ if(NOT OPENGL_FOUND)
+ message("Error in building MaterialXRender: OpenGL was not found")
+ endif(NOT OPENGL_FOUND)
+ include_directories(${X11_INCLUDE_DIR})
endif(UNIX AND NOT APPLE)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-if (APPLE)
- find_library(COCOA_FRAMEWORK Cocoa)
- find_package(OpenGL REQUIRED)
- file(GLOB_RECURSE materialx_source_oc "${CMAKE_CURRENT_SOURCE_DIR}/*.m")
- message("Objective C files: " ${materialx_source_oc})
- set_source_files_properties(${materialx_source_oc} PROPERTIES
- COMPILE_FLAGS "-x objective-c++")
- set(materialx_source ${materialx_source} ${materialx_source_oc})
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
+if(APPLE)
+ find_library(COCOA_FRAMEWORK Cocoa)
+ find_package(OpenGL REQUIRED)
+ file(GLOB_RECURSE materialx_source_oc "${CMAKE_CURRENT_SOURCE_DIR}/*.m")
+ message("Objective C files: " ${materialx_source_oc})
+ set_source_files_properties(${materialx_source_oc} PROPERTIES
+ COMPILE_FLAGS "-x objective-c++")
+ set(materialx_source ${materialx_source} ${materialx_source_oc})
endif(APPLE)
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXRenderGlsl STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXRenderGlsl STATIC ${materialx_source} ${materialx_headers})
if(MSVC)
target_link_libraries(
@@ -64,24 +43,22 @@ if(MSVC)
MaterialXRenderHw
Opengl32
${CMAKE_DL_LIBS})
-elseif (APPLE)
+elseif(APPLE)
target_link_libraries(
MaterialXRenderGlsl
MaterialXRenderHw
${CMAKE_DL_LIBS}
${OPENGL_LIBRARIES}
- "-framework Foundation"
- "-framework Cocoa"
-)
-elseif (UNIX AND NOT APPLE)
+ "-framework Foundation"
+ "-framework Cocoa")
+elseif(UNIX)
target_link_libraries(
MaterialXRenderGlsl
MaterialXRenderHw
${CMAKE_DL_LIBS}
${OPENGL_LIBRARIES}
${X11_LIBRARIES}
- ${X11_Xt_LIB}
- )
+ ${X11_Xt_LIB})
endif(MSVC)
set_target_properties(
@@ -93,12 +70,11 @@ set_target_properties(
SOVERSION "${MATERIALX_MAJOR_VERSION}")
install(TARGETS MaterialXRenderGlsl
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXRenderGlsl/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderGlsl.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXRenderGlsl/GlslProgram.h b/source/MaterialXRenderGlsl/GlslProgram.h
index 8b8c33dcb5..b0cf23f82f 100644
--- a/source/MaterialXRenderGlsl/GlslProgram.h
+++ b/source/MaterialXRenderGlsl/GlslProgram.h
@@ -71,7 +71,7 @@ class GlslProgram
/// @return Program identifier.
unsigned int build();
- /// Structure to hold information about program inputs
+ /// Structure to hold information about program inputs.
/// The structure is populated by directly scanning the program so may not contain
/// some inputs listed on any associated HwShader as those inputs may have been
/// optimized out if they are unused.
diff --git a/source/MaterialXRenderGlsl/GlslValidator.cpp b/source/MaterialXRenderGlsl/GlslValidator.cpp
index 71b9b622a1..9630868f31 100644
--- a/source/MaterialXRenderGlsl/GlslValidator.cpp
+++ b/source/MaterialXRenderGlsl/GlslValidator.cpp
@@ -20,18 +20,18 @@ const float FAR_PLANE_PERSP = 100.0f;
//
// Creator
//
-GlslValidatorPtr GlslValidator::create()
+GlslValidatorPtr GlslValidator::create(unsigned int res)
{
- return std::shared_ptr(new GlslValidator());
+ return GlslValidatorPtr(new GlslValidator(res));
}
-GlslValidator::GlslValidator() :
+GlslValidator::GlslValidator(unsigned int res) :
ShaderValidator(),
_colorTarget(0),
_depthTarget(0),
_frameBuffer(0),
- _frameBufferWidth(512),
- _frameBufferHeight(512),
+ _frameBufferWidth(res),
+ _frameBufferHeight(res),
_initialized(false),
_window(nullptr),
_context(nullptr)
@@ -313,6 +313,67 @@ void GlslValidator::validateCreation(const StageMap& stages)
_program->build();
}
+void GlslValidator::renderTextureSpace(bool encodeSrgb)
+{
+ bindTarget(true);
+ if (encodeSrgb)
+ {
+ glEnable(GL_FRAMEBUFFER_SRGB);
+ }
+ else
+ {
+ glDisable(GL_FRAMEBUFFER_SRGB);
+ }
+ glViewport(0, 0, _frameBufferWidth, _frameBufferHeight);
+
+ _program->bind();
+
+ unsigned int vao;
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+
+ _program->bindTextures(_imageHandler);
+
+ glBindVertexArray(vao);
+ float vertices[] =
+ {
+ // positions // texcoords
+ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
+ 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
+ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
+ -1.0f, 1.0f, 0.0f, 0.0f, 1.0f
+ };
+ unsigned int indices[] =
+ {
+ 0, 1, 3, // first triangle
+ 1, 2, 3 // second triangle
+ };
+
+ GLuint vbo;
+ glGenBuffers(1, &vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
+
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*) 0);
+
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*) (3 * sizeof(float)));
+
+ GLuint ebo;
+ glGenBuffers(1, &ebo);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
+
+ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
+ bindTarget(false);
+ checkErrors();
+
+ _program->unbind();
+ _program->unbindInputs(_imageHandler);
+ _program->unbindTextures(_imageHandler);
+}
+
void GlslValidator::validateInputs()
{
ShaderValidationErrorList errors;
@@ -522,4 +583,4 @@ void GlslValidator::checkErrors()
}
}
-}
+} // namespace MaterialX
diff --git a/source/MaterialXRenderGlsl/GlslValidator.h b/source/MaterialXRenderGlsl/GlslValidator.h
index 379169e515..4ecc8674e8 100644
--- a/source/MaterialXRenderGlsl/GlslValidator.h
+++ b/source/MaterialXRenderGlsl/GlslValidator.h
@@ -39,7 +39,7 @@ class GlslValidator : public ShaderValidator
{
public:
/// Create a GLSL validator instance
- static GlslValidatorPtr create();
+ static GlslValidatorPtr create(unsigned int res = 512);
/// Destructor
virtual ~GlslValidator();
@@ -47,7 +47,7 @@ class GlslValidator : public ShaderValidator
/// @name Setup
/// @{
- /// Internal initialization of stages and OpenGL contstructs
+ /// Internal initialization of stages and OpenGL constructs
/// required for program validation and rendering.
/// An exception is thrown on failure.
/// The exception will contain a list of initialization errors.
@@ -72,6 +72,15 @@ class GlslValidator : public ShaderValidator
/// rendered with. Rendering is to an offscreen hardware buffer.
void validateRender() override;
+ /// @}
+ /// @name Texture Baking
+ /// @{
+
+ /// Render the current program in texture space to our off-screen buffer.
+ /// @param encodeSrgb If true, then the off-screen buffer will be encoded
+ /// as sRGB; otherwise, no encoding is performed.
+ void renderTextureSpace(bool encodeSrgb);
+
/// @}
/// @name Utilities
/// @{
@@ -91,7 +100,7 @@ class GlslValidator : public ShaderValidator
protected:
/// Constructor
- GlslValidator();
+ GlslValidator(unsigned int res = 512);
/// Internal cleanup of stages and OpenGL constructs
void cleanup();
diff --git a/source/MaterialXRenderGlsl/TextureBaker.cpp b/source/MaterialXRenderGlsl/TextureBaker.cpp
new file mode 100644
index 0000000000..c7094e5bc2
--- /dev/null
+++ b/source/MaterialXRenderGlsl/TextureBaker.cpp
@@ -0,0 +1,121 @@
+//
+// TM & (c) 2019 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
+// All rights reserved. See LICENSE.txt for license.
+//
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include
+
+namespace MaterialX
+{
+
+TextureBaker::TextureBaker(unsigned int res) :
+ _fileSuffix(ImageLoader::PNG_EXTENSION)
+{
+ _rasterizer = GlslValidator::create(res);
+ _rasterizer->initialize();
+}
+
+void TextureBaker::bakeShaderInputs(ShaderRefPtr shaderRef, const FileSearchPath& searchPath, GenContext& context, const FilePath& outputFolder)
+{
+ if (!shaderRef)
+ {
+ return;
+ }
+
+ _searchPath = searchPath;
+ for (BindInputPtr bindInput : shaderRef->getBindInputs())
+ {
+ OutputPtr output = bindInput->getConnectedOutput();
+ if (output)
+ {
+ bakeGraphOutput(output, context, outputFolder);
+ }
+ }
+}
+
+void TextureBaker::bakeGraphOutput(OutputPtr output, GenContext& context, const FilePath& outputFolder)
+{
+ if (!output)
+ {
+ return;
+ }
+
+ GLTextureHandlerPtr imageHandler = GLTextureHandler::create(StbImageLoader::create());
+ imageHandler->setSearchPath(_searchPath);
+ _rasterizer->setImageHandler(imageHandler);
+
+ _generator = GlslShaderGenerator::create();
+
+ string outputName = createValidName(output->getNamePath());
+ ShaderPtr shader = _generator->generate(outputName + "_baker", output, context);
+
+ bool encodeSrgb = output->getType() == "color3" || output->getType() == "color4";
+ _rasterizer->validateCreation(shader);
+ _rasterizer->renderTextureSpace(encodeSrgb);
+
+ // TODO: Add support for graphs containing geometric nodes such as position and normal.
+ // Currently, the only supported geometric node is texcoord.
+
+ FilePath filename = outputFolder / FilePath(outputName + "_baked." + _fileSuffix);
+ _rasterizer->save(filename, false);
+}
+
+void TextureBaker::writeBakedDocument(ShaderRefPtr shaderRef, const FilePath& filename)
+{
+ if (!shaderRef)
+ {
+ return;
+ }
+
+ // Create document.
+ DocumentPtr bakedTextureDoc = createDocument();
+
+ // Create top-level elements.
+ NodeGraphPtr bakedNodeGraph = bakedTextureDoc->addNodeGraph("NG_baked");
+ MaterialPtr bakedMaterial = bakedTextureDoc->addMaterial("M_baked");
+ ShaderRefPtr bakedShaderRef = bakedMaterial->addShaderRef(shaderRef->getName() + "_baked", shaderRef->getAttribute("node"));
+ bakedNodeGraph->setColorSpace("srgb_texture");
+
+ // Create bind elements on the baked shader reference.
+ for (ValueElementPtr valueElem : shaderRef->getChildrenOfType())
+ {
+ BindInputPtr bindInput = valueElem->asA();
+ if (bindInput && bindInput->getConnectedOutput())
+ {
+ OutputPtr output = bindInput->getConnectedOutput();
+ string outputName = createValidName(output->getNamePath());
+
+ // Create the baked bind input.
+ BindInputPtr bakedBindInput = bakedShaderRef->addBindInput(bindInput->getName(), bindInput->getType());
+
+ // Add the image node.
+ NodePtr bakedImage = bakedNodeGraph->addNode("image", bindInput->getName() + "_baked", bindInput->getType());
+ ParameterPtr param = bakedImage->addParameter("file", "filename");
+ param->setValueString(outputName + "_baked." + _fileSuffix);
+
+ // Add the graph output.
+ OutputPtr bakedOutput = bakedNodeGraph->addOutput(bindInput->getName() + "_output", bindInput->getType());
+ bakedOutput->setConnectedNode(bakedImage);
+ bakedBindInput->setConnectedOutput(bakedOutput);
+ }
+ else
+ {
+ ElementPtr bakedElem = bakedShaderRef->addChildOfCategory(valueElem->getCategory(), valueElem->getName());
+ bakedElem->copyContentFrom(valueElem);
+ }
+ }
+
+ XmlWriteOptions writeOptions;
+ writeOptions.writeXIncludeEnable = false;
+ writeToXmlFile(bakedTextureDoc, filename, &writeOptions);
+}
+
+} // namespace MaterialX
diff --git a/source/MaterialXRenderGlsl/TextureBaker.h b/source/MaterialXRenderGlsl/TextureBaker.h
new file mode 100644
index 0000000000..1f02badd5b
--- /dev/null
+++ b/source/MaterialXRenderGlsl/TextureBaker.h
@@ -0,0 +1,59 @@
+//
+// TM & (c) 2019 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
+// All rights reserved. See LICENSE.txt for license.
+//
+
+#ifndef MATERIALX_TEXTUREBAKER
+#define MATERIALX_TEXTUREBAKER
+
+/// @file
+/// Texture baking functionality
+
+#include
+
+#include
+
+namespace MaterialX
+{
+
+class TextureBaker;
+class GlslValidator;
+using GlslValidatorPtr = std::shared_ptr;
+
+/// A shared pointer to a TextureBaker
+using TextureBakerPtr = shared_ptr;
+
+class TextureBaker
+{
+ public:
+ TextureBaker(unsigned int res = 1024);
+ ~TextureBaker() { }
+
+ static TextureBakerPtr create()
+ {
+ return std::make_shared();
+ }
+
+ /// Bake textures for all graph inputs of the given shader reference.
+ void bakeShaderInputs(ShaderRefPtr shaderRef, const FileSearchPath& searchPath, GenContext& context, const FilePath& outputFolder);
+
+ /// Bake a texture for the given graph output.
+ void bakeGraphOutput(OutputPtr output, GenContext& context, const FilePath& outputFolder);
+
+ /// Write out a document with baked images.
+ void writeBakedDocument(ShaderRefPtr shaderRef, const FilePath& filename);
+
+ protected:
+ void setSearchPath(const FileSearchPath searchPath) { _searchPath = searchPath; }
+ FileSearchPath getSearchPath() { return _searchPath; }
+
+ protected:
+ GlslValidatorPtr _rasterizer;
+ ShaderGeneratorPtr _generator;
+ FileSearchPath _searchPath;
+ string _fileSuffix;
+};
+
+} // namespace MaterialX
+
+#endif // MATERIALX_TEXTUREBAKER
diff --git a/source/MaterialXRenderHw/CMakeLists.txt b/source/MaterialXRenderHw/CMakeLists.txt
index f7fbd039af..6cfb50d4c8 100644
--- a/source/MaterialXRenderHw/CMakeLists.txt
+++ b/source/MaterialXRenderHw/CMakeLists.txt
@@ -1,13 +1,9 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-
-assign_source_group("Header Files" ${materialx_header})
-assign_source_group("Source Files" ${materialx_source})
+file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
if(APPLE)
find_library(COCOA_FRAMEWORK Cocoa)
@@ -18,30 +14,30 @@ if(APPLE)
set(materialx_source ${materialx_source} ${materialx_source_oc})
endif(APPLE)
-add_library(MaterialXRenderHw STATIC
- ${materialx_source}
- ${materialx_header}
-)
+assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
+
+add_library(MaterialXRenderHw STATIC ${materialx_source} ${materialx_headers})
if(MSVC)
target_link_libraries(
- MaterialXRenderHw
- MaterialXRender
- ${CMAKE_DL_LIBS})
+ MaterialXRenderHw
+ MaterialXRender
+ ${CMAKE_DL_LIBS})
elseif(APPLE)
target_link_libraries(
- MaterialXRenderHw
- MaterialXRender
- ${CMAKE_DL_LIBS}
- "-framework Foundation"
- "-framework Cocoa")
+ MaterialXRenderHw
+ MaterialXRender
+ ${CMAKE_DL_LIBS}
+ "-framework Foundation"
+ "-framework Cocoa")
elseif(UNIX)
target_link_libraries(
- MaterialXRenderHw
- MaterialXRender
- ${CMAKE_DL_LIBS}
- ${X11_LIBRARIES}
- ${X11_Xt_LIB})
+ MaterialXRenderHw
+ MaterialXRender
+ ${CMAKE_DL_LIBS}
+ ${X11_LIBRARIES}
+ ${X11_Xt_LIB})
endif(MSVC)
set_target_properties(
@@ -60,4 +56,4 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderHw.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXRenderHw/SimpleWindowWindows.cpp b/source/MaterialXRenderHw/SimpleWindowWindows.cpp
index b35ddb2a9e..298b712d55 100644
--- a/source/MaterialXRenderHw/SimpleWindowWindows.cpp
+++ b/source/MaterialXRenderHw/SimpleWindowWindows.cpp
@@ -23,7 +23,7 @@ SimpleWindow::SimpleWindow()
windowCount++;
// Generate a unique string for our window class.
- sprintf_s(_windowClassName, "_SW_%lu", _id);
+ sprintf_s(_windowClassName, "_SW_%u", _id);
}
// No-op window procedure
diff --git a/source/MaterialXRenderHw/WindowWrapper.h b/source/MaterialXRenderHw/WindowWrapper.h
index b6a8480fbe..198a86a990 100644
--- a/source/MaterialXRenderHw/WindowWrapper.h
+++ b/source/MaterialXRenderHw/WindowWrapper.h
@@ -50,7 +50,7 @@ using DisplayHandle = void*;
///
/// @class WindowWrapper
-/// Generic wrapper for encapsulating a "window" construct
+/// Generic wrapper for encapsulating a "window" construct.
/// Each supported platform will have specific storage and management logic.
///
class WindowWrapper
diff --git a/source/MaterialXRenderOsl/CMakeLists.txt b/source/MaterialXRenderOsl/CMakeLists.txt
index 9e5a0b1813..907bed3202 100644
--- a/source/MaterialXRenderOsl/CMakeLists.txt
+++ b/source/MaterialXRenderOsl/CMakeLists.txt
@@ -1,43 +1,26 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
-assign_source_group("Header Files" ${materialx_header})
assign_source_group("Source Files" ${materialx_source})
+assign_source_group("Header Files" ${materialx_headers})
-add_library(MaterialXRenderOsl STATIC
- ${materialx_source}
- ${materialx_header}
-)
+add_library(MaterialXRenderOsl STATIC ${materialx_source} ${materialx_headers})
if(MSVC)
target_link_libraries(
MaterialXRenderOsl
MaterialXRender
${CMAKE_DL_LIBS})
-elseif (APPLE)
+elseif(APPLE)
target_link_libraries(
MaterialXRenderOsl
MaterialXRender
${CMAKE_DL_LIBS})
-elseif (UNIX AND NOT APPLE)
+elseif(UNIX)
target_link_libraries(
MaterialXRenderOsl
MaterialXRender
@@ -53,12 +36,11 @@ set_target_properties(
SOVERSION "${MATERIALX_MAJOR_VERSION}")
install(TARGETS MaterialXRenderOsl
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/
-)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MaterialXRenderOsl/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderOsl.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" OPTIONAL)
diff --git a/source/MaterialXTest/CMakeLists.txt b/source/MaterialXTest/CMakeLists.txt
index fe36915b54..739b846309 100644
--- a/source/MaterialXTest/CMakeLists.txt
+++ b/source/MaterialXTest/CMakeLists.txt
@@ -1,58 +1,31 @@
include_directories(
${EXTERNAL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../
-)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../)
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-if(NOT MATERIALX_BUILD_GEN_ARNOLD)
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/GenArnold.cpp")
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/RenderArnold.cpp")
-endif()
-if(NOT MATERIALX_BUILD_GEN_OGSFX)
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/GenOgsFx.cpp")
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/RenderOgsfx.cpp")
-endif()
-if(NOT MATERIALX_BUILD_GEN_OGSXML)
- list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/GenOgsXml.cpp")
-endif()
-file(GLOB_RECURSE materialx_header "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-file(GLOB_RECURSE catch_headers "${CMAKE_CURRENT_SOURCE_DIR}/Catch/*.hpp")
-
-function(assign_source_group prefix)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${prefix}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
+file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
-assign_source_group("Header Files" ${materialx_header})
assign_source_group("Source Files" ${materialx_source})
-source_group("Header Files\\Catch" FILES ${catch_headers})
+assign_source_group("Header Files" ${materialx_headers})
-add_executable(MaterialXTest ${materialx_source} ${materialx_header} ${catch_headers})
+add_executable(MaterialXTest ${materialx_source} ${materialx_headers})
add_test(NAME MaterialXTest
- COMMAND MaterialXTest
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ COMMAND MaterialXTest
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(MATERIALX_BUILD_OIIO AND OPENIMAGEIO_ROOT_DIR)
add_custom_command(TARGET MaterialXTest POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${OPENIMAGEIO_ROOT_DIR}/bin ${CMAKE_CURRENT_BINARY_DIR})
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${OPENIMAGEIO_ROOT_DIR}/bin ${CMAKE_CURRENT_BINARY_DIR})
endif()
add_custom_command(TARGET MaterialXTest POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries ${CMAKE_CURRENT_BINARY_DIR}/libraries)
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries ${CMAKE_CURRENT_BINARY_DIR}/libraries)
add_custom_command(TARGET MaterialXTest POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${CMAKE_CURRENT_SOURCE_DIR}/../../resources ${CMAKE_CURRENT_BINARY_DIR}/resources)
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../resources ${CMAKE_CURRENT_BINARY_DIR}/resources)
set_target_properties(
MaterialXTest PROPERTIES
@@ -62,7 +35,7 @@ set_target_properties(
VERSION "${MATERIALX_LIBRARY_VERSION}"
SOVERSION "${MATERIALX_MAJOR_VERSION}")
-set (LIBS
+set(LIBS
MaterialXCore
MaterialXFormat
MaterialXGenShader
@@ -91,6 +64,6 @@ if (MATERIALX_BUILD_CONTRIB)
endif()
target_link_libraries(
- MaterialXTest ${LIBS}
- ${CMAKE_DL_LIBS}
-)
+ MaterialXTest
+ ${LIBS}
+ ${CMAKE_DL_LIBS})
diff --git a/source/MaterialXTest/GenGlsl.cpp b/source/MaterialXTest/GenGlsl.cpp
index 285db8418d..dba6189a5b 100644
--- a/source/MaterialXTest/GenGlsl.cpp
+++ b/source/MaterialXTest/GenGlsl.cpp
@@ -123,11 +123,12 @@ TEST_CASE("GenShader: Bind Light Shaders", "[genglsl]")
static void generateGlslCode()
{
const mx::FilePath testRootPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/TestSuite");
+ const mx::FilePath testRootPath2 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface");
+ const mx::FilePath testRootPath3 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface");
mx::FilePathVec testRootPaths;
testRootPaths.push_back(testRootPath);
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/Units"));
+ testRootPaths.push_back(testRootPath2);
+ testRootPaths.push_back(testRootPath3);
const mx::FilePath libSearchPath = mx::FilePath::getCurrentPath() / mx::FilePath("libraries");
const mx::FileSearchPath srcSearchPath(libSearchPath.asString());
const mx::FilePath logPath("genglsl_glsl400_generate_test.txt");
diff --git a/source/MaterialXTest/GenOsl.cpp b/source/MaterialXTest/GenOsl.cpp
index 1b5db2c0a2..21de45bf8c 100644
--- a/source/MaterialXTest/GenOsl.cpp
+++ b/source/MaterialXTest/GenOsl.cpp
@@ -110,11 +110,12 @@ TEST_CASE("GenShader: OSL Unique Names", "[genosl]")
static void generateOslCode()
{
const mx::FilePath testRootPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/TestSuite");
+ const mx::FilePath testRootPath2 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface");
+ const mx::FilePath testRootPath3 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface");
mx::FilePathVec testRootPaths;
testRootPaths.push_back(testRootPath);
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/Units"));
+ testRootPaths.push_back(testRootPath2);
+ testRootPaths.push_back(testRootPath3);
const mx::FilePath libSearchPath = mx::FilePath::getCurrentPath() / mx::FilePath("libraries");
mx::FileSearchPath srcSearchPath(libSearchPath.asString());
srcSearchPath.append(libSearchPath / mx::FilePath("stdlib/osl"));
diff --git a/source/MaterialXTest/Look.cpp b/source/MaterialXTest/Look.cpp
index c65d9d2ab3..99642f2987 100644
--- a/source/MaterialXTest/Look.cpp
+++ b/source/MaterialXTest/Look.cpp
@@ -38,9 +38,11 @@ TEST_CASE("Look", "[look]")
REQUIRE(material->getGeometryBindings("/robot2/left_arm").size() == 0);
// Create a property assignment.
- mx::PropertyAssignPtr propertyAssign = look->addPropertyAssign("twosided");
+ mx::PropertyAssignPtr propertyAssign = look->addPropertyAssign();
+ propertyAssign->setProperty("twosided");
propertyAssign->setGeom("/robot1");
propertyAssign->setValue(true);
+ REQUIRE(propertyAssign->getProperty() == "twosided");
REQUIRE(propertyAssign->getGeom() == "/robot1");
REQUIRE(propertyAssign->getValue()->isA());
REQUIRE(propertyAssign->getValue()->asA() == true);
@@ -50,8 +52,10 @@ TEST_CASE("Look", "[look]")
propertySet->setPropertyValue("matte", false);
REQUIRE(propertySet->getPropertyValue("matte")->isA());
REQUIRE(propertySet->getPropertyValue("matte")->asA() == false);
- mx::PropertySetAssignPtr propertySetAssign = look->addPropertySetAssign(propertySet->getName());
+ mx::PropertySetAssignPtr propertySetAssign = look->addPropertySetAssign();
+ propertySetAssign->setPropertySet(propertySet);
propertySetAssign->setGeom("/robot1");
+ REQUIRE(propertySetAssign->getPropertySet() == propertySet);
REQUIRE(propertySetAssign->getGeom() == "/robot1");
// Create a variant set.
diff --git a/source/MaterialXTest/RenderGLSL.cpp b/source/MaterialXTest/RenderGLSL.cpp
index c66cec08a4..82d0ce6125 100644
--- a/source/MaterialXTest/RenderGLSL.cpp
+++ b/source/MaterialXTest/RenderGLSL.cpp
@@ -502,13 +502,15 @@ bool GlslShaderRenderTester::runValidator(const std::string& shaderName,
TEST_CASE("Render: GLSL TestSuite", "[renderglsl]")
{
GlslShaderRenderTester renderTester(mx::GlslShaderGenerator::create());
-
+
const mx::FilePath testRootPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/TestSuite");
+ const mx::FilePath testRootPath2 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface");
+ const mx::FilePath testRootPath3 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface");
mx::FilePathVec testRootPaths;
testRootPaths.push_back(testRootPath);
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/Units"));
+ testRootPaths.push_back(testRootPath2);
+ testRootPaths.push_back(testRootPath3);
+
mx::FilePath optionsFilePath = testRootPath / mx::FilePath("_options.mtlx");
renderTester.validate(testRootPaths, optionsFilePath);
diff --git a/source/MaterialXTest/RenderOSL.cpp b/source/MaterialXTest/RenderOSL.cpp
index fe478e01d6..208c1cb982 100644
--- a/source/MaterialXTest/RenderOSL.cpp
+++ b/source/MaterialXTest/RenderOSL.cpp
@@ -308,11 +308,12 @@ TEST_CASE("Render: OSL TestSuite", "[renderosl]")
OslShaderRenderTester renderTester(mx::OslShaderGenerator::create());
const mx::FilePath testRootPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/TestSuite");
+ const mx::FilePath testRootPath2 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface");
+ const mx::FilePath testRootPath3 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface");
mx::FilePathVec testRootPaths;
testRootPaths.push_back(testRootPath);
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface"));
- testRootPaths.push_back(mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/Units"));
+ testRootPaths.push_back(testRootPath2);
+ testRootPaths.push_back(testRootPath3);
mx::FilePath optionsFilePath = testRootPath / mx::FilePath("_options.mtlx");
diff --git a/source/MaterialXTest/RenderUtil.cpp b/source/MaterialXTest/RenderUtil.cpp
index dcc8d82143..184dda651a 100644
--- a/source/MaterialXTest/RenderUtil.cpp
+++ b/source/MaterialXTest/RenderUtil.cpp
@@ -262,7 +262,6 @@ bool ShaderRenderTester::validate(const mx::FilePathVec& testRootPaths, const mx
}
doc->importLibrary(dependLib, ©Options);
-
ioTimer.endTimer();
validateTimer.startTimer();
diff --git a/source/MaterialXTest/Value.cpp b/source/MaterialXTest/Value.cpp
index 1d291a570d..9ab68e1f20 100644
--- a/source/MaterialXTest/Value.cpp
+++ b/source/MaterialXTest/Value.cpp
@@ -106,14 +106,14 @@ TEST_CASE("Typed values", "[value]")
std::string("second_value"));
// Array types
- testTypedValue(std::vector{1, 2, 3},
- std::vector{4, 5, 6});
- testTypedValue(std::vector{false, false, false},
- std::vector{true, true, true});
- testTypedValue(std::vector{1.0f, 2.0f, 3.0f},
- std::vector{4.0f, 5.0f, 6.0f});
- testTypedValue(std::vector{"one", "two", "three"},
- std::vector{"four", "five", "six"});
+ testTypedValue(mx::IntVec{1, 2, 3},
+ mx::IntVec{4, 5, 6});
+ testTypedValue(mx::BoolVec{false, false, false},
+ mx::BoolVec{true, true, true});
+ testTypedValue(mx::FloatVec{1.0f, 2.0f, 3.0f},
+ mx::FloatVec{4.0f, 5.0f, 6.0f});
+ testTypedValue(mx::StringVec{"one", "two", "three"},
+ mx::StringVec{"four", "five", "six"});
// Alias types
testTypedValue(1l, 2l);
diff --git a/source/MaterialXView/CMakeLists.txt b/source/MaterialXView/CMakeLists.txt
index 4476aef14b..f3d0344335 100644
--- a/source/MaterialXView/CMakeLists.txt
+++ b/source/MaterialXView/CMakeLists.txt
@@ -5,7 +5,7 @@ if (NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/NanoGUI/ext/glfw/src")
endif()
file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
-file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
set(NANOGUI_BUILD_EXAMPLE OFF CACHE BOOL " " FORCE)
set(NANOGUI_BUILD_SHARED OFF CACHE BOOL " " FORCE)
@@ -16,13 +16,11 @@ set(NANOGUI_INSTALL OFF CACHE BOOL " " FORCE)
set(PREV_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
set(PREV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
if(MSVC)
- add_compile_options(/wd4389 -DEIGEN_DONT_VECTORIZE)
+ add_compile_options(-wd4389 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DEIGEN_DONT_VECTORIZE)
elseif(UNIX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- add_compile_options(-Wno-misleading-indentation)
- add_compile_options(-Wno-format-truncation)
- add_compile_options(-Wno-implicit-fallthrough)
- add_compile_options(-Wno-int-in-bool-context)
- add_compile_options(-Wno-maybe-uninitialized) # GCC-8 only
+ add_compile_options(-Wno-format-truncation -Wno-implicit-fallthrough -Wno-int-in-bool-context
+ -Wno-maybe-uninitialized -Wno-misleading-indentation)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/NanoGUI external/NanoGUI)
@@ -38,10 +36,6 @@ include_directories(
add_definitions(${NANOGUI_EXTRA_DEFS})
-if(MSVC)
- add_compile_options(/D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS )
-endif()
-
add_executable(MaterialXView ${materialx_source} ${materialx_headers})
target_link_libraries(
@@ -53,19 +47,18 @@ target_link_libraries(
${NANOGUI_EXTRA_LIBS})
add_custom_command(TARGET MaterialXView POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries ${CMAKE_CURRENT_BINARY_DIR}/libraries)
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries ${CMAKE_CURRENT_BINARY_DIR}/libraries)
add_custom_command(TARGET MaterialXView POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${CMAKE_CURRENT_SOURCE_DIR}/../../resources ${CMAKE_CURRENT_BINARY_DIR}/resources)
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../resources ${CMAKE_CURRENT_BINARY_DIR}/resources)
if(MATERIALX_BUILD_OIIO AND OPENIMAGEIO_ROOT_DIR)
add_custom_command(TARGET MaterialXView POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${OPENIMAGEIO_ROOT_DIR}/bin ${CMAKE_CURRENT_BINARY_DIR})
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${OPENIMAGEIO_ROOT_DIR}/bin ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(TARGETS MaterialXView
- DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/)
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXView.pdb"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/" OPTIONAL)
-
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/" OPTIONAL)
diff --git a/source/MaterialXView/Material.cpp b/source/MaterialXView/Material.cpp
index 949244ca98..ae57d8e87c 100644
--- a/source/MaterialXView/Material.cpp
+++ b/source/MaterialXView/Material.cpp
@@ -205,7 +205,6 @@ bool Material::generateShader(mx::GenContext& context, bool forceCreation)
_glShader->init(_elem->getNamePath(), vertexShader, pixelShader);
updateUniformsList();
}
-
return true;
}
@@ -289,8 +288,14 @@ void Material::bindViewInformation(const mx::Matrix44& world, const mx::Matrix44
mx::Matrix44 invTransWorld = world.getInverse().getTranspose();
// Bind view properties.
- _glShader->setUniform(mx::HW::WORLD_MATRIX, ng::Matrix4f(world.getTranspose().data()));
- _glShader->setUniform(mx::HW::VIEW_PROJECTION_MATRIX, ng::Matrix4f(viewProj.getTranspose().data()));
+ if (_glShader->uniform(mx::HW::WORLD_MATRIX, false) != -1)
+ {
+ _glShader->setUniform(mx::HW::WORLD_MATRIX, ng::Matrix4f(world.getTranspose().data()));
+ }
+ if (_glShader->uniform(mx::HW::VIEW_PROJECTION_MATRIX, false) != -1)
+ {
+ _glShader->setUniform(mx::HW::VIEW_PROJECTION_MATRIX, ng::Matrix4f(viewProj.getTranspose().data()));
+ }
if (_glShader->uniform(mx::HW::WORLD_INVERSE_TRANSPOSE_MATRIX, false) != -1)
{
_glShader->setUniform(mx::HW::WORLD_INVERSE_TRANSPOSE_MATRIX, ng::Matrix4f(invTransWorld.getTranspose().data()));
diff --git a/source/MaterialXView/Viewer.cpp b/source/MaterialXView/Viewer.cpp
index 5ea61587ed..d81b0f9011 100644
--- a/source/MaterialXView/Viewer.cpp
+++ b/source/MaterialXView/Viewer.cpp
@@ -1,13 +1,16 @@
#include
-#include
-#include
-#include
+#include
+
#include
#include
#include
#include
+#include
+#include
+#include
+
#include
#include
#include
@@ -80,7 +83,7 @@ mx::DocumentPtr loadLibraries(const mx::FilePathVec& libraryFolders, const mx::F
readOptions.skipConflictingElements = true;
mx::FilePath libraryPath = searchPath.find(libraryFolder);
- for (const mx::FilePath& filename : libraryPath.getFilesInDirectory("mtlx"))
+ for (const mx::FilePath& filename : libraryPath.getFilesInDirectory(mx::MTLX_EXTENSION))
{
mx::DocumentPtr libDoc = mx::createDocument();
mx::readFromXmlFile(libDoc, libraryPath / filename, mx::FileSearchPath(), &readOptions);
@@ -193,6 +196,7 @@ Viewer::Viewer(const mx::FilePathVec& libraryFolders,
_genContext(mx::GlslShaderGenerator::create()),
_splitByUdims(false),
_mergeMaterials(false),
+ _bakeTextures(false),
_outlineSelection(false),
_specularEnvironmentMethod(specularEnvironmentMethod),
_envSamples(DEFAULT_ENV_SAMPLES),
@@ -525,30 +529,43 @@ void Viewer::createSaveMaterialsInterface(Widget* parent, const std::string& lab
materialButton->setCallback([this]()
{
mProcessEvents = false;
- std::string filename = ng::file_dialog({ { "mtlx", "MaterialX" } }, true);
+ MaterialPtr material = getSelectedMaterial();
+ mx::FilePath filename = ng::file_dialog({ { "mtlx", "MaterialX" } }, true);
// Save document
- if (!filename.empty() && !_materials.empty())
+ if (material && !filename.isEmpty())
{
- mx::DocumentPtr doc = _materials.front()->getDocument();
- // Add element predicate to prune out writing elements from included files
- auto skipXincludes = [this](mx::ConstElementPtr elem)
+ mx::DocumentPtr doc = material->getDocument();
+ if (filename.getExtension() != mx::MTLX_EXTENSION)
+ {
+ filename = mx::FilePath(filename.asString() + "." + mx::MTLX_EXTENSION);
+ }
+
+ mx::ShaderRefPtr shaderRef = material->getElement()->asA();
+ if (_bakeTextures && shaderRef)
+ {
+ mx::TextureBakerPtr baker = mx::TextureBaker::create();
+ baker->bakeShaderInputs(shaderRef, _searchPath, _genContext, filename.getParentPath());
+ baker->writeBakedDocument(shaderRef, filename);
+ }
+ else
{
- if (elem->hasSourceUri())
+ // Add element predicate to prune out writing elements from included files
+ auto skipXincludes = [this](mx::ConstElementPtr elem)
{
- return (_xincludeFiles.count(elem->getSourceUri()) == 0);
- }
- return true;
- };
- mx::XmlWriteOptions writeOptions;
- writeOptions.writeXIncludeEnable = true;
- writeOptions.elementPredicate = skipXincludes;
- mx::writeToXmlFile(doc, filename, &writeOptions);
- }
+ if (elem->hasSourceUri())
+ {
+ return (_xincludeFiles.count(elem->getSourceUri()) == 0);
+ }
+ return true;
+ };
+ mx::XmlWriteOptions writeOptions;
+ writeOptions.writeXIncludeEnable = true;
+ writeOptions.elementPredicate = skipXincludes;
+ mx::writeToXmlFile(doc, filename, &writeOptions);
+ }
- // Update material file name
- if (!filename.empty() && _materialFilename != filename)
- {
+ // Update material file name
_materialFilename = filename;
}
mProcessEvents = true;
@@ -592,6 +609,13 @@ void Viewer::createAdvancedSettings(Widget* parent)
_mergeMaterials = enable;
});
+ ng::CheckBox* bakeTexturesBox = new ng::CheckBox(advancedPopup, "Bake Textures");
+ bakeTexturesBox->setChecked(_bakeTextures);
+ bakeTexturesBox->setCallback([this](bool enable)
+ {
+ _bakeTextures = enable;
+ });
+
new ng::Label(advancedPopup, "Lighting Options");
ng::CheckBox* directLightingBox = new ng::CheckBox(advancedPopup, "Direct lighting");
@@ -1137,12 +1161,13 @@ void Viewer::loadStandardLibraries()
{
// Initialize standard library and color management.
_stdLib = loadLibraries(_libraryFolders, _searchPath);
- mx::DefaultColorManagementSystemPtr cms = mx::DefaultColorManagementSystem::create(_genContext.getShaderGenerator().getLanguage());
- cms->loadLibrary(_stdLib);
- for (const mx::FilePath& filePath : _searchPath)
+ for (std::string sourceUri : _stdLib->getReferencedSourceUris())
{
- _genContext.registerSourceCodeSearchPath(filePath);
+ _xincludeFiles.insert(sourceUri);
}
+ mx::DefaultColorManagementSystemPtr cms = mx::DefaultColorManagementSystem::create(_genContext.getShaderGenerator().getLanguage());
+ cms->loadLibrary(_stdLib);
+ _genContext.registerSourceCodeSearchPath(_searchPath);
_genContext.getShaderGenerator().setColorManagementSystem(cms);
}
diff --git a/source/MaterialXView/Viewer.h b/source/MaterialXView/Viewer.h
index 638190b076..6003103bdf 100644
--- a/source/MaterialXView/Viewer.h
+++ b/source/MaterialXView/Viewer.h
@@ -190,6 +190,7 @@ class Viewer : public ng::Screen
// Material options
bool _mergeMaterials;
+ bool _bakeTextures;
// Render options
bool _outlineSelection;
diff --git a/source/PyMaterialX/CMakeLists.txt b/source/PyMaterialX/CMakeLists.txt
index a839c01eb4..2e51724fa3 100644
--- a/source/PyMaterialX/CMakeLists.txt
+++ b/source/PyMaterialX/CMakeLists.txt
@@ -4,15 +4,15 @@ set(PYBIND11_PYTHON_VERSION ${MATERIALX_PYTHON_VERSION})
set(PYTHON_EXECUTABLE ${MATERIALX_PYTHON_EXECUTABLE})
if(NOT EXISTS "${PYBIND11_COMMON_H}")
-message(FATAL_ERROR "PyBind11 source file not found: ${PYBIND11_COMMON_H}")
+ message(FATAL_ERROR "PyBind11 source file not found: ${PYBIND11_COMMON_H}")
endif()
file(STRINGS "${PYBIND11_COMMON_H}" pybind11_version_defines
- REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
+ REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
foreach(ver ${pybind11_version_defines})
- if (ver MATCHES "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
- set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
- endif()
+ if (ver MATCHES "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
+ set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
+ endif()
endforeach()
set(PYBIND11_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH})
message(STATUS "Using PyBind11 v${PYBIND11_VERSION}")
@@ -30,6 +30,15 @@ if(NOT MATERIALX_PYTHON_LTO)
set(PYBIND11_MODULE_FLAGS "NO_EXTRAS")
endif()
+if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
+ include(CheckCXXCompilerFlag)
+ add_compile_options(-Wno-deprecated-register)
+ CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template UNDEFINED_VAR_TEMPLATE_FLAG)
+ if(UNDEFINED_VAR_TEMPLATE_FLAG)
+ add_compile_options(-Wno-undefined-var-template)
+ endif()
+endif()
+
add_subdirectory(PyMaterialXCore)
add_subdirectory(PyMaterialXFormat)
add_subdirectory(PyMaterialXGenShader)
diff --git a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp
index ed8a1c0e6c..421254e3d9 100644
--- a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp
+++ b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp
@@ -191,7 +191,11 @@ void bindPyElement(py::module& mod)
BIND_VALUE_ELEMENT_FUNC_INSTANCE(vector4, mx::Vector4)
BIND_VALUE_ELEMENT_FUNC_INSTANCE(matrix33, mx::Matrix33)
BIND_VALUE_ELEMENT_FUNC_INSTANCE(matrix44, mx::Matrix44)
- BIND_VALUE_ELEMENT_FUNC_INSTANCE(string, std::string);
+ BIND_VALUE_ELEMENT_FUNC_INSTANCE(string, std::string)
+ BIND_VALUE_ELEMENT_FUNC_INSTANCE(integerarray, mx::IntVec)
+ BIND_VALUE_ELEMENT_FUNC_INSTANCE(booleanarray, mx::BoolVec)
+ BIND_VALUE_ELEMENT_FUNC_INSTANCE(floatarray, mx::FloatVec)
+ BIND_VALUE_ELEMENT_FUNC_INSTANCE(stringarray, mx::StringVec);
py::class_(mod, "Token")
.def_readonly_static("CATEGORY", &mx::Token::CATEGORY);
diff --git a/source/PyMaterialX/PyMaterialXCore/PyGeom.cpp b/source/PyMaterialX/PyMaterialXCore/PyGeom.cpp
index 797e038667..69869f2990 100644
--- a/source/PyMaterialX/PyMaterialXCore/PyGeom.cpp
+++ b/source/PyMaterialX/PyMaterialXCore/PyGeom.cpp
@@ -48,6 +48,10 @@ void bindPyGeom(py::module& mod)
BIND_GEOMINFO_FUNC_INSTANCE(matrix33, mx::Matrix33)
BIND_GEOMINFO_FUNC_INSTANCE(matrix44, mx::Matrix44)
BIND_GEOMINFO_FUNC_INSTANCE(string, std::string)
+ BIND_GEOMINFO_FUNC_INSTANCE(integerarray, mx::IntVec)
+ BIND_GEOMINFO_FUNC_INSTANCE(booleanarray, mx::BoolVec)
+ BIND_GEOMINFO_FUNC_INSTANCE(floatarray, mx::FloatVec)
+ BIND_GEOMINFO_FUNC_INSTANCE(stringarray, mx::StringVec)
.def_readonly_static("CATEGORY", &mx::GeomInfo::CATEGORY);
py::class_(mod, "GeomAttr")
diff --git a/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp b/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp
index bbefa58ae3..4b5e7e8594 100644
--- a/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp
+++ b/source/PyMaterialX/PyMaterialXCore/PyInterface.cpp
@@ -96,5 +96,9 @@ void bindPyInterface(py::module& mod)
BIND_INTERFACE_TYPE_INSTANCE(matrix33, mx::Matrix33)
BIND_INTERFACE_TYPE_INSTANCE(matrix44, mx::Matrix44)
BIND_INTERFACE_TYPE_INSTANCE(string, std::string)
+ BIND_INTERFACE_TYPE_INSTANCE(integerarray, mx::IntVec)
+ BIND_INTERFACE_TYPE_INSTANCE(booleanarray, mx::BoolVec)
+ BIND_INTERFACE_TYPE_INSTANCE(floatarray, mx::FloatVec)
+ BIND_INTERFACE_TYPE_INSTANCE(stringarray, mx::StringVec)
.def_readonly_static("NODE_DEF_ATTRIBUTE", &mx::InterfaceElement::NODE_DEF_ATTRIBUTE);
}
diff --git a/source/PyMaterialX/PyMaterialXCore/PyProperty.cpp b/source/PyMaterialX/PyMaterialXCore/PyProperty.cpp
index 93a7f17513..fb17dd658e 100644
--- a/source/PyMaterialX/PyMaterialXCore/PyProperty.cpp
+++ b/source/PyMaterialX/PyMaterialXCore/PyProperty.cpp
@@ -19,6 +19,9 @@ void bindPyProperty(py::module& mod)
.def_readonly_static("CATEGORY", &mx::Property::CATEGORY);
py::class_(mod, "PropertyAssign")
+ .def("setProperty", &mx::PropertyAssign::setProperty)
+ .def("hasProperty", &mx::PropertyAssign::hasProperty)
+ .def("getProperty", &mx::PropertyAssign::getProperty)
.def("setGeom", &mx::PropertyAssign::setGeom)
.def("hasGeom", &mx::PropertyAssign::hasGeom)
.def("getGeom", &mx::PropertyAssign::getGeom)
@@ -46,8 +49,17 @@ void bindPyProperty(py::module& mod)
BIND_PROPERTYSET_TYPE_INSTANCE(matrix33, mx::Matrix33)
BIND_PROPERTYSET_TYPE_INSTANCE(matrix44, mx::Matrix44)
BIND_PROPERTYSET_TYPE_INSTANCE(string, std::string)
+ BIND_PROPERTYSET_TYPE_INSTANCE(integerarray, mx::IntVec)
+ BIND_PROPERTYSET_TYPE_INSTANCE(booleanarray, mx::BoolVec)
+ BIND_PROPERTYSET_TYPE_INSTANCE(floatarray, mx::FloatVec)
+ BIND_PROPERTYSET_TYPE_INSTANCE(stringarray, mx::StringVec)
.def_readonly_static("CATEGORY", &mx::Property::CATEGORY);
py::class_(mod, "PropertySetAssign")
+ .def("setPropertySetString", &mx::PropertySetAssign::setPropertySetString)
+ .def("hasPropertySetString", &mx::PropertySetAssign::hasPropertySetString)
+ .def("getPropertySetString", &mx::PropertySetAssign::getPropertySetString)
+ .def("setPropertySet", &mx::PropertySetAssign::setPropertySet)
+ .def("getPropertySet", &mx::PropertySetAssign::getPropertySet)
.def_readonly_static("CATEGORY", &mx::PropertySetAssign::CATEGORY);
}
diff --git a/source/PyMaterialX/PyMaterialXCore/PyValue.cpp b/source/PyMaterialX/PyMaterialXCore/PyValue.cpp
index 1c4332b8b3..366b9389d8 100644
--- a/source/PyMaterialX/PyMaterialXCore/PyValue.cpp
+++ b/source/PyMaterialX/PyMaterialXCore/PyValue.cpp
@@ -36,4 +36,8 @@ void bindPyValue(py::module& mod)
BIND_TYPE_INSTANCE(matrix33, mx::Matrix33)
BIND_TYPE_INSTANCE(matrix44, mx::Matrix44)
BIND_TYPE_INSTANCE(string, std::string)
+ BIND_TYPE_INSTANCE(integerarray, mx::IntVec)
+ BIND_TYPE_INSTANCE(booleanarray, mx::BoolVec)
+ BIND_TYPE_INSTANCE(floatarray, mx::FloatVec)
+ BIND_TYPE_INSTANCE(stringarray, mx::StringVec)
}
diff --git a/source/PyMaterialX/PyMaterialXGenShader/PyGenContext.cpp b/source/PyMaterialX/PyMaterialXGenShader/PyGenContext.cpp
index e128fded4e..785ad35ee6 100644
--- a/source/PyMaterialX/PyMaterialXGenShader/PyGenContext.cpp
+++ b/source/PyMaterialX/PyMaterialXGenShader/PyGenContext.cpp
@@ -17,7 +17,6 @@ void bindPyGenContext(py::module& mod)
.def(py::init())
.def("getShaderGenerator", &mx::GenContext::getShaderGenerator)
.def("getOptions", static_cast(&mx::GenContext::getOptions), py::return_value_policy::reference)
- .def("registerSourceCodeSearchPath", static_cast(&mx::GenContext::registerSourceCodeSearchPath))
.def("registerSourceCodeSearchPath", static_cast(&mx::GenContext::registerSourceCodeSearchPath))
.def("registerSourceCodeSearchPath", static_cast(&mx::GenContext::registerSourceCodeSearchPath))
.def("resolveSourceFile", &mx::GenContext::resolveSourceFile);