@needle-tools/materialx 1.7.3 → 1.7.4-next.bdb4b9a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/package.json +2 -2
- package/src/materialx.material.js +14 -8
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.7.4] - 2026-07-09
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- MaterialX shader graphs that call generated world-matrix helpers from nodegraph functions now compile and render correctly while preserving Three.js instancing transforms.
|
|
11
|
+
|
|
7
12
|
## [1.7.3] - 2026-07-09
|
|
8
13
|
|
|
9
14
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/materialx",
|
|
3
3
|
"description": "MaterialX material support for three.js and Needle Engine – render physically based MaterialX shaders in the browser via WebAssembly",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.4-next.bdb4b9a",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
7
7
|
"main": "index.js",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"type": "git",
|
|
79
79
|
"url": "https://github.com/needle-tools/needle-engine-materialx.git"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -358,10 +358,10 @@ function patchImageAddressModes(fragmentShader) {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
function patchInstancingTransforms(vertexShader) {
|
|
361
|
-
if (!vertexShader.includes('u_worldMatrix')
|
|
361
|
+
if (!vertexShader.includes('u_worldMatrix')) return vertexShader;
|
|
362
362
|
|
|
363
363
|
let helper = `
|
|
364
|
-
mat4
|
|
364
|
+
mat4 mx_three_worldMatrix()
|
|
365
365
|
{
|
|
366
366
|
#ifdef USE_INSTANCING
|
|
367
367
|
return u_worldMatrix * instanceMatrix;
|
|
@@ -373,7 +373,7 @@ mat4 mtlxWorldMatrix()
|
|
|
373
373
|
|
|
374
374
|
if (vertexShader.includes('u_worldInverseTransposeMatrix')) {
|
|
375
375
|
helper += `
|
|
376
|
-
vec3
|
|
376
|
+
vec3 mx_three_worldNormal(vec3 objectNormal)
|
|
377
377
|
{
|
|
378
378
|
vec3 transformedNormal = objectNormal;
|
|
379
379
|
#ifdef USE_INSTANCING
|
|
@@ -390,22 +390,28 @@ vec3 mtlxWorldNormal(vec3 objectNormal)
|
|
|
390
390
|
`;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
|
|
393
|
+
const firstFunctionMatch = vertexShader.match(/\n(?:void|float|int|bool|vec[234]|mat[234])\s+[A-Za-z_]\w*\s*\(/);
|
|
394
|
+
if (firstFunctionMatch?.index !== undefined) {
|
|
395
|
+
vertexShader = `${vertexShader.slice(0, firstFunctionMatch.index)}${helper}${vertexShader.slice(firstFunctionMatch.index)}`;
|
|
396
|
+
} else {
|
|
397
|
+
vertexShader = vertexShader.replace(/void\s+main\s*\(\s*\)\s*\{/, `${helper}\nvoid main() {`);
|
|
398
|
+
}
|
|
399
|
+
vertexShader = vertexShader.replaceAll('mtlxWorldMatrix()', 'mx_three_worldMatrix()');
|
|
394
400
|
vertexShader = vertexShader.replaceAll(
|
|
395
401
|
'u_worldMatrix * vec4(position, 1.0)',
|
|
396
|
-
'
|
|
402
|
+
'mx_three_worldMatrix() * vec4(position, 1.0)',
|
|
397
403
|
);
|
|
398
404
|
vertexShader = vertexShader.replaceAll(
|
|
399
405
|
'mx_matrix_mul(u_worldMatrix, vec4(tangent, 0.0)).xyz',
|
|
400
|
-
'(
|
|
406
|
+
'(mx_three_worldMatrix() * vec4(tangent, 0.0)).xyz',
|
|
401
407
|
);
|
|
402
408
|
vertexShader = vertexShader.replaceAll(
|
|
403
409
|
'normalize(mx_matrix_mul(u_worldInverseTransposeMatrix, vec4(normal, 0.0)).xyz)',
|
|
404
|
-
'
|
|
410
|
+
'mx_three_worldNormal(normal)',
|
|
405
411
|
);
|
|
406
412
|
vertexShader = vertexShader.replaceAll(
|
|
407
413
|
'normalize(mat3(viewMatrix) * mat3(u_worldInverseTransposeMatrix) * normal)',
|
|
408
|
-
'normalize(mat3(viewMatrix) *
|
|
414
|
+
'normalize(mat3(viewMatrix) * mx_three_worldNormal(normal))',
|
|
409
415
|
);
|
|
410
416
|
|
|
411
417
|
return vertexShader;
|