Skip to content

Commit

Permalink
ILM master merge. Oct 2, 2019. (#623)
Browse files Browse the repository at this point in the history
- merge to pull in all 1.34 changes.
  • Loading branch information
bernardkwok authored Oct 4, 2019
1 parent b77d550 commit 45da1e9
Show file tree
Hide file tree
Showing 95 changed files with 916 additions and 631 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ addons:
- libxi-dev
- libx11-dev
- g++-6
- g++-8
- g++-9
- clang-8

matrix:
Expand Down Expand Up @@ -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"
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
36 changes: 19 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion documents/DeveloperGuide/ShaderGeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ For nodes that can’t be implemented by inline expressions a function definitio
<parameter name="vaddressmode" type="string" value="periodic"/>
<parameter name="framerange" type="string" value=""/>
<parameter name="frameoffset" type="integer" value="0"/>
<parameter name="frameendaction" type="string" value="constant"/>
<parameter name="frameendaction" type="string" value="black"/>
</nodedef>
// Implementation element
Expand Down
29 changes: 15 additions & 14 deletions documents/DeveloperGuide/Viewer.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:

Expand All @@ -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

Expand All @@ -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.
Expand Down
103 changes: 46 additions & 57 deletions python/MaterialX/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,76 @@
# 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
return method(value).getValueString()


#--------------------------------------------------------------------------------
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()
Expand Down
Loading

0 comments on commit 45da1e9

Please sign in to comment.