Skip to content

Commit 1d99181

Browse files
Merge branch 'main' into pbr_blackbody
2 parents a573b0a + 2c50d91 commit 1d99181

33 files changed

Lines changed: 1762 additions & 1443 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ jobs:
203203
run: |
204204
python MaterialXTest/main.py
205205
python MaterialXTest/genshader.py
206-
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgradeVersion True
206+
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
207207
python Scripts/mxvalidate.py ../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose
208208
python Scripts/mxdoc.py --docType md ../libraries/pbrlib/pbrlib_defs.mtlx
209209
python Scripts/mxdoc.py --docType html ../libraries/bxdf/standard_surface.mtlx

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@ The [MaterialX Viewer](documents/DeveloperGuide/Viewer.md) leverages shader gene
3434

3535
**Figure 1:** Procedural and uniform materials in the MaterialX viewer
3636
<p float="left">
37-
<img src="/documents/Images/MaterialXView_Marble.png" width="204" />
38-
<img src="/documents/Images/MaterialXView_Copper.png" width="204" />
39-
<img src="/documents/Images/MaterialXView_Plastic.png" width="204" />
40-
<img src="/documents/Images/MaterialXView_Carpaint.png" width="204" />
37+
<img src="documents/Images/MaterialXView_Marble.png" width="204" />
38+
<img src="documents/Images/MaterialXView_Copper.png" width="204" />
39+
<img src="documents/Images/MaterialXView_Plastic.png" width="204" />
40+
<img src="documents/Images/MaterialXView_Carpaint.png" width="204" />
4141
</p>
4242

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

4949
### Open Chess Set
5050

5151
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.
5252

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

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

5959
### Pre-Built Binaries
6060

javascript/MaterialXTest/package-lock.json

Lines changed: 955 additions & 829 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/MaterialXTest/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
"author": "",
1717
"license": "ISC",
1818
"devDependencies": {
19-
"@babel/core": "^7.20.2",
20-
"@babel/preset-env": "^7.20.2",
21-
"@babel/register": "^7.18.9",
19+
"@babel/core": "^7.22.5",
20+
"@babel/preset-env": "^7.22.5",
21+
"@babel/register": "^7.22.5",
2222
"chai": "^4.3.7",
2323
"copyfiles": "^2.4.1",
24-
"karma": "^6.4.1",
24+
"karma": "^6.4.2",
2525
"karma-chai": "^0.1.0",
26-
"karma-chrome-launcher": "^3.1.1",
26+
"karma-chrome-launcher": "^3.2.0",
2727
"karma-mocha": "^2.0.1",
2828
"karma-mocha-reporter": "^2.2.5",
29-
"mocha": "^10.1.0",
29+
"mocha": "^10.2.0",
3030
"rimraf": "^3.0.2"
3131
}
3232
}

javascript/MaterialXView/package-lock.json

Lines changed: 381 additions & 300 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/MaterialXView/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"dependencies": {
1313
"dat.gui": "^0.7.9",
1414
"three": "^0.135.0",
15-
"webpack": "^5.75.0"
15+
"webpack": "^5.88.1"
1616
},
1717
"devDependencies": {
1818
"copy-webpack-plugin": "^8.1.1",
19-
"html-webpack-plugin": "^5.5.0",
19+
"html-webpack-plugin": "^5.5.3",
2020
"webpack-cli": "^4.10.0",
21-
"webpack-dev-server": "^4.11.1"
21+
"webpack-dev-server": "^4.15.1"
2222
}
2323
}

libraries/bxdf/gltf_pbr.mtlx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@
148148
<!-- Thin-film + Dielectric
149149
Note: Due to limitations in codegen, the base layer BSDF is duplicated (#1035). -->
150150

151-
<oren_nayar_diffuse_bsdf name="tf_diffuse_bsdf" type="BSDF">
152-
<input name="color" type="color3" interfacename="base_color" />
153-
<input name="normal" type="vector3" interfacename="normal" />
154-
</oren_nayar_diffuse_bsdf>
155-
156151
<dielectric_bsdf name="tf_transmission_bsdf" type="BSDF">
157152
<input name="weight" type="float" value="1" />
158153
<input name="tint" type="color3" interfacename="base_color" />
@@ -173,7 +168,7 @@
173168
</generalized_schlick_bsdf>
174169

175170
<mix name="tf_transmission_mix" type="BSDF">
176-
<input name="bg" type="BSDF" nodename="tf_diffuse_bsdf" />
171+
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
177172
<input name="fg" type="BSDF" nodename="tf_transmission_bsdf" />
178173
<input name="mix" type="float" interfacename="transmission" />
179174
</mix>

libraries/lights/genmsl/lights_genmsl_impl.mtlx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<materialx version="1.37">
2+
<materialx version="1.38">
33

44
<!-- <point_light> -->
55
<implementation name="IM_point_light_genmsl" nodedef="ND_point_light" file="mx_point_light.metal" function="mx_point_light" target="genmsl" />

libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
2323
// Compute derived properties.
2424
float NdotV = clamp(V.z, M_FLOAT_EPS, 1.0);
2525
float avgAlpha = mx_average_alpha(alpha);
26+
float G1V = mx_ggx_smith_G1(NdotV, avgAlpha);
2627

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

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

3940
// Compute dot products for this sample.
40-
float NdotH = clamp(H.z, M_FLOAT_EPS, 1.0);
4141
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
4242
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
43-
float LdotH = VdotH;
4443

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

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

69-
// Normalize and return the final radiance.
70-
radiance /= float(envRadianceSamples);
68+
// Apply the global component of the geometric term and normalize.
69+
radiance /= G1V * float(envRadianceSamples);
70+
71+
// Return the final radiance.
7172
return radiance;
7273
}
7374

libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,48 +61,22 @@ float mx_ggx_NDF(vec3 H, vec2 alpha)
6161
return 1.0 / (M_PI * alpha.x * alpha.y * mx_square(denom));
6262
}
6363

64-
// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
65-
// Appendix B.1 Equation 3
66-
float mx_ggx_PDF(vec3 H, float LdotH, vec2 alpha)
67-
{
68-
float NdotH = H.z;
69-
return mx_ggx_NDF(H, alpha) * NdotH / (4.0 * LdotH);
70-
}
71-
72-
// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
73-
// Appendix B.2 Equation 15
74-
vec3 mx_ggx_importance_sample_NDF(vec2 Xi, vec2 alpha)
75-
{
76-
float phi = 2.0 * M_PI * Xi.x;
77-
float tanTheta = sqrt(Xi.y / (1.0 - Xi.y));
78-
vec3 H = vec3(tanTheta * alpha.x * cos(phi),
79-
tanTheta * alpha.y * sin(phi),
80-
1.0);
81-
return normalize(H);
82-
}
83-
84-
// http://jcgt.org/published/0007/04/01/paper.pdf
85-
// Appendix A Listing 1
64+
// https://ggx-research.github.io/publication/2023/06/09/publication-ggx.html
8665
vec3 mx_ggx_importance_sample_VNDF(vec2 Xi, vec3 V, vec2 alpha)
8766
{
8867
// Transform the view direction to the hemisphere configuration.
8968
V = normalize(vec3(V.xy * alpha, V.z));
9069

91-
// Construct an orthonormal basis from the view direction.
92-
float len = length(V.xy);
93-
vec3 T1 = (len > 0.0) ? vec3(-V.y, V.x, 0.0) / len : vec3(1.0, 0.0, 0.0);
94-
vec3 T2 = cross(V, T1);
95-
96-
// Parameterization of the projected area.
97-
float r = sqrt(Xi.y);
70+
// Sample a spherical cap in (-V.z, 1].
9871
float phi = 2.0 * M_PI * Xi.x;
99-
float t1 = r * cos(phi);
100-
float t2 = r * sin(phi);
101-
float s = 0.5 * (1.0 + V.z);
102-
t2 = (1.0 - s) * sqrt(1.0 - mx_square(t1)) + s * t2;
103-
104-
// Reprojection onto hemisphere.
105-
vec3 H = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - mx_square(t1) - mx_square(t2))) * V;
72+
float z = (1.0 - Xi.y) * (1.0 + V.z) - V.z;
73+
float sinTheta = sqrt(clamp(1.0 - z * z, 0.0, 1.0));
74+
float x = sinTheta * cos(phi);
75+
float y = sinTheta * sin(phi);
76+
vec3 c = vec3(x, y, z);
77+
78+
// Compute the microfacet normal.
79+
vec3 H = c + V;
10680

10781
// Transform the microfacet normal back to the ellipsoid configuration.
10882
H = normalize(vec3(H.xy * alpha, max(H.z, 0.0)));

0 commit comments

Comments
 (0)