@meimu/mutracer 0.1.2 → 0.1.3

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.
Files changed (68) hide show
  1. package/dist/assets/bvh.worker.js +1 -1
  2. package/dist/mutracer.umd.js +3429 -3390
  3. package/lib/oidn.d.ts +1 -1
  4. package/lib/oidnBundledWeights.cdn.d.ts +2 -2
  5. package/lib/renderer/WGPUBloomPass.js +18 -18
  6. package/lib/renderer/WGPUFullQuadPass.js +3 -3
  7. package/lib/renderer/WGPUJNLMDenoiser.js +62 -62
  8. package/lib/renderer/WGPURayTraceOutput.js +14 -12
  9. package/lib/renderer/WGPURayTraceOutput.js.map +1 -1
  10. package/lib/renderer/WGPURayTracePass.js +1 -1
  11. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  12. package/lib/renderer/WGPURenderingPipeline.js +20 -18
  13. package/lib/renderer/WGPURenderingPipeline.js.map +1 -1
  14. package/lib/renderer/WebGLJNLMDenoiser.js +61 -61
  15. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  16. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +9 -9
  17. package/lib/renderer/glsl/chunks/envMap.glsl.js +45 -45
  18. package/lib/renderer/glsl/chunks/intersect.glsl.js +262 -262
  19. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +111 -111
  20. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +436 -436
  21. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  22. package/lib/renderer/glsl/chunks/random.glsl.js +3 -3
  23. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +32 -32
  24. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +54 -54
  25. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +71 -71
  26. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +12 -12
  27. package/lib/renderer/glsl/chunks/sampling.glsl.js +64 -64
  28. package/lib/renderer/glsl/chunks/sobol.glsl.js +49 -49
  29. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  30. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +5 -5
  31. package/lib/renderer/glsl/depthQuery.frag.js +2 -2
  32. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +8 -8
  33. package/lib/renderer/glsl/rayTrace.frag.js +128 -128
  34. package/lib/renderer/glsl/shadowCatcher.frag.js +12 -12
  35. package/lib/renderer/glsl/webglPipeline.frag.js +49 -49
  36. package/lib/renderer/lightsUtil.js +1 -1
  37. package/lib/renderer/lightsUtil.js.map +1 -1
  38. package/lib/renderer/scratchSampling.js +6 -6
  39. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  40. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +29 -29
  41. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +368 -368
  42. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +5 -5
  43. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +51 -51
  44. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +453 -453
  45. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +116 -116
  46. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  47. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +13 -13
  48. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +94 -94
  49. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +119 -119
  50. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +5 -5
  51. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +62 -62
  52. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.d.ts +3 -3
  53. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js +2 -2
  54. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js.map +1 -1
  55. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +53 -53
  56. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +5 -5
  57. package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +2 -2
  58. package/lib/renderer/wgsl/compose.frag.wgsl.js +120 -92
  59. package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -1
  60. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  61. package/lib/renderer/wgsl/depthQuery.wgsl.js +3 -3
  62. package/lib/renderer/wgsl/offlineAdaptive.compute.js +26 -26
  63. package/lib/renderer/wgsl/rayTrace.compute.js +220 -211
  64. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  65. package/lib/version.d.ts +1 -1
  66. package/lib/version.js +1 -1
  67. package/lib/version.js.map +1 -1
  68. package/package.json +5 -4
@@ -8,14 +8,14 @@ import { materialAlphaModeConstants } from '../../../scene/OpenPBRMaterial.js';
8
8
  */
9
9
  export function createIntersectionAlphaWgsl(hasAnisotropyDirections = true) {
10
10
  return /* wgsl */ `
11
- fn nl(
12
- ph: i32,
11
+ fn nr(
12
+ pl: i32,
13
13
  index: vec3i,
14
14
  aB: vec3f,
15
15
  eU: vec3f,
16
16
  eC: vec3f
17
17
  ) -> bool {
18
- var materialIndex = ph;
18
+ var materialIndex = pl;
19
19
  let m0 = vec3i(attrBuffers[index.x * ATTR_STRIDE + MATERIALINDEX_OFF]${hasAnisotropyDirections ? '.xyz' : ''});
20
20
  let m1 = vec3i(attrBuffers[index.y * ATTR_STRIDE + MATERIALINDEX_OFF]${hasAnisotropyDirections ? '.xyz' : ''});
21
21
  let m2 = vec3i(attrBuffers[index.z * ATTR_STRIDE + MATERIALINDEX_OFF]${hasAnisotropyDirections ? '.xyz' : ''});
@@ -37,7 +37,7 @@ let uv2 = attrBuffers[index.z * ATTR_STRIDE + UV_OFF].xy;
37
37
  var uv = aB.x * uv0 +
38
38
  aB.y * uv1 + aB.z * uv2;
39
39
  if (uvProjection > 0) {
40
- uv = gz(uvProjection, eU, eC);
40
+ uv = gC(uvProjection, eU, eC);
41
41
  }
42
42
  uv *= ma.uvScale;
43
43
  if (uvProjection == ${uvProjectionConstants.triplanar}) {
@@ -57,7 +57,7 @@ let uv2 = attrBuffers[index.z * ATTR_STRIDE + UV_OFF].xy;
57
57
  var uv = aB.x * uv0 +
58
58
  aB.y * uv1 + aB.z * uv2;
59
59
  if (uvProjection > 0) {
60
- uv = gz(uvProjection, eU, eC);
60
+ uv = gC(uvProjection, eU, eC);
61
61
  }
62
62
  uv *= ma.uvScale;
63
63
  if (uvProjection == ${uvProjectionConstants.triplanar}) {
@@ -29,43 +29,43 @@ return vec2f(pow((a*a + u*u) * 0.5, 0.25), clamp(1.0 - u/a, 0.0, 1.0));
29
29
  }
30
30
  ` : /* wgsl */ ``}
31
31
 
32
- fn oy(c: vec3f) -> vec3f {
32
+ fn oB(c: vec3f) -> vec3f {
33
33
  return mix(pow(c * 0.9478672986 + 0.0521327014, vec3f(2.4)), c * 0.0773993808, vec3f(c < vec3f(0.04045)));
34
34
  }
35
35
 
36
36
  fn decodeMapColor(idx: i32, c: vec3f) -> vec3f {
37
37
  if (mapInfo[idx + NUM_MAPS * 2].y > 0.5) { return c; }
38
- return oy(c);
38
+ return oB(c);
39
39
  }
40
40
 
41
41
  fn ae(val: i32) -> vec2f {
42
42
  return vec2f(f32(val >> 8), f32(val & 0xff) / 255.0);
43
43
  }
44
44
 
45
- fn nX(idx: i32) -> vec2f {
45
+ fn oa(idx: i32) -> vec2f {
46
46
  return mapInfo[idx].xy;
47
47
  }
48
48
 
49
- fn pf(idx: i32) -> i32 {
49
+ fn pj(idx: i32) -> i32 {
50
50
  return i32(floor(mapInfo[idx].z));
51
51
  }
52
52
 
53
- fn nW(idx: i32) -> vec2f {
53
+ fn nZ(idx: i32) -> vec2f {
54
54
  return vec2f(fract(mapInfo[idx].z), mapInfo[idx].w);
55
55
  }
56
56
 
57
- fn sb(idx: i32, uv: vec2f) -> vec2f {
57
+ fn sg(idx: i32, uv: vec2f) -> vec2f {
58
58
  let transform = mapInfo[idx + NUM_MAPS];
59
- let qv = fract(uv * transform.xy + transform.zw);
60
- let je = 1.0 / vec2f(textureDimensions(map).xy);
61
- let dZ = nW(idx);
62
- let ke = nX(idx) + je;
63
- let oB = dZ - 0.5 * je;
64
- let lo = dZ + ke - je;
59
+ let qz = fract(uv * transform.xy + transform.zw);
60
+ let jg = 1.0 / vec2f(textureDimensions(map).xy);
61
+ let dZ = nZ(idx);
62
+ let kg = oa(idx) + jg;
63
+ let oE = dZ - 0.5 * jg;
64
+ let lr = dZ + kg - jg;
65
65
  return clamp(
66
- oB + qv * ke,
66
+ oE + qz * kg,
67
67
  dZ,
68
- lo
68
+ lr
69
69
  );
70
70
  }
71
71
 
@@ -74,11 +74,11 @@ return select(uv, uv1, mapInfo[idx + NUM_MAPS * 2].x > 0.5);
74
74
  }
75
75
 
76
76
  fn sampleMap(idx: i32, uv: vec2f) -> vec4f {
77
- return textureSampleLevel(map, mapSampler, sb(idx, uv), pf(idx), 0.0);
77
+ return textureSampleLevel(map, mapSampler, sg(idx, uv), pj(idx), 0.0);
78
78
  }
79
79
 
80
80
 
81
- fn lB(materialIndex: i32, uv: vec2f, uv1: vec2f) -> vec3f {
81
+ fn lE(materialIndex: i32, uv: vec2f, uv1: vec2f) -> vec3f {
82
82
  let matData = materialsBuffer[materialIndex];
83
83
  var emission = matData.emission;
84
84
  if (USE_EMISSIVE_MAPS) {
@@ -102,16 +102,16 @@ return emission;
102
102
  }
103
103
 
104
104
 
105
- fn aJ(roughness: f32, anisotropy: f32) -> vec2f {
105
+ fn aK(roughness: f32, anisotropy: f32) -> vec2f {
106
106
  let alpha = roughness * roughness;
107
- let oT = ROUGHNESS_MIN * ROUGHNESS_MIN;
108
- if (anisotropy == 0.0) { return vec2f(max(oT, alpha)); }
107
+ let oX = ROUGHNESS_MIN * ROUGHNESS_MIN;
108
+ if (anisotropy == 0.0) { return vec2f(max(oX, alpha)); }
109
109
  let dg = 1.0 - anisotropy;
110
- let rU = alpha * sqrt(2.0 / (1.0 + dg * dg));
111
- return max(vec2f(oT), vec2f(rU, dg * rU));
110
+ let rZ = alpha * sqrt(2.0 / (1.0 + dg * dg));
111
+ return max(vec2f(oX), vec2f(rZ, dg * rZ));
112
112
  }
113
113
 
114
- fn kx(instanceIndex: i32) -> vec3f {
114
+ fn kA(instanceIndex: i32) -> vec3f {
115
115
  if (instanceIndex < 0) { return vec3f(1.0); }
116
116
  return instancesBuffer[instanceIndex * ${INSTANCE_VEC4_STRIDE} + 9].xyz;
117
117
  }
@@ -130,7 +130,7 @@ let matData = materialsBuffer[materialIndex];
130
130
  (*ma).specularRoughness = matData.roughness;
131
131
  (*ma).baseMetalness = matData.metallic;
132
132
  (*ma).specularAnisotropy = clamp(matData.anisotropy, 0.0, 1.0);
133
- (*ma).emission = lB(materialIndex, uv, uv1);
133
+ (*ma).emission = lE(materialIndex, uv, uv1);
134
134
  (*ma).inside = false;
135
135
  (*ma).specularIor = matData.ior;
136
136
  (*ma).transmissionWeight = matData.transmission;
@@ -169,19 +169,19 @@ if (USE_DIFFUSE_MAPS) {
169
169
  let diffuseMapIndex = i32(matData.diffuseMapIndex);
170
170
  if (diffuseMapIndex >= 0) {
171
171
 
172
- let nN = sampleMap(
172
+ let nQ = sampleMap(
173
173
  diffuseMapIndex, getMapUvSet(diffuseMapIndex, uv, uv1)
174
174
  );
175
175
 
176
176
 
177
- (*ma).baseColor *= decodeMapColor(diffuseMapIndex, nN.rgb);
177
+ (*ma).baseColor *= decodeMapColor(diffuseMapIndex, nQ.rgb);
178
178
 
179
179
 
180
180
  if (matData.mapAlphaUsage == ${mapAlphaUsageConstants.transmission}) {
181
- (*ma).transmissionWeight = 1.0 - nN.a;
181
+ (*ma).transmissionWeight = 1.0 - nQ.a;
182
182
  }
183
183
  else if (matData.mapAlphaUsage == ${mapAlphaUsageConstants.alpha}) {
184
- (*ma).alpha *= nN.a;
184
+ (*ma).alpha *= nQ.a;
185
185
  }
186
186
  }
187
187
  }
@@ -232,16 +232,16 @@ ${hasAnisotropyDirections ? /* wgsl */ `
232
232
  (*ma).coatAnisotropyRotation = matData.coatAnisotropyRotation;
233
233
  if (USE_ANISOTROPY_MAPS && matData.anisotropyMapIndex >= 0.0) {
234
234
  let index = i32(matData.anisotropyMapIndex);
235
- let iW = sampleMap(index, getMapUvSet(index, uv, uv1));
236
- (*ma).specularAnisotropy *= iW.b;
237
- let direction = iW.rg * 2.0 - 1.0;
235
+ let iX = sampleMap(index, getMapUvSet(index, uv, uv1));
236
+ (*ma).specularAnisotropy *= iX.b;
237
+ let direction = iX.rg * 2.0 - 1.0;
238
238
  if (dot(direction, direction) > 1e-4) { (*ma).anisotropyDirection = normalize(direction); }
239
239
  (*ma).anisotropyDirectionEnabled = true;
240
240
  }
241
241
  if (matData.specularAnisotropyModel > 0.5 && (*ma).specularAnisotropy > 0.0) {
242
- let sp = fb(clamp((*ma).specularRoughness, 0.0, 1.0), (*ma).specularAnisotropy);
243
- (*ma).specularRoughness = sp.x;
244
- (*ma).specularAnisotropy = sp.y;
242
+ let sv = fb(clamp((*ma).specularRoughness, 0.0, 1.0), (*ma).specularAnisotropy);
243
+ (*ma).specularRoughness = sv.x;
244
+ (*ma).specularAnisotropy = sv.y;
245
245
  }
246
246
  if ((*ma).anisotropyDirectionEnabled) {
247
247
  let theta = matData.specularAnisotropyRotation;
@@ -253,55 +253,55 @@ let d = (*ma).anisotropyDirection;
253
253
 
254
254
 
255
255
  if ((*ma).coatWeight > 0.0 && (*ma).coatRoughness > 0.0) {
256
- let hJ = (*ma).specularRoughness * (*ma).specularRoughness;
257
- let hK = (*ma).coatRoughness * (*ma).coatRoughness;
256
+ let hI = (*ma).specularRoughness * (*ma).specularRoughness;
257
+ let hJ = (*ma).coatRoughness * (*ma).coatRoughness;
258
258
  (*ma).specularRoughness = mix((*ma).specularRoughness,
259
- pow(min(1.0, hJ * hJ + 2.0 * hK * hK), 0.25), (*ma).coatWeight);
259
+ pow(min(1.0, hI * hI + 2.0 * hJ * hJ), 0.25), (*ma).coatWeight);
260
260
  }
261
- let instanceColor = kx(instanceIndex);
261
+ let instanceColor = kA(instanceIndex);
262
262
  (*ma).baseColor *= instanceColor;
263
263
  if ((*ma).materialType == UNLIT) { (*ma).emission *= instanceColor; }
264
264
 
265
265
  (*ma).specularRoughness = clamp((*ma).specularRoughness, ROUGHNESS_MIN, 1.0);
266
266
  (*ma).baseMetalness = clamp((*ma).baseMetalness, 0.0, 1.0);
267
- let specularAlpha = aJ((*ma).specularRoughness, (*ma).specularAnisotropy);
267
+ let specularAlpha = aK((*ma).specularRoughness, (*ma).specularAnisotropy);
268
268
  (*ma).alphaX = specularAlpha.x;
269
269
  (*ma).alphaY = specularAlpha.y;
270
270
  }
271
271
 
272
- fn nY(materialIndex: i32, uv: vec2f, normal: vec3f, dp1: vec3f, dp2: vec3f, nP: vec2f, nQ: vec2f) -> vec3f {
272
+ fn ob(materialIndex: i32, uv: vec2f, normal: vec3f, dp1: vec3f, dp2: vec3f, nS: vec2f, nT: vec2f) -> vec3f {
273
273
  let matData = materialsBuffer[materialIndex];
274
274
  let normalMapIndex = i32(matData.normalMapIndex);
275
275
  if (normalMapIndex >= 0) {
276
276
 
277
277
 
278
278
 
279
- let qJ = cross(dp2, normal);
280
- let qI = cross(normal, dp1);
281
- var dpdu = qJ * nP.x + qI * nQ.x;
282
- var rZ = qJ * nP.y + qI * nQ.y;
283
- let dS = max(dot(dpdu, dpdu), dot(rZ, rZ));
279
+ let qO = cross(dp2, normal);
280
+ let qM = cross(normal, dp1);
281
+ var dpdu = qO * nS.x + qM * nT.x;
282
+ var se = qO * nS.y + qM * nT.y;
283
+ let dS = max(dot(dpdu, dpdu), dot(se, se));
284
284
  if (dS > 1e-12) {
285
- let sh = inverseSqrt(dS);
286
- dpdu *= sh;
287
- rZ *= sh;
285
+ let sn = inverseSqrt(dS);
286
+ dpdu *= sn;
287
+ se *= sn;
288
288
  }
289
289
  else {
290
290
 
291
291
 
292
- let mZ = select(
292
+ let nf = select(
293
293
  vec3f(0.0, 1.0, 0.0),
294
294
  vec3f(0.0, 0.0, 1.0),
295
295
  abs(normal.z) < 0.999
296
296
  );
297
- dpdu = normalize(cross(mZ, normal));
298
- rZ = cross(normal, dpdu);
297
+ dpdu = normalize(cross(nf, normal));
298
+ se = cross(normal, dpdu);
299
299
  }
300
300
 
301
301
  var n = 2.0 * sampleMap(normalMapIndex, uv).rgb - 1.0;
302
302
  n = normalize(vec3(n.xy * matData.normalMapScale, n.z));
303
303
 
304
- let tbn = mat3x3(dpdu, rZ, normal);
304
+ let tbn = mat3x3(dpdu, se, normal);
305
305
 
306
306
  return normalize(tbn * n);
307
307
  } else {