-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for recursive structs, with example.
Add "_struct" suffix to struct type name to avoid potential name clashes with variable names. Add AggregateValue to centralize struct string parsing. Add support for recursive structs in places - may not be complete yet - centralized syntax parsing - and unit tests pass currently. refactor struct experiment to not unfold the structs, but instead maintain them in the shaders
- Loading branch information
Showing
47 changed files
with
1,305 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
Declarations of experimental data types and nodes | ||
--> | ||
|
||
<!-- name clashes with variable names will hopefully be resolved by | ||
recommending struct type names be suffixed with `_struct` --> | ||
|
||
<typedef name="texcoord_struct"> | ||
<member name="ss" type="float" value="0.5"/> | ||
<member name="tt" type="float" value="0.5"/> | ||
</typedef> | ||
|
||
<typedef name="texcoordGroup_struct"> | ||
<member name="st_0" type="texcoord_struct" value="{0.1;0.1}"/> | ||
<member name="st_1" type="texcoord_struct" value="{0.5;0.5}"/> | ||
<member name="st_2" type="texcoord_struct" value="{0.9;0.9}"/> | ||
</typedef> | ||
|
||
<nodedef name="ND_extract_s_texcoord" node="extracts" nodegroup="shader" > | ||
<input name="in" type="texcoord_struct" value="{0.1;0.1}" /> | ||
<output name="out" type="float" value="0.0" /> | ||
</nodedef> | ||
|
||
<nodedef name="ND_extract_s_texcoordGroup" node="extractsgroup" nodegroup="shader" > | ||
<input name="in" type="texcoordGroup_struct" value="{{0.1;0.2};{0.3;0.4};{0.5;0.6}}"/> | ||
<input name="index" type="integer" value="0"/> | ||
<output name="out" type="float" value="0.0" /> | ||
</nodedef> | ||
|
||
</materialx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
Nodegraph Implementations of experimental nodes | ||
--> | ||
|
||
</materialx> |
15 changes: 15 additions & 0 deletions
15
libraries/experimental/genglsl/experimental_genglsl_impl.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
GLSL Implementations of experimental nodes | ||
--> | ||
|
||
<implementation name="IM_extract_s_texcoord_genglsl" nodedef="ND_extract_s_texcoord" target="genglsl" sourcecode="{{in}}.ss" /> | ||
<implementation name="IM_extract_s_texcoordGroup_genglsl" nodedef="ND_extract_s_texcoordGroup" file="./mx_extractgroup.glsl" function="mx_extractGroup" target="genglsl"> | ||
<input name="in" type="texcoordGroup_struct" implname="data" /> | ||
</implementation> | ||
|
||
</materialx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
void mx_extractGroup(texcoordGroup_struct data, int index, out float result) | ||
{ | ||
result = data.st_0.ss; | ||
|
||
if (index == 1) | ||
result = data.st_1.ss; | ||
else if (index == 2) | ||
result = data.st_2.ss; | ||
} |
14 changes: 14 additions & 0 deletions
14
libraries/experimental/genmdl/experimental_genmdl_impl.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
GLSL Implementations of experimental nodes | ||
--> | ||
|
||
<implementation name="IM_extract_s_texcoord_genmdl" nodedef="ND_extract_s_texcoord" target="genmdl" sourcecode="{{in}}.ss" /> | ||
|
||
<implementation name="IM_extract_s_texcoordGroup_genmdl" nodedef="ND_extract_s_texcoordGroup" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_extractGroup({{in}}, {{index}})" target="genmdl" /> | ||
|
||
</materialx> |
15 changes: 15 additions & 0 deletions
15
libraries/experimental/genmsl/experimental_genmsl_impl.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
MSL Implementations of experimental nodes | ||
--> | ||
|
||
<implementation name="IM_extract_s_texcoord_genmsl" nodedef="ND_extract_s_texcoord" target="genmsl" sourcecode="{{in}}.ss" /> | ||
|
||
<implementation name="IM_extract_s_texcoordGroup_genmsl" nodedef="ND_extract_s_texcoordGroup" file="../genglsl/mx_extractgroup.glsl" function="mx_extractGroup" target="genmsl"> | ||
<input name="in" type="texcoordGroup_struct" implname="data" /> | ||
</implementation> | ||
</materialx> |
16 changes: 16 additions & 0 deletions
16
libraries/experimental/genosl/experimental_genosl_impl.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<!-- | ||
Copyright Contributors to the MaterialX Project | ||
SPDX-License-Identifier: Apache-2.0 | ||
GLSL Implementations of experimental nodes | ||
--> | ||
|
||
<implementation name="IM_extract_s_texcoord_genosl" nodedef="ND_extract_s_texcoord" target="genosl" sourcecode="{{in}}.ss" /> | ||
|
||
<implementation name="IM_extract_s_texcoordGroup_genosl" nodedef="ND_extract_s_texcoordGroup" file="./mx_extractgroup.osl" function="mx_extractGroup" target="genosl"> | ||
<input name="in" type="texcoordGroup_struct" implname="data" /> | ||
</implementation> | ||
|
||
</materialx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void mx_extractGroup(texcoordGroup_struct data, int index, out float result) | ||
{ | ||
result = data.st_0.ss; | ||
|
||
if (index == 1) | ||
result = data.st_1.ss; | ||
else if (index == 2) | ||
result = data.st_2.ss; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
resources/Materials/TestSuite/experimental/struct/struct_texcoord.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<nodegraph name="test_struct_texcoord"> | ||
|
||
<extracts name="extracts" type="float"> | ||
<input name="in" type="texcoord_struct" value="{0.01;0.5}"/> | ||
</extracts> | ||
|
||
<convert name="float_to_color3" type="color3"> | ||
<input name="in" type="float" nodename="extracts"/> | ||
</convert> | ||
<oren_nayar_diffuse_bsdf name="diffuse_brdf1" type="BSDF"> | ||
<input name="color" type="color3" nodename="float_to_color3" /> | ||
</oren_nayar_diffuse_bsdf> | ||
<surface name="surface1" type="surfaceshader"> | ||
<input name="bsdf" type="BSDF" nodename="diffuse_brdf1" /> | ||
<input name="opacity" type="float" value="1.0" /> | ||
</surface> | ||
<output name="out" type="surfaceshader" nodename="surface1" /> | ||
</nodegraph> | ||
</materialx> |
22 changes: 22 additions & 0 deletions
22
resources/Materials/TestSuite/experimental/struct/struct_texcoordGroup.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
<nodegraph name="test_struct_texcoord"> | ||
|
||
<extractsgroup name="extracts_group" type="float"> | ||
<input name="in" type="texcoordGroup_struct" value="{{0.1;0.2};{0.3;0.4};{0.5;0.6}}"/> | ||
<input name="index" type="integer" value="0"/> | ||
</extractsgroup> | ||
|
||
<convert name="float_to_color3" type="color3"> | ||
<input name="in" type="float" nodename="extracts_group"/> | ||
</convert> | ||
<oren_nayar_diffuse_bsdf name="diffuse_brdf1" type="BSDF"> | ||
<input name="color" type="color3" nodename="float_to_color3" /> | ||
</oren_nayar_diffuse_bsdf> | ||
<surface name="surface1" type="surfaceshader"> | ||
<input name="bsdf" type="BSDF" nodename="diffuse_brdf1" /> | ||
<input name="opacity" type="float" value="1.0" /> | ||
</surface> | ||
<output name="out" type="surfaceshader" nodename="surface1" /> | ||
</nodegraph> | ||
</materialx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.