Skip to content

Commit 22f178f

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into uri_for_viewer
2 parents 4dc7cf7 + 3c78aa1 commit 22f178f

55 files changed

Lines changed: 738 additions & 610 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: MacOS_Xcode_15_Python311
7171
os: macos-15
7272
compiler: xcode
73-
compiler_version: "15.4"
73+
compiler_version: "16.1"
7474
python: 3.11
7575
test_shaders: ON
7676

@@ -97,11 +97,11 @@ jobs:
9797
python: None
9898
cmake_config: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path` -DCMAKE_OSX_ARCHITECTURES=arm64
9999

100-
- name: Windows_VS2019_Win32_Python39
101-
os: windows-2019
100+
- name: Windows_VS2022_Win32_Python39
101+
os: windows-2022
102102
architecture: x86
103103
python: 3.9
104-
cmake_config: -G "Visual Studio 16 2019" -A "Win32"
104+
cmake_config: -G "Visual Studio 17 2022" -A "Win32"
105105

106106
- name: Windows_VS2022_x64_Python311
107107
os: windows-2025

documents/Specification/MaterialX.PBRSpec.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The PBS nodes also make use of the following standard MaterialX types:
162162

163163
<a id="node-oren-nayar-diffuse-bsdf"> </a>
164164

165-
* **`oren_nayar_diffuse_bsdf`**: Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance model. A `roughness` of 0.0 gives Lambertian reflectance. An `energy_compensation` boolean selects between classic Oren-Nayar behavior[^Oren1994] and the energy-compensated Oren-Nayar in OpenPBR[^Andersson2024].
165+
* **`oren_nayar_diffuse_bsdf`**: Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance model. A `roughness` of 0.0 gives Lambertian reflectance. An `energy_compensation` boolean selects between the Qualitative Oren-Nayar[^Oren1994] and Energy-Preserving Oren-Nayar[^Portsmouth2025] models of diffuse reflectance.
166166
* `weight` (float): Weight for this BSDF’s contribution, range [0.0, 1.0]. Defaults to 1.0.
167167
* `color` (color3): Diffuse reflectivity (albedo). Defaults to (0.18, 0.18, 0.18).
168168
* `roughness `(float): Surface roughness, range [0.0, 1.0]. Defaults to 0.0.
@@ -500,12 +500,14 @@ Path Tracing**, <https://media.disneyanimation.com/uploads/production/publicatio
500500

501501
[^Marschner2003]: Stephen R. Marschner et al., **Light Scattering from Human Hair Fibers**, <http://www.graphics.stanford.edu/papers/hair/hair-sg03final.pdf>, 2003
502502

503-
[^Oren1994]: Michael Oren, Shree K. Nayar, **Generalization of Lambert’s Reflectance Model**, <https://www1.cs.columbia.edu/CAVE/publications/pdfs/Oren_SIGGRAPH94.pdf>, 1994
503+
[^Oren1994]: Michael Oren, Shree K. Nayar, **Generalization of Lambert’s Reflectance Model**, <https://dl.acm.org/doi/10.1145/192161.192213>, 1994
504504

505505
[^Pharr2023]: Matt Pharr et al., **Physically Based Rendering: From Theory To Implementation**, <https://www.pbr-book.org/>, 2023
506506

507507
[^Pixar2019]: Pixar Animation Studios, **UsdPreviewSurface Specification**, <https://openusd.org/release/spec_usdpreviewsurface.html>, 2019.
508508

509+
[^Portsmouth2025]: Portsmouth et al., **EON: A practical energy-preserving rough diffuse BRDF**, <https://www.jcgt.org/published/0014/01/06/>, 2025.
510+
509511
[^Walter2007]: Bruce Walter et al., **Microfacet Models for Refraction through Rough Surfaces**, <https://www.graphics.cornell.edu/~bjw/microfacetbsdf.pdf>, 2007
510512

511513
[^Zeltner2022]: Tizian Zeltner et al., **Practical Multiple-Scattering Sheen Using Linearly Transformed Cosines**, <https://tizianzeltner.com/projects/Zeltner2022Practical/>, 2022

javascript/MaterialXView/source/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,19 @@ function onWindowResize()
170170
function animate()
171171
{
172172
requestAnimationFrame(animate);
173+
const scene = viewer.getScene();
173174

174175
if (turntableEnabled)
175176
{
176177
turntableStep = (turntableStep + 1) % 360;
177178
var turntableAngle = turntableStep * (360.0 / turntableSteps) / 180.0 * Math.PI;
178-
viewer.getScene()._scene.rotation.y = turntableAngle;
179-
viewer.getScene().setUpdateTransforms();
179+
scene._scene.rotation.y = turntableAngle;
180+
scene.setUpdateTransforms();
180181
}
181182

182-
renderer.render(viewer.getScene().getScene(), viewer.getScene().getCamera());
183-
viewer.getScene().updateTransforms();
183+
scene.updateUniforms();
184+
renderer.render(scene.getScene(), scene.getCamera());
185+
scene.updateTransforms();
184186

185187
if (captureRequested)
186188
{

javascript/MaterialXView/source/viewer.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export class Scene
4343
const cameraFarDist = 100.0;
4444
const cameraFOV = 60.0;
4545
this._camera = new THREE.PerspectiveCamera(cameraFOV, aspectRatio, cameraNearDist, cameraFarDist);
46-
46+
this._frame = 0;
47+
4748
this.#_gltfLoader = new GLTFLoader();
4849

4950
this.#_normalMat = new THREE.Matrix3();
@@ -265,6 +266,37 @@ export class Scene
265266
});
266267
}
267268

269+
/**
270+
* Update uniforms for all scene objects. This is called once per frame
271+
* and updates time and frame count uniforms.
272+
*/
273+
updateUniforms() {
274+
this._frame++;
275+
276+
const scene = this.getScene();
277+
const time = performance.now() / 1000.0;
278+
const frame = this._frame;
279+
280+
scene.traverse((child) =>
281+
{
282+
if (child.isMesh && child.material && child.material.uniforms)
283+
{
284+
const uniforms = child.material.uniforms;
285+
if (uniforms)
286+
{
287+
if (uniforms.u_time)
288+
{
289+
uniforms.u_time.value = time;
290+
}
291+
if (uniforms.u_frame)
292+
{
293+
uniforms.u_frame.value = frame;
294+
}
295+
}
296+
}
297+
});
298+
}
299+
268300
// Determine string DAG path based on individual node names.
269301
getDagPath(node)
270302
{
@@ -1414,6 +1446,40 @@ export class Material
14141446
break;
14151447

14161448
case 'color4':
1449+
uniformToUpdate = material.uniforms[name];
1450+
if (uniformToUpdate && value != null)
1451+
{
1452+
var dummy =
1453+
{
1454+
color: 0xFF0000
1455+
};
1456+
// Extract RGB from the color4 value
1457+
const color3 = new THREE.Color();
1458+
color3.fromArray(material.uniforms[name].value);
1459+
dummy.color = color3.getHex();
1460+
let alphaValue = material.uniforms[name].value[3]; // Get alpha component
1461+
1462+
// Add the RGB color picker as one item
1463+
let colorPicker = currentFolder.addColor(dummy, 'color').name(path + '.rgb')
1464+
.onChange(function (value)
1465+
{
1466+
const color3 = new THREE.Color(value);
1467+
// Update RGB while preserving alpha
1468+
material.uniforms[name].value[0] = color3.r;
1469+
material.uniforms[name].value[1] = color3.g;
1470+
material.uniforms[name].value[2] = color3.b;
1471+
});
1472+
colorPicker.domElement.classList.add('peditoritem');
1473+
1474+
// Add the alpha slider as a separate item at the same level
1475+
var alphaObj = { value: alphaValue };
1476+
let alphaSlider = currentFolder.add(alphaObj, 'value', 0, 1, 0.01).name(path + '.alpha')
1477+
.onChange(function (value)
1478+
{
1479+
material.uniforms[name].value[3] = value;
1480+
});
1481+
alphaSlider.domElement.classList.add('peditoritem');
1482+
}
14171483
break;
14181484

14191485
case 'matrix33':

0 commit comments

Comments
 (0)