@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
@@ -5,13 +5,13 @@ import { glsl } from '../../shader.js';
5
5
  export default glsl `
6
6
  uvec4 s0;
7
7
 
8
- void jY(vec2 p, int frame) {
8
+ void ka(vec2 p, int frame) {
9
9
 
10
10
  s0 = uvec4(p, uint(frame), uint(p.x) + uint(p.y));
11
11
  }
12
12
 
13
13
 
14
- void vj(inout uvec4 v) {
14
+ void vo(inout uvec4 v) {
15
15
  v = v * 1664525u + 1013904223u;
16
16
  v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
17
17
  v = v ^ (v>>16u);
@@ -19,7 +19,7 @@ v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
19
19
  }
20
20
 
21
21
  float rand() {
22
- vj(s0); return float(s0.x)/float(0xffffffffu);
22
+ vo(s0); return float(s0.x)/float(0xffffffffu);
23
23
  }
24
24
 
25
25
  `;
@@ -10,13 +10,13 @@ export default createShaderMixin({
10
10
 
11
11
  ${sobol}
12
12
 
13
- void se() {
13
+ void sk() {
14
14
  bc = uvec2(v_Texcoord / pixelSize);
15
15
  bd = uint(sampleCount);
16
- cE = 0u; em = 0u;
16
+ cF = 0u; em = 0u;
17
17
  }
18
18
 
19
- vec2 rN() {
19
+ vec2 rS() {
20
20
  if (samplingPattern == 0 || samplingPattern == 1) {
21
21
  return (fk(CAMERA_PIXEL) - 0.5) * pixelSize;
22
22
  }
@@ -23,7 +23,7 @@ export default createShaderMixin({
23
23
  main: glsl `
24
24
 
25
25
  const vec3 luminance = vec3(0.2126, 0.7152, 0.0722);
26
- const int vp = 8;
26
+ const int vw = 8;
27
27
 
28
28
  #define RAY_MAX_DISTANCE 9999.0
29
29
 
@@ -163,19 +163,19 @@ ray.tMax = RAY_MAX_DISTANCE;
163
163
  }
164
164
 
165
165
 
166
- ivec2 gK(int i, int jq) {
166
+ ivec2 gM(int i, int jt) {
167
167
  ivec2 u;
168
- u.y = i >> jq;
169
- u.x = i - (u.y << jq);
168
+ u.y = i >> jt;
169
+ u.x = i - (u.y << jt);
170
170
  return u;
171
171
  }
172
172
 
173
- vec4 kw(sampler2D s, int i, int jq) {
174
- return texelFetch(s, gK(i, jq), 0);
173
+ vec4 ky(sampler2D s, int i, int jt) {
174
+ return texelFetch(s, gM(i, jt), 0);
175
175
  }
176
176
 
177
- ivec4 kw(highp isampler2D s, int i, int jq) {
178
- return texelFetch(s, gK(i, jq), 0);
177
+ ivec4 ky(highp isampler2D s, int i, int jt) {
178
+ return texelFetch(s, gM(i, jt), 0);
179
179
  }
180
180
 
181
181
  struct Path {
@@ -200,24 +200,24 @@ bool isDelta;
200
200
  };
201
201
 
202
202
 
203
- Light ql(int i) {
203
+ Light qp(int i) {
204
204
  int firstTexel = i * 6;
205
- vec4 ps = texelFetch(
205
+ vec4 pG = texelFetch(
206
206
  lightsTex,
207
207
  ivec2(firstTexel, 0),
208
208
  0
209
209
  );
210
- vec4 pb = texelFetch(
210
+ vec4 pf = texelFetch(
211
211
  lightsTex,
212
212
  ivec2(firstTexel + 1, 0),
213
213
  0
214
214
  );
215
- vec4 nC = texelFetch(
215
+ vec4 nF = texelFetch(
216
216
  lightsTex,
217
217
  ivec2(firstTexel + 2, 0),
218
218
  0
219
219
  );
220
- vec4 lA = texelFetch(
220
+ vec4 lD = texelFetch(
221
221
  lightsTex,
222
222
  ivec2(firstTexel + 3, 0),
223
223
  0
@@ -228,32 +228,32 @@ ivec2(firstTexel + 4, 0),
228
228
  0
229
229
  );
230
230
  return Light(
231
- ps.xyz,
232
- pb.xyz,
233
- nC.xyz,
234
- lA.xyz,
231
+ pG.xyz,
232
+ pf.xyz,
233
+ nF.xyz,
234
+ lD.xyz,
235
235
  shape.x,
236
236
  shape.y,
237
237
  shape.z,
238
- int(lA.w),
239
- nC.w,
240
- ps.w,
241
- pb.w,
238
+ int(lD.w),
239
+ nF.w,
240
+ pG.w,
241
+ pf.w,
242
242
  texelFetch(lightsTex, ivec2(firstTexel + 5, 0), 0).xyz
243
243
  );
244
244
  }
245
245
 
246
- float cL(int dV, int le) {
247
- int ij = dV + le / 4;
246
+ float cL(int dV, int lh) {
247
+ int ih = dV + lh / 4;
248
248
  vec4 packed = texelFetch(
249
249
  iesProfileData,
250
- ivec2(ij % iesProfileColumns, ij / iesProfileColumns),
250
+ ivec2(ih % iesProfileColumns, ih / iesProfileColumns),
251
251
  0
252
252
  );
253
- return packed[le % 4];
253
+ return packed[lh % 4];
254
254
  }
255
255
 
256
- float kF(int dV, vec2 uv) {
256
+ float kI(int dV, vec2 uv) {
257
257
  if (dV < 0) return 1.0;
258
258
  vec2 fM = fract(uv) * 128.0 - 0.5;
259
259
  ivec2 p0 = ivec2(floor(fM));
@@ -272,15 +272,15 @@ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
272
272
  float bL(Light light, vec3 dJ) {
273
273
  vec3 axis = normalize(light.u);
274
274
  float cc = dot(axis, dJ);
275
- float tD = light.v.y > 1e-6
275
+ float tI = light.v.y > 1e-6
276
276
  ? smoothstep(light.v.x, light.v.x + light.v.y, cc)
277
277
  : step(light.v.x, cc);
278
- if (tD <= 0.0 || light.textureIndex < 0) return tD;
279
- vec3 tX = light.iesReference;
280
- vec3 vo = cross(axis, tX);
278
+ if (tI <= 0.0 || light.textureIndex < 0) return tI;
279
+ vec3 uc = light.iesReference;
280
+ vec3 vu = cross(axis, uc);
281
281
  float vertical = acos(clamp(cc, -1.0, 1.0));
282
- float horizontal = atan(dot(dJ, vo), dot(dJ, tX));
283
- return tD * kF(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));
282
+ float horizontal = atan(dot(dJ, vu), dot(dJ, uc));
283
+ return tI * kI(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));
284
284
  }
285
285
  `
286
286
  });
@@ -7,8 +7,8 @@ in vec3 shadingPoint,
7
7
  in vec2 samplePoint,
8
8
  inout LightSampleRec result
9
9
  ) {
10
- vec3 nE = light.position - shadingPoint;
11
- float aj = length(nE);
10
+ vec3 nH = light.position - shadingPoint;
11
+ float aj = length(nH);
12
12
  if (light.radius <= 0.0) {
13
13
  if (aj <= 1e-6) {
14
14
  result.direction = vec3(0.0, 0.0, 1.0);
@@ -19,7 +19,7 @@ result.emission = vec3(0.0);
19
19
  result.isDelta = true;
20
20
  return;
21
21
  }
22
- result.direction = nE / aj;
22
+ result.direction = nH / aj;
23
23
  result.normal = -result.direction;
24
24
  result.dist = aj;
25
25
  result.pdf = 1.0;
@@ -39,31 +39,31 @@ direction = vec3(fi * cos(br), fi * sin(br), z);
39
39
  result.pdf = INV4PI;
40
40
  }
41
41
  else {
42
- vec3 axis = nE / aj;
43
- float rG = min(
42
+ vec3 axis = nH / aj;
43
+ float rL = min(
44
44
  1.0,
45
45
  radius * radius / (aj * aj)
46
46
  );
47
- float rJ = sqrt(max(0.0, 1.0 - rG));
48
- float au = mix(1.0, rJ, samplePoint.x);
49
- float tR = sqrt(max(0.0, 1.0 - au * au));
47
+ float rO = sqrt(max(0.0, 1.0 - rL));
48
+ float au = mix(1.0, rO, samplePoint.x);
49
+ float tW = sqrt(max(0.0, 1.0 - au * au));
50
50
  float br = TWOPI * samplePoint.y;
51
51
  vec3 tangent;
52
52
  vec3 bitangent;
53
- aK(axis, tangent, bitangent);
53
+ aL(axis, tangent, bitangent);
54
54
  direction = axis * au
55
- + tangent * (tR * cos(br))
56
- + bitangent * (tR * sin(br));
57
- result.pdf = 1.0 / max(TWOPI * (1.0 - rJ), 1e-8);
55
+ + tangent * (tW * cos(br))
56
+ + bitangent * (tW * sin(br));
57
+ result.pdf = 1.0 / max(TWOPI * (1.0 - rO), 1e-8);
58
58
  }
59
59
 
60
- float iZ = dot(direction, nE);
61
- float ej = iZ * iZ
62
- - dot(nE, nE) + radius * radius;
63
- float wu = sqrt(max(0.0, ej));
64
- float cN = iZ - wu;
65
- float cB = iZ + wu;
66
- result.dist = cN > 1e-6 ? cN : cB;
60
+ float jb = dot(direction, nH);
61
+ float ej = jb * jb
62
+ - dot(nH, nH) + radius * radius;
63
+ float wB = sqrt(max(0.0, ej));
64
+ float cN = jb - wB;
65
+ float cC = jb + wB;
66
+ result.dist = cN > 1e-6 ? cN : cC;
67
67
  result.direction = direction;
68
68
  vec3 surfacePoint = shadingPoint + direction * result.dist;
69
69
  result.normal = normalize(surfacePoint - light.position);
@@ -80,17 +80,17 @@ inout LightSampleRec result
80
80
  if (light.textureIndex >= 0) {
81
81
  float width = length(light.u);
82
82
  float height = length(light.v);
83
- vec3 hY = surfacePoint - lowerLeft;
83
+ vec3 hX = surfacePoint - lowerLeft;
84
84
  vec2 uv = vec2(
85
- dot(hY, light.u / width) / width,
86
- dot(hY, light.v / height) / height
85
+ dot(hX, light.u / width) / width,
86
+ dot(hX, light.v / height) / height
87
87
  );
88
88
  result.emission *= sampleMap(light.textureIndex, uv).rgb;
89
89
  }
90
90
  #endif
91
91
  }
92
92
 
93
- void jJ(
93
+ void jL(
94
94
  in Light light,
95
95
  in vec3 shadingPoint,
96
96
  in vec2 samplePoint,
@@ -101,23 +101,23 @@ vec3 lowerLeft = light.position - 0.5 * (light.u + light.v);
101
101
  float spread = clamp(light.spread, 0.0, 1.0);
102
102
 
103
103
  if (spread <= 0.001) {
104
- float ga = dot(normal, shadingPoint - light.position);
105
- vec3 surfacePoint = shadingPoint - normal * ga;
106
- vec3 hY = surfacePoint - lowerLeft;
104
+ float gb = dot(normal, shadingPoint - light.position);
105
+ vec3 surfacePoint = shadingPoint - normal * gb;
106
+ vec3 hX = surfacePoint - lowerLeft;
107
107
  float width = length(light.u);
108
108
  float height = length(light.v);
109
109
  vec2 uv = vec2(
110
- dot(hY, light.u / width) / width,
111
- dot(hY, light.v / height) / height
110
+ dot(hX, light.u / width) / width,
111
+ dot(hX, light.v / height) / height
112
112
  );
113
- if (ga <= 0.0 || any(lessThan(uv, vec2(0.0)))
113
+ if (gb <= 0.0 || any(lessThan(uv, vec2(0.0)))
114
114
  || any(greaterThan(uv, vec2(1.0)))) {
115
115
  result.emission = vec3(0.0);
116
116
  result.pdf = 0.0;
117
117
  return;
118
118
  }
119
119
  result.direction = -normal;
120
- result.dist = ga;
120
+ result.dist = gb;
121
121
  result.normal = normal;
122
122
  result.emission = light.emission;
123
123
  result.pdf = 1.0;
@@ -135,8 +135,8 @@ result.dist = sqrt(hl);
135
135
  result.direction = offset / result.dist;
136
136
  result.normal = normal;
137
137
  float fV = dot(-result.direction, normal);
138
- float oC = cos(0.5 * PI * spread);
139
- if (fV <= 0.0 || fV < oC) {
138
+ float oF = cos(0.5 * PI * spread);
139
+ if (fV <= 0.0 || fV < oF) {
140
140
  result.emission = vec3(0.0);
141
141
  result.pdf = 0.0;
142
142
  return;
@@ -146,7 +146,7 @@ result.pdf = hl / max(light.area * fV, 1e-8);
146
146
  cZ(light, surfacePoint, lowerLeft, result);
147
147
  }
148
148
 
149
- void fX(
149
+ void fY(
150
150
  in Light light,
151
151
  in vec3 shadingPoint,
152
152
  inout LightSampleRec result
@@ -159,7 +159,7 @@ result.pdf = 1.0;
159
159
  result.isDelta = true;
160
160
  }
161
161
 
162
- void jK(
162
+ void jM(
163
163
  in Light light,
164
164
  in vec3 shadingPoint,
165
165
  in vec2 samplePoint,
@@ -173,7 +173,7 @@ normalize(shadingPoint - surfacePoint)
173
173
  );
174
174
  }
175
175
 
176
- void iK(
176
+ void iL(
177
177
  in Light light,
178
178
  in vec3 shadingPoint,
179
179
  in vec2 samplePoint,
@@ -182,7 +182,7 @@ inout LightSampleRec result
182
182
  int dO = int(light.type);
183
183
  #ifdef HAS_RECT_LIGHTS
184
184
  if (dO == RECT_LIGHT) {
185
- jJ(light, shadingPoint, samplePoint, result);
185
+ jL(light, shadingPoint, samplePoint, result);
186
186
  return;
187
187
  }
188
188
  #endif
@@ -194,21 +194,21 @@ return;
194
194
  #endif
195
195
  #ifdef HAS_SPOT_LIGHTS
196
196
  if (dO == SPOT_LIGHT) {
197
- jK(light, shadingPoint, samplePoint, result);
197
+ jM(light, shadingPoint, samplePoint, result);
198
198
  return;
199
199
  }
200
200
  #endif
201
201
  #ifdef HAS_DIRECTIONAL_LIGHTS
202
202
  if (dO == DIRECTIONAL_LIGHT) {
203
- fX(light, shadingPoint, result);
203
+ fY(light, shadingPoint, result);
204
204
  }
205
205
  #endif
206
206
  }
207
207
  #endif
208
208
 
209
- void mu(in vec2 samplePoint, inout LightSampleRec result) {
209
+ void mx(in vec2 samplePoint, inout LightSampleRec result) {
210
210
  vec2 uv;
211
- result.direction = oA(samplePoint, uv, result.pdf);
211
+ result.direction = oD(samplePoint, uv, result.pdf);
212
212
  result.emission = textureLinear(envMap, uv).rgb;
213
213
  result.dist = INF;
214
214
  }
@@ -217,36 +217,36 @@ void sampleLight(
217
217
  in vec3 shadingPoint,
218
218
  in vec3 randomSampleValue,
219
219
  inout LightSampleRec result,
220
- bool rP
220
+ bool rU
221
221
  ) {
222
222
  result.isDelta = false;
223
- float tQ = randomSampleValue.z;
224
- bool ko = false;
223
+ float tV = randomSampleValue.z;
224
+ bool kq = false;
225
225
  #ifdef USE_ENVMAP
226
- ko = tQ < envLightSelectionPmf;
227
- if (ko) {
228
- mu(randomSampleValue.xy, result);
226
+ kq = tV < envLightSelectionPmf;
227
+ if (kq) {
228
+ mx(randomSampleValue.xy, result);
229
229
  result.pdf *= envLightSelectionPmf;
230
230
  }
231
231
  #endif
232
232
 
233
233
  #ifdef NUM_LIGHTS
234
- if (!ko) {
235
- int kQ = NUM_LIGHTS - 1;
234
+ if (!kq) {
235
+ int kT = NUM_LIGHTS - 1;
236
236
  for (int index = 0; index < NUM_LIGHTS; index++) {
237
- if (tQ < ql(index).selectionCdf) {
238
- kQ = index;
237
+ if (tV < qp(index).selectionCdf) {
238
+ kT = index;
239
239
  break;
240
240
  }
241
241
  }
242
- Light qb = ql(kQ);
243
- iK(
244
- qb,
242
+ Light qf = qp(kT);
243
+ iL(
244
+ qf,
245
245
  shadingPoint,
246
246
  randomSampleValue.xy,
247
247
  result
248
248
  );
249
- result.pdf *= qb.selectionPmf;
249
+ result.pdf *= qf.selectionPmf;
250
250
  }
251
251
  #endif
252
252
  }