Skip to content

Commit

Permalink
Merge branch 'main' into pbr_blackbody
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm authored Jul 11, 2023
2 parents a573b0a + 2c50d91 commit 1d99181
Show file tree
Hide file tree
Showing 33 changed files with 1,762 additions and 1,443 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
run: |
python MaterialXTest/main.py
python MaterialXTest/genshader.py
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgradeVersion True
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
python Scripts/mxvalidate.py ../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose
python Scripts/mxdoc.py --docType md ../libraries/pbrlib/pbrlib_defs.mtlx
python Scripts/mxdoc.py --docType html ../libraries/bxdf/standard_surface.mtlx
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ The [MaterialX Viewer](documents/DeveloperGuide/Viewer.md) leverages shader gene

**Figure 1:** Procedural and uniform materials in the MaterialX viewer
<p float="left">
<img src="/documents/Images/MaterialXView_Marble.png" width="204" />
<img src="/documents/Images/MaterialXView_Copper.png" width="204" />
<img src="/documents/Images/MaterialXView_Plastic.png" width="204" />
<img src="/documents/Images/MaterialXView_Carpaint.png" width="204" />
<img src="documents/Images/MaterialXView_Marble.png" width="204" />
<img src="documents/Images/MaterialXView_Copper.png" width="204" />
<img src="documents/Images/MaterialXView_Plastic.png" width="204" />
<img src="documents/Images/MaterialXView_Carpaint.png" width="204" />
</p>

**Figure 2:** Textured, color-space-managed materials in the MaterialX viewer
<p float="left">
<img src="/documents/Images/MaterialXView_TiledBrass.png" width="412" />
<img src="/documents/Images/MaterialXView_TiledWood.png" width="412" />
<img src="documents/Images/MaterialXView_TiledBrass.png" width="412" />
<img src="documents/Images/MaterialXView_TiledWood.png" width="412" />
</p>

### Open Chess Set

The Open Chess Set is an open reference asset, consisting of a [MaterialX file](resources/Materials/Examples/StandardSurface/standard_surface_chess_set.mtlx) in the Standard Surface shading model and a [geometry file](resources/Geometry) in the glTF format. It was authored by Moeen Sayed and Mujtaba Sayed, and was contributed to the MaterialX project by Side Effects.

**Figure 3:** The Open Chess Set, rendered in Arnold for Maya
<img src="/documents/Images/OpenChessSet_Arnold_01.png" />
<img src="documents/Images/OpenChessSet_Arnold_01.png" />

**Figure 4:** The Open Chess Set, rendered in Karma XPU for Houdini
<img src="/documents/Images/OpenChessSet_Karma_01.png" />
<img src="documents/Images/OpenChessSet_Karma_01.png" />

### Pre-Built Binaries

Expand Down
1,784 changes: 955 additions & 829 deletions javascript/MaterialXTest/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions javascript/MaterialXTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/register": "^7.22.5",
"chai": "^4.3.7",
"copyfiles": "^2.4.1",
"karma": "^6.4.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-chrome-launcher": "^3.2.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^10.1.0",
"mocha": "^10.2.0",
"rimraf": "^3.0.2"
}
}
681 changes: 381 additions & 300 deletions javascript/MaterialXView/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions javascript/MaterialXView/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"dependencies": {
"dat.gui": "^0.7.9",
"three": "^0.135.0",
"webpack": "^5.75.0"
"webpack": "^5.88.1"
},
"devDependencies": {
"copy-webpack-plugin": "^8.1.1",
"html-webpack-plugin": "^5.5.0",
"html-webpack-plugin": "^5.5.3",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
"webpack-dev-server": "^4.15.1"
}
}
7 changes: 1 addition & 6 deletions libraries/bxdf/gltf_pbr.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@
<!-- Thin-film + Dielectric
Note: Due to limitations in codegen, the base layer BSDF is duplicated (#1035). -->

<oren_nayar_diffuse_bsdf name="tf_diffuse_bsdf" type="BSDF">
<input name="color" type="color3" interfacename="base_color" />
<input name="normal" type="vector3" interfacename="normal" />
</oren_nayar_diffuse_bsdf>

<dielectric_bsdf name="tf_transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="tint" type="color3" interfacename="base_color" />
Expand All @@ -173,7 +168,7 @@
</generalized_schlick_bsdf>

<mix name="tf_transmission_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="tf_diffuse_bsdf" />
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="fg" type="BSDF" nodename="tf_transmission_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>
Expand Down
2 changes: 1 addition & 1 deletion libraries/lights/genmsl/lights_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<materialx version="1.37">
<materialx version="1.38">

<!-- <point_light> -->
<implementation name="IM_point_light_genmsl" nodedef="ND_point_light" file="mx_point_light.metal" function="mx_point_light" target="genmsl" />
Expand Down
17 changes: 9 additions & 8 deletions libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
// Compute derived properties.
float NdotV = clamp(V.z, M_FLOAT_EPS, 1.0);
float avgAlpha = mx_average_alpha(alpha);
float G1V = mx_ggx_smith_G1(NdotV, avgAlpha);

// Integrate outgoing radiance using filtered importance sampling.
// http://cgg.mff.cuni.cz/~jaroslav/papers/2008-egsr-fis/2008-egsr-fis-final-embedded.pdf
Expand All @@ -33,18 +34,16 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples);

// Compute the half vector and incoming light direction.
vec3 H = mx_ggx_importance_sample_NDF(Xi, alpha);
vec3 H = mx_ggx_importance_sample_VNDF(Xi, V, alpha);
vec3 L = fd.refraction ? mx_refraction_solid_sphere(-V, H, fd.ior.x) : -reflect(V, H);

// Compute dot products for this sample.
float NdotH = clamp(H.z, M_FLOAT_EPS, 1.0);
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
float LdotH = VdotH;

// Sample the environment light from the given direction.
vec3 Lw = tangentToWorld * L;
float pdf = mx_ggx_PDF(H, LdotH, alpha);
float pdf = mx_ggx_NDF(H, alpha) * G1V / (4.0 * NdotV);
float lod = mx_latlong_compute_lod(Lw, pdf, float($envRadianceMips - 1), envRadianceSamples);
vec3 sampleColor = mx_latlong_map_lookup(Lw, $envMatrix, lod, $envRadiance);

Expand All @@ -61,13 +60,15 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
// From https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
// incidentLight = sampleColor * NdotL
// microfacetSpecular = D * F * G / (4 * NdotL * NdotV)
// pdf = D * NdotH / (4 * VdotH)
// pdf = D * G1V / (4 * NdotV);
// radiance = incidentLight * microfacetSpecular / pdf
radiance += sampleColor * FG * VdotH / (NdotV * NdotH);
radiance += sampleColor * FG;
}

// Normalize and return the final radiance.
radiance /= float(envRadianceSamples);
// Apply the global component of the geometric term and normalize.
radiance /= G1V * float(envRadianceSamples);

// Return the final radiance.
return radiance;
}

Expand Down
46 changes: 10 additions & 36 deletions libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,22 @@ float mx_ggx_NDF(vec3 H, vec2 alpha)
return 1.0 / (M_PI * alpha.x * alpha.y * mx_square(denom));
}

// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
// Appendix B.1 Equation 3
float mx_ggx_PDF(vec3 H, float LdotH, vec2 alpha)
{
float NdotH = H.z;
return mx_ggx_NDF(H, alpha) * NdotH / (4.0 * LdotH);
}

// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
// Appendix B.2 Equation 15
vec3 mx_ggx_importance_sample_NDF(vec2 Xi, vec2 alpha)
{
float phi = 2.0 * M_PI * Xi.x;
float tanTheta = sqrt(Xi.y / (1.0 - Xi.y));
vec3 H = vec3(tanTheta * alpha.x * cos(phi),
tanTheta * alpha.y * sin(phi),
1.0);
return normalize(H);
}

// http://jcgt.org/published/0007/04/01/paper.pdf
// Appendix A Listing 1
// https://ggx-research.github.io/publication/2023/06/09/publication-ggx.html
vec3 mx_ggx_importance_sample_VNDF(vec2 Xi, vec3 V, vec2 alpha)
{
// Transform the view direction to the hemisphere configuration.
V = normalize(vec3(V.xy * alpha, V.z));

// Construct an orthonormal basis from the view direction.
float len = length(V.xy);
vec3 T1 = (len > 0.0) ? vec3(-V.y, V.x, 0.0) / len : vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, T1);

// Parameterization of the projected area.
float r = sqrt(Xi.y);
// Sample a spherical cap in (-V.z, 1].
float phi = 2.0 * M_PI * Xi.x;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + V.z);
t2 = (1.0 - s) * sqrt(1.0 - mx_square(t1)) + s * t2;

// Reprojection onto hemisphere.
vec3 H = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - mx_square(t1) - mx_square(t2))) * V;
float z = (1.0 - Xi.y) * (1.0 + V.z) - V.z;
float sinTheta = sqrt(clamp(1.0 - z * z, 0.0, 1.0));
float x = sinTheta * cos(phi);
float y = sinTheta * sin(phi);
vec3 c = vec3(x, y, z);

// Compute the microfacet normal.
vec3 H = c + V;

// Transform the microfacet normal back to the ellipsoid configuration.
H = normalize(vec3(H.xy * alpha, max(H.z, 0.0)));
Expand Down
4 changes: 2 additions & 2 deletions libraries/pbrlib/pbrlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
-->
<nodedef name="ND_conductor_bsdf" node="conductor_bsdf" bsdf="R" nodegroup="pbr" doc="A reflection BSDF node based on a microfacet model and a Fresnel curve for conductors/metals.">
<input name="weight" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="ior" type="color3" value="0.271, 0.677, 1.316" colorspace="none" />
<input name="extinction" type="color3" value="3.609, 2.625, 2.292" colorspace="none" />
<input name="ior" type="color3" value="0.183, 0.421, 1.373" colorspace="none" />
<input name="extinction" type="color3" value="3.424, 2.346, 1.770" colorspace="none" />
<input name="roughness" type="vector2" value="0.05, 0.05" />
<input name="normal" type="vector3" defaultgeomprop="Nworld" />
<input name="tangent" type="vector3" defaultgeomprop="Tworld" />
Expand Down
10 changes: 8 additions & 2 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
Node: <triplanarprojection> Supplemental Node
Samples data from three images, or layers within multi-layer images, and projects a tiled
representation of the images along each of the three respective coordinate axes, computing
a weighted blend of the three samples using the geometric normal.
an adjustable weighted blend of the three samples using the geometric normal.
-->
<nodedef name="ND_triplanarprojection_float" node="triplanarprojection" nodegroup="texture3d">
<input name="filex" type="filename" value="" uniform="true" />
Expand All @@ -307,6 +307,7 @@
<input name="default" type="float" value="0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand All @@ -323,6 +324,7 @@
<input name="default" type="color3" value="0.0, 0.0, 0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand All @@ -339,6 +341,7 @@
<input name="default" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand All @@ -355,6 +358,7 @@
<input name="default" type="vector2" value="0.0, 0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand All @@ -371,6 +375,7 @@
<input name="default" type="vector3" value="0.0, 0.0, 0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand All @@ -387,6 +392,7 @@
<input name="default" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="position" type="vector3" defaultgeomprop="Pobject" />
<input name="normal" type="vector3" defaultgeomprop="Nobject" />
<input name="blend" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="filtertype" type="string" value="linear" enum="closest,linear,cubic" uniform="true" />
<input name="framerange" type="string" value="" uniform="true" />
<input name="frameoffset" type="integer" value="0" uniform="true" />
Expand Down Expand Up @@ -2274,7 +2280,7 @@
<input name="in2" type="vector4" uiname="in2" value="0.0, 0.0, 0.0, 0.0" />
<output name="out" type="float" />
</nodedef>

<!--
Node: <dotproduct>
Perform a dot product of two 2-4 channel vectors
Expand Down
Loading

0 comments on commit 1d99181

Please sign in to comment.