Skip to content

Commit a5ac56d

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into editor_capture
2 parents 202c434 + 3c78aa1 commit a5ac56d

10 files changed

Lines changed: 336 additions & 88 deletions

File tree

.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

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':

libraries/bxdf/gltf_pbr.mtlx

Lines changed: 140 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<input name="thickness" uniform="false" type="float" value="0" uimin="0" uiname="Thickness" uifolder="Volume" />
2828
<input name="attenuation_distance" uniform="true" type="float" uimin="0" uiname="Attenuation Distance" uifolder="Volume" />
2929
<input name="attenuation_color" uniform="true" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Attenuation Color" uifolder="Volume" />
30+
<input name="anisotropy_strength" type="float" value="0" uimin="0" uimax="1" uiname="Anisotropy Strength" uifolder="Anisotropy" />
31+
<input name="anisotropy_rotation" type="float" value="0" uimin="0" uimax="6.283185" uiname="Anisotropy Rotation" uifolder="Anisotropy" />
3032
<output name="out" type="surfaceshader" />
3133
</nodedef>
3234

@@ -104,9 +106,33 @@
104106

105107
<!-- Roughness -->
106108

107-
<roughness_anisotropy name="roughness_uv" type="vector2">
108-
<input name="roughness" type="float" interfacename="roughness" />
109-
</roughness_anisotropy>
109+
<combine2 name="roughness_uv" type="vector2">
110+
<input name="in1" type="float" nodename="clamped_at" />
111+
<input name="in2" type="float" nodename="clamped_ab" />
112+
</combine2>
113+
<clamp name="clamped_at" type="float">
114+
<input name="in" type="float" nodename="at" />
115+
<input name="low" type="float" value="0.00001" />
116+
<input name="high" type="float" value="1.0" />
117+
</clamp>
118+
<clamp name="clamped_ab" type="float">
119+
<input name="in" type="float" nodename="alpha_roughness" />
120+
<input name="low" type="float" value="0.00001" />
121+
<input name="high" type="float" value="1.0" />
122+
</clamp>
123+
<multiply name="alpha_roughness" type="float">
124+
<input name="in1" type="float" interfacename="roughness" />
125+
<input name="in2" type="float" interfacename="roughness" />
126+
</multiply>
127+
<multiply name="strength_2" type="float">
128+
<input name="in1" type="float" interfacename="anisotropy_strength" />
129+
<input name="in2" type="float" interfacename="anisotropy_strength" />
130+
</multiply>
131+
<mix name="at" type="float">
132+
<input name="fg" type="float" value="1" />
133+
<input name="bg" type="float" nodename="alpha_roughness" />
134+
<input name="mix" type="float" nodename="strength_2" />
135+
</mix>
110136

111137
<!-- Dielectric -->
112138

@@ -121,7 +147,7 @@
121147
<input name="ior" type="float" interfacename="ior" />
122148
<input name="roughness" type="vector2" nodename="roughness_uv" />
123149
<input name="normal" type="vector3" interfacename="normal" />
124-
<input name="tangent" type="vector3" interfacename="tangent" />
150+
<input name="tangent" type="vector3" nodename="selected_tangent" />
125151
<input name="scatter_mode" type="string" value="T" />
126152
</dielectric_bsdf>
127153

@@ -130,7 +156,7 @@
130156
<input name="color90" type="color3" nodename="dielectric_f90" />
131157
<input name="roughness" type="vector2" nodename="roughness_uv" />
132158
<input name="normal" type="vector3" interfacename="normal" />
133-
<input name="tangent" type="vector3" interfacename="tangent" />
159+
<input name="tangent" type="vector3" nodename="selected_tangent" />
134160
<input name="scatter_mode" type="string" value="R" />
135161
</generalized_schlick_bsdf>
136162

@@ -153,7 +179,7 @@
153179
<input name="color90" type="color3" nodename="dielectric_f90" />
154180
<input name="roughness" type="vector2" nodename="roughness_uv" />
155181
<input name="normal" type="vector3" interfacename="normal" />
156-
<input name="tangent" type="vector3" interfacename="tangent" />
182+
<input name="tangent" type="vector3" nodename="selected_tangent" />
157183
<input name="scatter_mode" type="string" value="R" />
158184
<input name="thinfilm_thickness" type="float" interfacename="iridescence_thickness" />
159185
<input name="thinfilm_ior" type="float" interfacename="iridescence_ior" />
@@ -178,7 +204,7 @@
178204
<input name="color90" type="color3" value="1, 1, 1" />
179205
<input name="roughness" type="vector2" nodename="roughness_uv" />
180206
<input name="normal" type="vector3" interfacename="normal" />
181-
<input name="tangent" type="vector3" interfacename="tangent" />
207+
<input name="tangent" type="vector3" nodename="selected_tangent" />
182208
</generalized_schlick_bsdf>
183209

184210
<!-- Thin-film + Metal
@@ -189,7 +215,7 @@
189215
<input name="color90" type="color3" value="1, 1, 1" />
190216
<input name="roughness" type="vector2" nodename="roughness_uv" />
191217
<input name="normal" type="vector3" interfacename="normal" />
192-
<input name="tangent" type="vector3" interfacename="tangent" />
218+
<input name="tangent" type="vector3" nodename="selected_tangent" />
193219
<input name="thinfilm_thickness" type="float" interfacename="iridescence_thickness" />
194220
<input name="thinfilm_ior" type="float" interfacename="iridescence_ior" />
195221
</generalized_schlick_bsdf>
@@ -311,6 +337,30 @@
311337
<input name="in2" type="float" nodename="opacity_mask" />
312338
</ifequal>
313339

340+
<!-- Anisotropy -->
341+
342+
<multiply name="rad_2_deg" type="float">
343+
<input name="in1" type="float" interfacename="anisotropy_rotation" />
344+
<input name="in2" type="float" value="-57.295780" />
345+
</multiply>
346+
<rotate3d name="rotate_tangent" type="vector3">
347+
<input name="in" type="vector3" interfacename="tangent" />
348+
<input name="amount" type="float" nodename="rad_2_deg" />
349+
<input name="axis" type="vector3" interfacename="normal" />
350+
</rotate3d>
351+
<normalize name="normalize_tangent" type="vector3">
352+
<input name="in" type="vector3" nodename="rotate_tangent" />
353+
</normalize>
354+
<absval name="abs_anisotropy_rotation" type="float">
355+
<input name="in" type="float" interfacename="anisotropy_rotation"/>
356+
</absval>
357+
<ifgreater name="selected_tangent" type="vector3">
358+
<input name="value1" type="float" nodename="abs_anisotropy_rotation" />
359+
<input name="value2" type="float" value="0.0" />
360+
<input name="in1" type="vector3" nodename="normalize_tangent" />
361+
<input name="in2" type="vector3" interfacename="tangent" />
362+
</ifgreater>
363+
314364
<!-- Surface -->
315365

316366
<surface name="shader_constructor" type="surfaceshader">
@@ -380,8 +430,8 @@
380430
<output name="outa" type="float" nodename="separate_alpha" />
381431
</nodegraph>
382432

383-
<!---
384-
Node: <gltf_image>
433+
<!---
434+
Node: <gltf_image>
385435
color3 image lookup which matches glTF
386436
-->
387437
<nodedef name="ND_gltf_image_color3_color3_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
@@ -435,8 +485,8 @@
435485
<output name="out" type="color3" nodename="scale_image" />
436486
</nodegraph>
437487

438-
<!---
439-
Node: <gltf_image>
488+
<!---
489+
Node: <gltf_image>
440490
color4 image lookup which matches glTF
441491
-->
442492
<nodedef name="ND_gltf_image_color4_color4_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
@@ -490,8 +540,8 @@
490540
<output name="out" type="color4" nodename="scale_image" />
491541
</nodegraph>
492542

493-
<!---
494-
Node: <gltf_image>
543+
<!---
544+
Node: <gltf_image>
495545
float image lookup which matches glTF
496546
-->
497547
<nodedef name="ND_gltf_image_float_float_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
@@ -545,8 +595,8 @@
545595
<output name="out" type="float" nodename="scale_image" />
546596
</nodegraph>
547597

548-
<!---
549-
Node: <gltf_image>
598+
<!---
599+
Node: <gltf_image>
550600
vector3 image lookup which matches glTF
551601
-->
552602
<nodedef name="ND_gltf_image_vector3_vector3_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
@@ -595,8 +645,8 @@
595645
<output name="out" type="vector3" nodename="image" />
596646
</nodegraph>
597647

598-
<!---
599-
Node: <gltf_normalmap>
648+
<!---
649+
Node: <gltf_normalmap>
600650
normalmap image lookup which matches glTF
601651
-->
602652
<nodedef name="ND_gltf_normalmap_vector3_1_0" node="gltf_normalmap" version="1.0" isdefaultversion="true" nodegroup="texture2d">
@@ -649,8 +699,8 @@
649699
</nodegraph>
650700

651701
<!--
652-
Node: <gltf_iridescence>
653-
normalmap image lookup which matches glTF
702+
Node: <gltf_iridescence>
703+
normalmap image lookup which matches glTF
654704
-->
655705
<nodedef name="ND_gltf_iridescence_thickness_float_1_0" node="gltf_iridescence_thickness" version="1.0" isdefaultversion="true" nodegroup="texture2d">
656706
<input name="file" type="filename" uniform="true" value="" uifolder="Image" />
@@ -692,4 +742,74 @@
692742
<output name="out" type="float" nodename="mixThickness" />
693743
</nodegraph>
694744

745+
<!--
746+
Node: <gltf_anisotropy_image>
747+
-->
748+
<nodedef name="ND_gltf_anisotropy_image" node="gltf_anisotropy_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
749+
<input name="file" type="filename" uniform="true" value="" uifolder="Image" />
750+
<input name="default" type="vector3" value="1.0, 0.5, 1" uifolder="Image" />
751+
<input name="texcoord" type="vector2" defaultgeomprop="UV0" uifolder="Image" />
752+
<input name="pivot" type="vector2" value="0, 1" uifolder="Image" />
753+
<input name="scale" type="vector2" value="1, 1" uifolder="Image" />
754+
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" uifolder="Image" />
755+
<input name="offset" type="vector2" value="0, 0" uifolder="Image" />
756+
<input name="operationorder" type="integer" value="0" uifolder="Image" />
757+
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" uifolder="Image" />
758+
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" uifolder="Image" />
759+
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" uifolder="Image" />
760+
<input name="anisotropy_strength" type="float" value="1" uimin="0" uimax="1" uifolder="Anisotropy" uiname="Anisotropy Strength" />
761+
<input name="anisotropy_rotation" type="float" value="0" uimin="0" uimax="6.283185" uifolder="Anisotropy" uiname="Anisotropy Rotation" />
762+
<output name="anisotropy_strength_out" type="float" value="0" />
763+
<output name="anisotropy_rotation_out" type="float" value="0" />
764+
</nodedef>
765+
766+
<nodegraph name="NG_gltf_anisotropy_image_1_0" nodedef="ND_gltf_anisotropy_image">
767+
<gltf_image name="gltf_anisotropy_image_src" type="vector3" nodedef="ND_gltf_image_vector3_vector3_1_0">
768+
<input name="file" type="filename" uniform="true" interfacename="file" />
769+
<input name="default" type="vector3" interfacename="default" />
770+
<input name="texcoord" type="vector2" interfacename="texcoord" />
771+
<input name="pivot" type="vector2" interfacename="pivot" />
772+
<input name="scale" type="vector2" interfacename="scale" />
773+
<input name="rotate" type="float" interfacename="rotate" />
774+
<input name="offset" type="vector2" interfacename="offset" />
775+
<input name="operationorder" type="integer" value="0" />
776+
<input name="uaddressmode" type="string" uniform="true" value="periodic" />
777+
<input name="vaddressmode" type="string" uniform="true" value="periodic" />
778+
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
779+
</gltf_image>
780+
<separate3 name="separate3" type="multioutput">
781+
<input name="in" type="vector3" nodename="gltf_anisotropy_image_src" />
782+
</separate3>
783+
<multiply name="strength_multiply" type="float">
784+
<input name="in1" type="float" interfacename="anisotropy_strength" />
785+
<input name="in2" type="float" nodename="separate3" output="outz" />
786+
</multiply>
787+
<atan2 name="direction_to_rotation" type="float">
788+
<input name="iny" type="float" nodename="subtract_y" />
789+
<input name="inx" type="float" nodename="subtract_x" />
790+
</atan2>
791+
<add name="rotation_add" type="float">
792+
<input name="in1" type="float" interfacename="anisotropy_rotation" />
793+
<input name="in2" type="float" nodename="direction_to_rotation" />
794+
</add>
795+
<multiply name="multiply_x" type="float">
796+
<input name="in1" type="float" nodename="separate3" output="outx" />
797+
<input name="in2" type="float" value="2.0" />
798+
</multiply>
799+
<subtract name="subtract_x" type="float">
800+
<input name="in1" type="float" nodename="multiply_x" />
801+
<input name="in2" type="float" value="1.0" />
802+
</subtract>
803+
<subtract name="subtract_y" type="float">
804+
<input name="in1" type="float" nodename="multiply_y" />
805+
<input name="in2" type="float" value="1.0" />
806+
</subtract>
807+
<multiply name="multiply_y" type="float">
808+
<input name="in1" type="float" nodename="separate3" output="outy" />
809+
<input name="in2" type="float" value="2.0" />
810+
</multiply>
811+
<output name="anisotropy_strength_out" type="float" nodename="strength_multiply" />
812+
<output name="anisotropy_rotation_out" type="float" nodename="rotation_add" />
813+
</nodegraph>
814+
695815
</materialx>

0 commit comments

Comments
 (0)