Skip to content

Commit

Permalink
Define default color transforms as graphs (#1352)
Browse files Browse the repository at this point in the history
This changelist updates the definitions of the default color transforms from raw shader code to MaterialX graphs, removing the need for explicit code for each transform to be provided in each supported language.

Further in the future, this approach could enable direct communication of color transform graphs from OpenColorIO to MaterialX, allowing both standard ACES transforms and custom transforms to be communicated in a unified way.
  • Loading branch information
jstone-lucasfilm authored May 16, 2023
1 parent cce5379 commit 1d67704
Show file tree
Hide file tree
Showing 47 changed files with 417 additions and 643 deletions.
17 changes: 9 additions & 8 deletions libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@ This folder contains the standard data libraries for MaterialX, providing declar
- [genglsl](stdlib/genglsl): GLSL language support.
- [lib](stdlib/genglsl/lib) : Shader utility files.
- [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
- [stdlib_genglsl_cm_impl.mtlx](stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx) : Default color management implementations.
- [stdlib_genglsl_unit_impl.mtlx](stdlib/genosl/stdlib_genglsl_unit_impl.mtlx) : Real world unit support implementations.
- [genosl](stdlib/genosl): OSL language support.
- [lib](stdlib/genosl/lib) : Shader utility files.
- [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
- [stdlib_genosl_cm_impl.mtlx](stdlib/genosl/stdlib_genosl_cm_impl.mtlx) : Default color management implementations.
- [stdlib_genosl_unit_impl.mtlx](stdlib/genosl/stdlib_genosl_unit_impl.mtlx) : Real world unit support implementations.
- [genmdl](stdlib/genmdl): MDL language support.
- [stdlib_genmdl_impl.mtlx](stdlib/genmdl/stdlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
- [stdlib_genmdl_cm_impl.mtlx](stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx) : Default color management implementations.
- [stdlib_genmdl_unit_impl.mtlx](stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx) : Real world unit support implementations.
- Additional MaterialX support libraries for MDL are located in the [source/MaterialXGenMdl/mdl/materialx](../source/MaterialXGenMdl/mdl/materialx) package folder
- [genmsl](stdlib/genmsl): MSL language support.
- [lib](stdlib/genmsl/lib) : Shader utility files.
- [stdlib_genmsl_impl.mtlx](stdlib/genmsl/stdlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
- [stdlib_genmsl_cm_impl.mtlx](stdlib/genmsl/stdlib_genmsl_cm_impl.mtlx) : Minimal set of "default" color management implementations.
- [stdlib_genmsl_unit_impl.mtlx](stdlib/genmsl/stdlib_genmsl_unit_impl.mtlx) : Real world unit support implementations.

## Physically Based Shading Library
Expand All @@ -49,6 +45,13 @@ This folder contains the standard data libraries for MaterialX, providing declar
- [usd_preview_surface.mtlx](bxdf/usd_preview_surface.mtlx) : Graph definition of the [UsdPreviewSurface](https://openusd.org/release/spec_usdpreviewsurface.html) shading model.
- [lama](bxdf/lama) : Graph definitions of the [MaterialX Lama](https://rmanwiki.pixar.com/display/REN24/MaterialX+Lama) node set.

## Color Management Library
- MaterialX shader generation natively supports a small set of common spaces for input colors, with all color transforms implemented as language-independent MaterialX graphs. The canonical definitions of these color transforms may be found in the OpenColorIO configuration for [ACES 1.2](https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config/aces_1.2).
- lin_rec709, g18_rec709, g22_rec709, rec709_display, acescg (lin_ap1), g22_ap1, srgb_texture, lin_adobergb, adobergb
- [cmlib](cmlib)
- [cmlib_defs.mtlx](cmlib/cmlib_defs.mtlx) : Nodedef declarations.
- [cmlib_ng.mtlx](cmlib/cmlib_ng.mtlx) : Nodegraph definitions.

## Target Definitions
- Each target implementation requires a target definition for declaration / implementation correspondence to work.
- The [targets](targets) folder contains definition files for the following core targets:
Expand All @@ -62,12 +65,10 @@ This folder contains the standard data libraries for MaterialX, providing declar
- GLSL target support is for version 4.0 or higher.
- OSL target support is for version 1.9.10 or higher.
- MDL target support is for version 1.7.
- "Default" color management support includes OSL, GLSL, and MDL implementations for the following color spaces:
- lin_rec709, g18_rec709, g22_rec709, rec709_display, acescg (lin_ap1), g22_ap1, srgb_texture, lin_adobergb, adobergb
- Basic GLSL and MSL `lightshader` node definitions and implementations are provided for the following light types:
- point, directional, spot
- Code generation does not currently support:
- Shader generation does not currently support:
- `ambientocclusion` node.
- `arrayappend` node.
- `curveadjust` node.
- `displacementshader` and `volumeshader` nodes and associated operations (`add`, `multiply`, `mix`) for GLSL and MSL targets.
- `displacementshader` and `volumeshader` nodes for hardware shading targets (GLSL, MSL).
90 changes: 90 additions & 0 deletions libraries/cmlib/cmlib_defs.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0"?>
<materialx version="1.38">
<!--
Copyright Contributors to the MaterialX Project
SPDX-License-Identifier: Apache-2.0
Declarations of the default color transforms in MaterialX.
-->

<nodedef name="ND_g18_rec709_to_lin_rec709_color3" node="g18_rec709_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_g18_rec709_to_lin_rec709_color4" node="g18_rec709_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_g22_rec709_to_lin_rec709_color3" node="g22_rec709_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_g22_rec709_to_lin_rec709_color4" node="g22_rec709_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_rec709_display_to_lin_rec709_color3" node="rec709_display_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_rec709_display_to_lin_rec709_color4" node="rec709_display_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_acescg_to_lin_rec709_color3" node="acescg_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_acescg_to_lin_rec709_color4" node="acescg_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_g22_ap1_to_lin_rec709_color3" node="g22_ap1_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_g22_ap1_to_lin_rec709_color4" node="g22_ap1_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_srgb_texture_to_lin_rec709_color3" node="srgb_texture_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_srgb_texture_to_lin_rec709_color4" node="srgb_texture_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_lin_adobergb_to_lin_rec709_color3" node="lin_adobergb_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_lin_adobergb_to_lin_rec709_color4" node="lin_adobergb_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

<nodedef name="ND_adobergb_to_lin_rec709_color3" node="adobergb_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color3" />
<output name="out" type="color3" />
</nodedef>

<nodedef name="ND_adobergb_to_lin_rec709_color4" node="adobergb_to_lin_rec709" nodegroup="colortransform">
<input name="in" type="color4" />
<output name="out" type="color4" />
</nodedef>

</materialx>
Loading

0 comments on commit 1d67704

Please sign in to comment.