Skip to content

Commit

Permalink
Initial commit legacy materials (#1398)
Browse files Browse the repository at this point in the history
* Initial commit legacy materials

This commit includes:
 - all Legacy (Protein) classes
 - procedural nodes (checker, noise, turbulence 2d/3d)
 - utilities (stain, normals combine nodes)

For now all nodes are under "adsk_legacy" group, except the turbulence ones that might be ok to be added to the standard lib.

Becasue of a bug in the handling of namespaces in the Graph Editor all namespaces are set to "". Bug: AcademySoftwareFoundation#1695

* Test files for legacy material

This includes a single MTLX file and a set of textures.
The MTLX file can be loaded in MaterialX Viewer and materials selected from the UI

* Adding values to test file

Adding values to all inputs to avoid warnings. This files generates no warning messages  when loaded in MaterialX viewer

Also fixing a small typo in the defs file

* USD test file

This is a USD test file that can be loaded in usdview to test the same materials that the legacy_materials_test.mtlx tests in MaterialX viewer.

Open the file in usdview, select the ShaderBall object and in the  Meta data panel you can select a variant for each material class.

The legacy materials node defs are also updated to remove a stub for namespace that was causing trouble in usdview (but was ok in MaterialX viewer).
A typo in the comments was also fixed.

* Stubs for OSL and MDL turbulence noise

Stubs for implementation of:
 - turbulence2d_float
 - turbulence3d_float
in OSL and MDL.
Currently returning a solid color. This is just to check the build warnings.

* Test for matching implementation count

Just a test to see if hardcoded expected skip count does influence overall implementation counters and failure to match.
Testing for glsl only.

* Revert "Test for matching implementation count"

This reverts commit 12e011f.

* Added test mtlx file for unused nodedefs

Tests were failing because the node turbulence2D was defined but never used in any TestSuite file.

Adding a other.mtlx as a container for these orphans nodes.
Note that for consistency I also added turbulence3d in there, even if not necessary as it's used in the main material test file.
  • Loading branch information
zicher3d authored Mar 14, 2024
1 parent 11daaa1 commit 05efae1
Show file tree
Hide file tree
Showing 40 changed files with 3,228 additions and 0 deletions.
333 changes: 333 additions & 0 deletions contrib/adsk/libraries/adsklib/adsklib_legacy_defs.mtlx

Large diffs are not rendered by default.

2,219 changes: 2,219 additions & 0 deletions contrib/adsk/libraries/adsklib/adsklib_legacy_ng.mtlx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
-->
<!-- <backface_util> -->
<implementation name="IM_backface_util_genglsl" nodedef="adsk:ND_backface_util" file="mx_backface_util.glsl" function="mx_backface_util" target="genglsl"/>

<implementation name="IM_turbulence2d_float_genglsl" nodedef="ND_turbulence2d_float" file="mx_turbulence2d_float.glsl" function="mx_turbulence2d_float" target="genglsl" />
<implementation name="IM_turbulence3d_float_genglsl" nodedef="ND_turbulence3d_float" file="mx_turbulence3d_float.glsl" function="mx_turbulence3d_float" target="genglsl" />

</materialx>
23 changes: 23 additions & 0 deletions contrib/adsk/libraries/adsklib/genglsl/mx_turbulence2d_float.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "../../stdlib/genglsl/lib/mx_noise.glsl"

void mx_turbulence2d_float(float amplitude, float octaves, vec2 texcoord, out float result)
{
float sum = 0.0;
float scale = 1.0;

// Accumulate the required number of octaves of noise.
float i = 0.0;
for (i = octaves; i >= 1.0; i -= 1.0) {
float value = mx_perlin_noise_float(texcoord * scale) / scale;
sum += abs(value);
scale *= 2.0;
}

// Add a portion of the remaining octave, if any.
if (i > 0.0) {
float value = mx_perlin_noise_float(texcoord * scale) / scale;
sum += abs(value) * i;
}

result = sum * amplitude;
}
23 changes: 23 additions & 0 deletions contrib/adsk/libraries/adsklib/genglsl/mx_turbulence3d_float.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "../../stdlib/genglsl/lib/mx_noise.glsl"

void mx_turbulence3d_float(float amplitude, float octaves, vec3 position, out float result)
{
float sum = 0.0;
float scale = 1.0;

// Accumulate the required number of octaves of noise.
float i = 0.0;
for (i = octaves; i >= 1.0; i -= 1.0) {
float value = mx_perlin_noise_float(position * scale) / scale;
sum += abs(value);
scale *= 2.0;
}

// Add a portion of the remaining octave, if any.
if (i > 0.0) {
float value = mx_perlin_noise_float(position * scale) / scale;
sum += abs(value) * i;
}

result = sum * amplitude;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@

<!-- <backface_util> todo: temporary implementation -->
<implementation name="IM_backface_util_genmdl" nodedef="adsk:ND_backface_util" sourcecode="color(1, 1, 1)" target="genmdl"/>

<implementation name="IM_turbulence2d_float_genmdl" nodedef="ND_turbulence2d_float" sourcecode="color(0.5, 0.5, 0.5)" target="genmdl" />
<implementation name="IM_turbulence3d_float_genmdl" nodedef="ND_turbulence3d_float" sourcecode="color(0.5, 0.5, 0.5)" target="genmdl" />

</materialx>
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
-->
<!-- <backface_util> -->
<implementation name="IM_backface_util_genosl" nodedef="adsk:ND_backface_util" file="mx_backface_util.osl" function="mx_backface_util" target="genosl"/>

<implementation name="IM_turbulence2d_float_genosl" nodedef="ND_turbulence2d_float" file="mx_turbulence2d_float.osl" function="mx_turbulence2d_float" target="genosl" />
<implementation name="IM_turbulence3d_float_genosl" nodedef="ND_turbulence3d_float" file="mx_turbulence3d_float.osl" function="mx_turbulence3d_float" target="genosl" />

</materialx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void mx_turbulence2d_float(float amplitude, float octaves, vector2 texcoord, output float result)
{
result = 0.5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void mx_turbulence3d_float(float amplitude, float octaves, vector position, output float result)
{
result = 0.5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#usda 1.0
(
defaultPrim = "ShaderBall"
metersPerUnit = 0.01
upAxis = "Y"
)

over "ShaderBall" (
references = @one_ball.usda@
variants = {
string shadingVariant = "Mirror"
}
prepend variantSets = "shadingVariant"
)
{
over "one_ball_MeshShape" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
}

variantSet "shadingVariant" = {
"Generic" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_generic>

}
}
"Mirror" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_mirror>

}
}
"Hardwood" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_hardwood>

}
}
"Metal" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_metal>

}
}
"Ceramic" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_ceramic>

}
}
"Concrete" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_concrete>

}
}
"Glazing" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_glazing>

}
}
"Masonry" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_masonry>

}
}
"MetallicPaint" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_metallicpaint>

}
}
"Glass" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_glass>

}
}
"Stone" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_stone>

}
}
"WallPaint" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_wallpaint>

}
}
"Water" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_water>

}
}
"Plastic" {
over "one_ball_MeshShape"
{
rel material:binding = </MaterialX/Materials/M_legacy_plastic>

}
}
}
}

over "MaterialX"
(
references = [
@legacy_materials_test.mtlx@</MaterialX>,
]
)
{
}
Loading

0 comments on commit 05efae1

Please sign in to comment.