@needle-tools/materialx 1.7.2 → 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 +10 -0
- package/package.json +2 -2
- package/src/materialx.material.js +18 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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
|
+
|
|
12
|
+
## [1.7.3] - 2026-07-09
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Three PMREM environment sampling now reads the encoded CubeUV atlas from the base texture level, keeping glossy MaterialX reflections stable for prefiltered KTX2 environments that include hardware mip levels.
|
|
16
|
+
|
|
7
17
|
## [1.7.2] - 2026-07-06
|
|
8
18
|
|
|
9
19
|
### 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
|
+
}
|
|
@@ -203,7 +203,10 @@ vec3 mx_cubeuv_bilinear(sampler2D envMap, vec3 direction, float mipInt) {
|
|
|
203
203
|
uv.y += 4.0 * (exp2(u_envRadianceCubeUVMaxMip) - faceSize);
|
|
204
204
|
uv.x *= u_envRadianceCubeUVTexelWidth;
|
|
205
205
|
uv.y *= u_envRadianceCubeUVTexelHeight;
|
|
206
|
-
|
|
206
|
+
// PMREM encodes roughness in the CubeUV atlas itself. If the source KTX2
|
|
207
|
+
// carries hardware mip levels, implicit sampling may pick those mips and
|
|
208
|
+
// corrupt the atlas lookup.
|
|
209
|
+
return textureLod(envMap, uv, 0.0).rgb;
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
float mx_cubeuv_roughnessToMip(float roughness) {
|
|
@@ -355,10 +358,10 @@ function patchImageAddressModes(fragmentShader) {
|
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
function patchInstancingTransforms(vertexShader) {
|
|
358
|
-
if (!vertexShader.includes('u_worldMatrix')
|
|
361
|
+
if (!vertexShader.includes('u_worldMatrix')) return vertexShader;
|
|
359
362
|
|
|
360
363
|
let helper = `
|
|
361
|
-
mat4
|
|
364
|
+
mat4 mx_three_worldMatrix()
|
|
362
365
|
{
|
|
363
366
|
#ifdef USE_INSTANCING
|
|
364
367
|
return u_worldMatrix * instanceMatrix;
|
|
@@ -370,7 +373,7 @@ mat4 mtlxWorldMatrix()
|
|
|
370
373
|
|
|
371
374
|
if (vertexShader.includes('u_worldInverseTransposeMatrix')) {
|
|
372
375
|
helper += `
|
|
373
|
-
vec3
|
|
376
|
+
vec3 mx_three_worldNormal(vec3 objectNormal)
|
|
374
377
|
{
|
|
375
378
|
vec3 transformedNormal = objectNormal;
|
|
376
379
|
#ifdef USE_INSTANCING
|
|
@@ -387,22 +390,28 @@ vec3 mtlxWorldNormal(vec3 objectNormal)
|
|
|
387
390
|
`;
|
|
388
391
|
}
|
|
389
392
|
|
|
390
|
-
|
|
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()');
|
|
391
400
|
vertexShader = vertexShader.replaceAll(
|
|
392
401
|
'u_worldMatrix * vec4(position, 1.0)',
|
|
393
|
-
'
|
|
402
|
+
'mx_three_worldMatrix() * vec4(position, 1.0)',
|
|
394
403
|
);
|
|
395
404
|
vertexShader = vertexShader.replaceAll(
|
|
396
405
|
'mx_matrix_mul(u_worldMatrix, vec4(tangent, 0.0)).xyz',
|
|
397
|
-
'(
|
|
406
|
+
'(mx_three_worldMatrix() * vec4(tangent, 0.0)).xyz',
|
|
398
407
|
);
|
|
399
408
|
vertexShader = vertexShader.replaceAll(
|
|
400
409
|
'normalize(mx_matrix_mul(u_worldInverseTransposeMatrix, vec4(normal, 0.0)).xyz)',
|
|
401
|
-
'
|
|
410
|
+
'mx_three_worldNormal(normal)',
|
|
402
411
|
);
|
|
403
412
|
vertexShader = vertexShader.replaceAll(
|
|
404
413
|
'normalize(mat3(viewMatrix) * mat3(u_worldInverseTransposeMatrix) * normal)',
|
|
405
|
-
'normalize(mat3(viewMatrix) *
|
|
414
|
+
'normalize(mat3(viewMatrix) * mx_three_worldNormal(normal))',
|
|
406
415
|
);
|
|
407
416
|
|
|
408
417
|
return vertexShader;
|