Skip to content

Commit

Permalink
Extend Chiang tests across languages (AcademySoftwareFoundation#2104)
Browse files Browse the repository at this point in the history
This changelist extends testing of Chiang Hair BSDF nodes across shading languages, allowing render comparisons to include the complete Examples and TestSuite folders.

In order to avoid shader compilation errors, placeholder OSL implementations of these nodes have been added, and these should be replaced with accurate implementations once they are supported.
  • Loading branch information
jstone-lucasfilm authored Nov 2, 2024
1 parent 4339aaa commit bef88b9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
7 changes: 7 additions & 0 deletions libraries/pbrlib/genosl/mx_chiang_hair_roughness.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void mx_chiang_hair_roughness(float longitudinal, float azimuthal, float scale_TT, float scale_TRT, output vector2 roughness_R, output vector2 roughness_TT, output vector2 roughness_TRT)
{
// TODO: Write OSL implementation of this node.
roughness_R = vector2(0.0, 0.0);
roughness_TT = vector2(0.0, 0.0);
roughness_TRT = vector2(0.0, 0.0);
}
12 changes: 12 additions & 0 deletions libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<!-- <subsurface_bsdf> -->
<implementation name="IM_subsurface_bsdf_genosl" nodedef="ND_subsurface_bsdf" file="mx_subsurface_bsdf.osl" function="mx_subsurface_bsdf" target="genosl" />

<!-- <chiang_hair_bsdf> -->
<implementation name="IM_chiang_hair_bsdf_genosl" nodedef="ND_chiang_hair_bsdf" sourcecode="oren_nayar_diffuse_bsdf({{normal}}, {{tint_R}}, 0.0)" target="genosl" />

<!-- <sheen_bsdf> -->
<implementation name="IM_sheen_bsdf_genosl" nodedef="ND_sheen_bsdf" sourcecode="{{weight}} * sheen_bsdf({{normal}}, {{color}}, {{roughness}})" target="genosl" />

Expand Down Expand Up @@ -71,4 +74,13 @@
<!-- <blackbody> -->
<implementation name="IM_blackbody_genosl" nodedef="ND_blackbody" file="mx_blackbody.osl" function="mx_blackbody" target="genosl" />

<!-- <deon_hair_absorption_from_melanin> -->
<implementation name="IM_deon_hair_absorption_from_melanin_genosl" nodedef="ND_deon_hair_absorption_from_melanin" sourcecode="vector(1.0)" target="genosl" />

<!-- <chiang_hair_absorption_from_color> -->
<implementation name="IM_chiang_hair_absorption_from_color_genosl" nodedef="ND_chiang_hair_absorption_from_color" sourcecode="vector(1.0)" target="genosl" />

<!-- <chiang_hair_roughness> -->
<implementation name="IM_chiang_hair_roughness_genosl" nodedef="ND_chiang_hair_roughness" file="mx_chiang_hair_roughness.osl" function="mx_chiang_hair_roughness" target="genosl" />

</materialx>
7 changes: 1 addition & 6 deletions source/MaterialXTest/MaterialXGenMsl/GenMsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ TEST_CASE("GenShader: MSL Implementation Check", "[genmsl]")

mx::StringSet generatorSkipNodeTypes;
mx::StringSet generatorSkipNodeDefs;
generatorSkipNodeDefs.insert("ND_chiang_hair_roughness");
generatorSkipNodeDefs.insert("ND_chiang_hair_absorption_from_color");
generatorSkipNodeDefs.insert("ND_deon_hair_absorption_from_melanin");
generatorSkipNodeDefs.insert("ND_chiang_hair_bsdf");

GenShaderUtil::checkImplementations(context, generatorSkipNodeTypes, generatorSkipNodeDefs, 34);
GenShaderUtil::checkImplementations(context, generatorSkipNodeTypes, generatorSkipNodeDefs, 30);
}

TEST_CASE("GenShader: MSL Unique Names", "[genmsl]")
Expand Down
2 changes: 0 additions & 2 deletions source/MaterialXTest/MaterialXGenMsl/GenMsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class MslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester

void addSkipFiles() override
{
_skipFiles.insert("hair_bsdf.mtlx");
_skipFiles.insert("hair_surfaceshader.mtlx");
}

void setupDependentLibraries() override
Expand Down
6 changes: 1 addition & 5 deletions source/MaterialXTest/MaterialXGenOsl/GenOsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,8 @@ TEST_CASE("GenShader: OSL Implementation Check", "[genosl]")
generatorSkipNodeTypes.insert("light");

mx::StringSet generatorSkipNodeDefs;
generatorSkipNodeDefs.insert("ND_chiang_hair_roughness");
generatorSkipNodeDefs.insert("ND_chiang_hair_absorption_from_color");
generatorSkipNodeDefs.insert("ND_deon_hair_absorption_from_melanin");
generatorSkipNodeDefs.insert("ND_chiang_hair_bsdf");

GenShaderUtil::checkImplementations(context, generatorSkipNodeTypes, generatorSkipNodeDefs, 35);
GenShaderUtil::checkImplementations(context, generatorSkipNodeTypes, generatorSkipNodeDefs, 31);
}

TEST_CASE("GenShader: OSL Unique Names", "[genosl]")
Expand Down
2 changes: 0 additions & 2 deletions source/MaterialXTest/MaterialXGenOsl/GenOsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class OslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester

void addSkipFiles() override
{
_skipFiles.insert("hair_bsdf.mtlx");
_skipFiles.insert("hair_surfaceshader.mtlx");
}

// Ignore light shaders in the document for OSL
Expand Down

0 comments on commit bef88b9

Please sign in to comment.