Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ jobs:
run: |
python MaterialXTest/main.py
python MaterialXTest/genshader.py
python Scripts/comparenodedefs.py
python Scripts/comparenodedefs.py --spec ../documents/Specification/MaterialX.StandardNodes.md --mtlx ../libraries/stdlib/stdlib_defs.mtlx
python Scripts/comparenodedefs.py --spec ../documents/Specification/MaterialX.PBRSpec.md --mtlx ../libraries/pbrlib/pbrlib_defs.mtlx
python Scripts/creatematerial.py ../resources/Materials/Examples/StandardSurface/chess_set --texturePrefix chessboard --shadingModel standard_surface
python Scripts/creatematerial.py ../resources/Materials/Examples/GltfPbr/boombox --shadingModel gltf_pbr
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
Expand Down
52 changes: 32 additions & 20 deletions documents/Specification/MaterialX.PBRSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,28 +398,28 @@ Adds a directionally varying factor to an EDF. Scales the emission distribution
### `absorption_vdf`
Constructs a VDF for pure light absorption.

The `absorption` input represents the absorption rate per distance traveled in the medium, stated in _m<sup>−1</sup>_, with independent control for each color channel.
The `absorption` input represents the absorption rate per distance traveled in the medium, stated in _m<sup>−1</sup>_, with independent control for each wavelength.

|Port |Description |Type |Default |
|------------|------------------------------|-------|-------------|
|`absorption`|Absorption rate for the medium|color3 |0.0, 0.0, 0.0|
|`absorption`|Absorption rate for the medium|vector3|0.0, 0.0, 0.0|
|`out` |Output: the computed VDF |VDF | |

<a id="node-anisotropic-vdf"> </a>

### `anisotropic_vdf`
Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein phase function[^Pharr2023]. Forward, backward and uniform scattering is supported and controlled by the anisotropy input.

The `absorption` input represents the absorption rate per distance traveled in the medium, stated in _m<sup>−1</sup>_, with independent control for each color channel.
The `absorption` input represents the absorption rate per distance traveled in the medium, stated in _m<sup>−1</sup>_, with independent control for each wavelength.

The `anisotropy` input controls the scattering direction: negative values produce backwards scattering, positive values produce forward scattering, and 0.0 produces uniform scattering. Both absorption and scattering rates are specified per color channel/wavelength.
The `anisotropy` input controls the scattering direction: negative values produce backwards scattering, positive values produce forward scattering, and 0.0 produces uniform scattering. Both absorption and scattering rates are specified per wavelength.

|Port |Description |Type |Default |Accepted Values|
|------------|------------------------------------------|------|-------------|---------------|
|`absorption`|Absorption rate for the medium |color3|0.0, 0.0, 0.0| |
|`scattering`|Scattering rate for the medium |color3|0.0, 0.0, 0.0| |
|`anisotropy`|Anisotropy factor for scattering direction|float |0.0 |[-1, 1] |
|`out` |Output: the computed VDF |VDF | | |
|Port |Description |Type |Default |Accepted Values|
|------------|------------------------------------------|-------|-------------|---------------|
|`absorption`|Absorption rate for the medium |vector3|0.0, 0.0, 0.0| |
|`scattering`|Scattering rate for the medium |vector3|0.0, 0.0, 0.0| |
|`anisotropy`|Anisotropy factor for scattering direction|float |0.0 |[-1, 1] |
|`out` |Output: the computed VDF |VDF | | |


## PBR Shader Nodes
Expand All @@ -439,6 +439,19 @@ If the `edf` input is left unconnected, no emission will occur from the surface.
|`thin_walled`|Set to true to make the surface thin-walled |boolean |false |
|`out` |Output: the computed surface shader |surfaceshader| |

<a id="node-displacement"> </a>

### `displacement`
Constructs a displacement shader describing geometric modification to surfaces.

The scalar signature displaces along the surface normal direction, while the vector signature allows displacement in tangent/normal space using (dPdu, dPdv, N) coordinates.

|Port |Description |Type |Default |
|--------------|----------------------------------------|------------------|--------|
|`displacement`|Displacement amount or direction |float, vector3 |__zero__|
|`scale` |Scale factor for the displacement |float |1.0 |
|`out` |Output: the computed displacement shader|displacementshader| |

<a id="node-volume"> </a>

### `volume`
Expand All @@ -457,15 +470,14 @@ If the `edf` input is left unconnected, no emission will occur from the medium.
### `light`
Constructs a light shader describing an explicit light source. The light shader will emit light according to the connected EDF. If the shader is attached to geometry both sides will be considered for light emission and the EDF controls if light is emitted from both sides or not.

|Port |Description |Type |Default |
|-----------|---------------------------------------------------|------------|-------------|
|`edf` |Emission distribution function for the light source|EDF |__zero__ |
|`intensity`|Intensity multiplier for the EDF's emittance |color3 |1.0, 1.0, 1.0|
|`exposure` |Exposure control for the EDF's emittance |float |0.0 |
|`out` |Output: the computed light shader |lightshader | |

Note that the standard library includes definitions for [**`displacement`**](./MaterialX.Specification.md#node-displacement) and [**`surface_unlit`**](./MaterialX.Specification.md#node-surfaceunlit) shader nodes.
|Port |Description |Type |Default |
|-----------|---------------------------------------------------|------------|--------|
|`edf` |Emission distribution function for the light source|EDF |__zero__|
|`intensity`|Intensity multiplier for the EDF's emittance |float |1.0 |
|`exposure` |Exposure control for the EDF's emittance |float |0.0 |
|`out` |Output: the computed light shader |lightshader | |

Note that the standard library includes a definition for the [**`surface_unlit`**](./MaterialX.StandardNodes.md#node-surfaceunlit) shader node.


## Utility Nodes
Expand Down Expand Up @@ -595,7 +607,7 @@ Converts the hair melanin parameterization to absorption coefficient based on pi
|`melanin_redness` |Amount of redness affected to the output |float |0.5 |[0, 1] |
|`eumelanin_color` |Eumelanin color |color3 |0.657704, 0.498077, 0.254107| |
|`pheomelanin_color` |Pheomelanin color |color3 |0.829444, 0.67032, 0.349938 | |
|`out` |Output: the computed absorption coefficient |vector3| | |
|`absorption` |Output: the computed absorption coefficient |vector3| | |

<a id="node-chiang-hair-absorption-from-color"> </a>

Expand All @@ -606,7 +618,7 @@ Converts the hair scattering color to absorption coefficient using the mapping m
|---------------------|------------------------------------------------|-------|-------------|---------------|
|`color` |Scattering color |color3 |1.0, 1.0, 1.0| |
|`azimuthal_roughness`|Azimuthal roughness |float |0.2 |[0, 1] |
|`out` |Output: the computed absorption coefficient |vector3| | |
|`absorption` |Output: the computed absorption coefficient |vector3| | |

<br>

Expand Down
17 changes: 0 additions & 17 deletions documents/Specification/MaterialX.StandardNodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2322,23 +2322,6 @@ An unlit surface shader node, representing a surface that can emit and transmit
|`opacity` |Surface cutout opacity |float |1.0 |
|`out` |Output: unlit surface shader closure |surfaceshader| |

<a id="node-displacement"> </a>

### `displacement`
Constructs a displacement shader describing geometric modification to surfaces.

|Port |Description |Type |Default|
|--------------|------------------------------------------------------------|------------------|-------|
|`displacement`|Scalar along the surface normal direction for each position.|float |0.0 |
|`scale` |Scale factor for the displacement vector. |float |1.0 |
|`out` |Output: displacement shader closure |displacementshader| |

|Port |Description |Type |Default |
|--------------|------------------------------------------------------------------------------|------------------|-------------|
|`displacement`|Vector displacement in (dPdu, dPdv, N) tangent/normal space for each position.|vector3 |0.0, 0.0, 0.0|
|`scale` |Scale factor for the displacement vector. |float |1.0 |
|`out` |Output: displacement shader closure |displacementshader| |

<a id="node-mix-shader"> </a>

### `mix`
Expand Down
17 changes: 12 additions & 5 deletions python/Scripts/comparenodedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def buildTypeGroupVariables(typeGroups):
def parseSpecTypes(typeStr):
'''
Parse a specification type string into (types, typeRef).
Handles "Same as X" and "Same as X or Y" patterns.

Supported patterns:
- Simple types: "float", "color3"
- Comma-separated: "float, color3"
- Union with "or": "BSDF or VDF", "BSDF, EDF, or VDF"
- Type references: "Same as bg", "Same as in1 or float"
'''
if typeStr is None or not typeStr.strip():
return set(), None
Expand All @@ -79,12 +84,14 @@ def parseSpecTypes(typeStr):
extraSet, _ = parseSpecTypes(extraTypes)
return extraSet, refPort

# Normalize "or" to comma: "X or Y" -> "X, Y", "X, Y, or Z" -> "X, Y, Z"
normalized = re.sub(r',?\s+or\s+', ', ', typeStr)

result = set()
for t in typeStr.split(','):
for t in normalized.split(','):
t = t.strip()
if not t:
continue
result.add(t)
if t:
result.add(t)

return result, None

Expand Down