@meimu/mutracer 0.1.3 → 0.1.5

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 (125) hide show
  1. package/dist/assets/bvh.worker.js +1 -1
  2. package/dist/mutracer.umd.js +4155 -4052
  3. package/docs/api.md +13 -10
  4. package/docs/materials.md +17 -26
  5. package/docs/threejs.md +35 -9
  6. package/docs/viewer.md +36 -3
  7. package/lib/Engine.js +18 -1
  8. package/lib/Engine.js.map +1 -1
  9. package/lib/main.d.ts +1 -1
  10. package/lib/main.js.map +1 -1
  11. package/lib/oidn.d.ts +1 -1
  12. package/lib/oidnBundledWeights.cdn.d.ts +2 -2
  13. package/lib/renderer/MaterialTable.d.ts +1 -0
  14. package/lib/renderer/MaterialTable.js +10 -4
  15. package/lib/renderer/MaterialTable.js.map +1 -1
  16. package/lib/renderer/WGPUBloomPass.js +18 -18
  17. package/lib/renderer/WGPUFullQuadPass.js +6 -6
  18. package/lib/renderer/WGPUJNLMDenoiser.js +69 -69
  19. package/lib/renderer/WGPURayTraceOutput.js +14 -14
  20. package/lib/renderer/WGPURayTracePass.d.ts +2 -0
  21. package/lib/renderer/WGPURayTracePass.js +17 -9
  22. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  23. package/lib/renderer/WGPURenderingPipeline.js +15 -15
  24. package/lib/renderer/WebGLJNLMDenoiser.js +69 -69
  25. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  26. package/lib/renderer/WebGLRayTracePass.d.ts +1 -0
  27. package/lib/renderer/WebGLRayTracePass.js +8 -1
  28. package/lib/renderer/WebGLRayTracePass.js.map +1 -1
  29. package/lib/renderer/envMapCreation.d.ts +5 -1
  30. package/lib/renderer/envMapCreation.js +42 -5
  31. package/lib/renderer/envMapCreation.js.map +1 -1
  32. package/lib/renderer/geometryUpdates.js +1 -1
  33. package/lib/renderer/geometryUpdates.js.map +1 -1
  34. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +12 -12
  35. package/lib/renderer/glsl/chunks/envMap.glsl.js +66 -54
  36. package/lib/renderer/glsl/chunks/envMap.glsl.js.map +1 -1
  37. package/lib/renderer/glsl/chunks/intersect.glsl.js +323 -315
  38. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -1
  39. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +154 -121
  40. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -1
  41. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +434 -434
  42. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js.map +1 -1
  43. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  44. package/lib/renderer/glsl/chunks/random.glsl.js +3 -3
  45. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +42 -41
  46. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -1
  47. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +69 -69
  48. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +84 -84
  49. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js.map +1 -1
  50. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +12 -12
  51. package/lib/renderer/glsl/chunks/sampling.glsl.js +75 -75
  52. package/lib/renderer/glsl/chunks/sobol.glsl.js +61 -61
  53. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  54. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +11 -11
  55. package/lib/renderer/glsl/depthQuery.frag.js +5 -5
  56. package/lib/renderer/glsl/depthQuery.frag.js.map +1 -1
  57. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +8 -8
  58. package/lib/renderer/glsl/rayTrace.frag.js +133 -133
  59. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -1
  60. package/lib/renderer/glsl/shadowCatcher.frag.js +9 -9
  61. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -1
  62. package/lib/renderer/glsl/webglPipeline.frag.js +52 -52
  63. package/lib/renderer/lightsUtil.js +6 -4
  64. package/lib/renderer/lightsUtil.js.map +1 -1
  65. package/lib/renderer/materialChanges.js +1 -1
  66. package/lib/renderer/materialChanges.js.map +1 -1
  67. package/lib/renderer/materialComparison.generated.js +36 -18
  68. package/lib/renderer/materialComparison.generated.js.map +1 -1
  69. package/lib/renderer/prepareMeshBVH.js +2 -2
  70. package/lib/renderer/prepareMeshBVH.js.map +1 -1
  71. package/lib/renderer/sceneChangeDetector.js +4 -1
  72. package/lib/renderer/sceneChangeDetector.js.map +1 -1
  73. package/lib/renderer/sceneLightChanges.js +3 -2
  74. package/lib/renderer/sceneLightChanges.js.map +1 -1
  75. package/lib/renderer/scratchSampling.js +18 -18
  76. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  77. package/lib/renderer/wgsl/chunks/envMap.wgsl.d.ts +1 -1
  78. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +39 -31
  79. package/lib/renderer/wgsl/chunks/envMap.wgsl.js.map +1 -1
  80. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +476 -470
  81. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
  82. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +8 -8
  83. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +95 -60
  84. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -1
  85. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +469 -469
  86. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +1 -1
  87. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +117 -120
  88. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -1
  89. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  90. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +25 -22
  91. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -1
  92. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +127 -127
  93. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +136 -136
  94. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +6 -6
  95. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +73 -73
  96. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +62 -62
  97. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +11 -11
  98. package/lib/renderer/wgsl/compose.frag.wgsl.js +105 -105
  99. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  100. package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +1 -1
  101. package/lib/renderer/wgsl/depthQuery.wgsl.js +5 -5
  102. package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -1
  103. package/lib/renderer/wgsl/offlineAdaptive.compute.js +28 -28
  104. package/lib/renderer/wgsl/rayTrace.compute.js +251 -248
  105. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  106. package/lib/scene/EnvironmentLight.d.ts +9 -3
  107. package/lib/scene/EnvironmentLight.js +9 -2
  108. package/lib/scene/EnvironmentLight.js.map +1 -1
  109. package/lib/scene/OpenPBRMaterial.d.ts +1 -1
  110. package/lib/scene/OpenPBRMaterial.js +1 -1
  111. package/lib/scene/OpenPBRMaterial.js.map +1 -1
  112. package/lib/scene/Scene.d.ts +4 -0
  113. package/lib/scene/Scene.js.map +1 -1
  114. package/lib/scene/SpotLight.d.ts +2 -2
  115. package/lib/scene/SpotLight.js +1 -1
  116. package/lib/scene/SpotLight.js.map +1 -1
  117. package/lib/scene/Texture.d.ts +17 -6
  118. package/lib/scene/Texture.js +13 -4
  119. package/lib/scene/Texture.js.map +1 -1
  120. package/lib/util/fromTHREE.js +151 -29
  121. package/lib/util/fromTHREE.js.map +1 -1
  122. package/lib/version.d.ts +1 -1
  123. package/lib/version.js +1 -1
  124. package/lib/version.js.map +1 -1
  125. package/package.json +1 -1
@@ -43,50 +43,50 @@ ${createOpenPbrBsdfWgsl(hasAnisotropyDirections, hasCoatNormals)}
43
43
  ${sampleLightWgsl}
44
44
 
45
45
 
46
- var<private> tE: u32 = 0u;
46
+ var<private> tL: u32 = 0u;
47
47
 
48
48
 
49
49
 
50
- fn jQ() -> u32 {
50
+ fn jX() -> u32 {
51
51
  return u32(max(rtUniform.directLightCandidates, 1));
52
52
  }
53
53
 
54
54
 
55
55
 
56
56
 
57
- fn ps(wI: u32) -> f32 {
57
+ fn pK(wP: u32) -> f32 {
58
58
 
59
59
 
60
60
 
61
61
 
62
62
  if (SAMPLING_PATTERN == 2) { _ = rand(); }
63
- let jW = bc.x + bc.y * u32(rtUniform.outputSize.x);
64
- let key = aq(aq(jW, bd), rtUniform.sequenceSeed);
65
- let dimension = aq(cF, wI) ^ 0xa511e9b3u;
63
+ let kd = bc.x + bc.y * u32(rtUniform.outputSize.x);
64
+ let key = aq(aq(kd, bd), rtUniform.sequenceSeed);
65
+ let dimension = aq(cF, wP) ^ 0xa511e9b3u;
66
66
  return f32(eg(key ^ dimension) >> 8u) * (1.0 / 16777216.0);
67
67
  }
68
68
 
69
69
 
70
70
 
71
- fn tq(fd: f32, scatteringPdf: f32) -> f32 {
72
- let aW = jQ();
73
- if (aW <= 1u) {
74
- return aG(fd, scatteringPdf);
71
+ fn tC(fg: f32, scatteringPdf: f32) -> f32 {
72
+ let aV = jX();
73
+ if (aV <= 1u) {
74
+ return aG(fg, scatteringPdf);
75
75
  }
76
- let iF = f32(aW) * fd;
77
- return iF /
78
- max(iF + scatteringPdf, 1e-20);
76
+ let iJ = f32(aV) * fg;
77
+ return iJ /
78
+ max(iJ + scatteringPdf, 1e-20);
79
79
  }
80
80
 
81
81
 
82
- fn fS(scatteringPdf: f32, fd: f32) -> f32 {
83
- let aW = jQ();
84
- if (aW <= 1u) {
85
- return aG(scatteringPdf, fd);
82
+ fn fX(scatteringPdf: f32, fg: f32) -> f32 {
83
+ let aV = jX();
84
+ if (aV <= 1u) {
85
+ return aG(scatteringPdf, fg);
86
86
  }
87
- let iF = f32(aW) * fd;
87
+ let iJ = f32(aV) * fg;
88
88
  return scatteringPdf /
89
- max(scatteringPdf + iF, 1e-20);
89
+ max(scatteringPdf + iJ, 1e-20);
90
90
  }
91
91
 
92
92
  ${createSampleMaterialWgsl(hasAnisotropyDirections, hasCoatNormals)}
@@ -101,24 +101,24 @@ ${shadowCatcherAccumulationWGSL}
101
101
  @group(3) @binding(3) var<storage, read_write> outShadowCatcher: array<ShadowCatcherAccumulation>;
102
102
 
103
103
 
104
- fn hG(
105
- ha: u32,
106
- vp: vec3f,
104
+ fn hK(
105
+ hg: u32,
106
+ vy: vec3f,
107
107
  normal: vec3f
108
108
  ) {
109
109
  if (rtUniform.varianceMoments != 0) {
110
- let value = dot(vp, luminance);
111
- outNormal[ha] += vec4f(value * value, 0.0, 0.0, 1.0);
110
+ let value = dot(vy, luminance);
111
+ outNormal[hg] += vec4f(value * value, 0.0, 0.0, 1.0);
112
112
  }
113
113
  else {
114
- outNormal[ha] += vec4f(normal, 1.0);
114
+ outNormal[hg] += vec4f(normal, 1.0);
115
115
  }
116
116
  }
117
117
 
118
118
 
119
119
 
120
- fn iN(ha: u32, value: f32) {
121
- outShadowCatcher[ha].moments += vec4f(value, value * value, 0.0, 0.0);
120
+ fn iS(hg: u32, value: f32) {
121
+ outShadowCatcher[hg].moments += vec4f(value, value * value, 0.0, 0.0);
122
122
  }
123
123
 
124
124
 
@@ -130,30 +130,30 @@ normal: vec3f,
130
130
  isBlank: bool,
131
131
  }
132
132
 
133
- fn dq(sF: vec3f, height: f32, radius: f32) -> f32 {
134
- let fN = length(sF);
135
- if (fN < 0.00001) {
133
+ fn dq(sN: vec3f, height: f32, radius: f32) -> f32 {
134
+ let fR = length(sN);
135
+ if (fR < 0.00001) {
136
136
  return -radius;
137
137
  }
138
138
 
139
- let iC = radius * sF.y / fN;
140
- let ij = -1.5 * height;
139
+ let iG = radius * sN.y / fR;
140
+ let iq = -1.5 * height;
141
141
  var ev: f32;
142
- if (iC >= 0.0) {
142
+ if (iG >= 0.0) {
143
143
  ev = radius;
144
144
  }
145
- else if (iC < ij) {
146
- ev = -height * fN / sF.y;
145
+ else if (iG < iq) {
146
+ ev = -height * fR / sN.y;
147
147
  }
148
148
  else {
149
149
  let dW = 1.0
150
- - iC * iC / (3.0 * ij * ij);
150
+ - iG * iG / (3.0 * iq * iq);
151
151
  ev = radius * dW;
152
152
  }
153
- return fN - ev;
153
+ return fR - ev;
154
154
  }
155
155
 
156
- fn eQ(origin: vec3f, direction: vec3f) -> vec3f {
156
+ fn eT(origin: vec3f, direction: vec3f) -> vec3f {
157
157
  if (!USE_GROUNDED_BACKGROUND) {
158
158
  return direction;
159
159
  }
@@ -165,8 +165,8 @@ params.z + params.x,
165
165
  rtUniform.groundedBackgroundCenter.y
166
166
  );
167
167
  let bB = origin - center;
168
- let eI = dot(bB, bY);
169
- let ej = eI * eI
168
+ let eJ = dot(bB, bY);
169
+ let ej = eJ * eJ
170
170
  - dot(bB, bB) + params.y * params.y;
171
171
  if (
172
172
  ej <= 0.0
@@ -175,58 +175,61 @@ ej <= 0.0
175
175
  return direction;
176
176
  }
177
177
 
178
- var cC = -eI + sqrt(ej);
178
+ var cC = -eJ + sqrt(ej);
179
179
  if (cC <= 0.0) {
180
180
  return direction;
181
181
  }
182
182
 
183
- let nE = bB + bY * cC;
184
- if (nE.y >= 0.0) {
185
- return normalize(nE);
183
+ let nO = bB + bY * cC;
184
+ if (nO.y >= 0.0) {
185
+ return normalize(nO);
186
186
  }
187
187
 
188
188
  if (bY.y < -0.00001 && params.y > 1.5 * params.x) {
189
- let hP = (-params.x - bB.y) / bY.y;
190
- let nq = bB + bY * hP;
191
- let oc = (2.0 / 3.0)
189
+ let hT = (-params.x - bB.y) / bY.y;
190
+ let nE = bB + bY * hT;
191
+ let om = (2.0 / 3.0)
192
192
  * sqrt(params.y * params.y - 2.25 * params.x * params.x);
193
- if (hP > 0.0 && length(nq.xz) <= oc) {
194
- return normalize(nq);
193
+ if (hT > 0.0 && length(nE.xz) <= om) {
194
+ return normalize(nE);
195
195
  }
196
196
  }
197
197
 
198
198
  var cN = 0.0;
199
199
  for (var i = 0; i < 14; i++) {
200
- let fe = (cN + cC) * 0.5;
201
- let pt = bB + bY * fe;
202
- if (dq(pt, params.x, params.y) > 0.0) {
203
- cC = fe;
200
+ let fh = (cN + cC) * 0.5;
201
+ let pL = bB + bY * fh;
202
+ if (dq(pL, params.x, params.y) > 0.0) {
203
+ cC = fh;
204
204
  }
205
205
  else {
206
- cN = fe;
206
+ cN = fh;
207
207
  }
208
208
  }
209
209
  let hit = bB + bY * ((cN + cC) * 0.5);
210
210
  return normalize(hit);
211
211
  }
212
212
 
213
- fn hD(ray: Ray) -> vec4f {
213
+ fn hH(ray: Ray) -> vec4f {
214
214
  var bg = vec4f(0.0);
215
215
  if (USE_BACKGROUND_MAP) {
216
- let pT = eQ(ray.o, ray.d);
217
- bg = textureLinear(backgroundMap, aS(pT));
216
+ let d = eT(ray.o, ray.d);
217
+ let t = rtUniform.backgroundMapTransform;
218
+ let qb = vec3f(t.x * d.x - t.y * d.z, d.y, t.y * d.x + t.x * d.z);
219
+ let aW = textureLinear(backgroundMap, eL(qb));
220
+ bg = vec4f(aW.rgb * t.z, aW.a);
218
221
  }
219
222
  else if (USE_BACKGROUND) {
220
223
  bg = rtUniform.backgroundColor;
221
224
  }
222
225
  else if (USE_ENVMAP) {
223
- bg = textureLinear(envMap, aS(ray.d));
226
+ bg = textureLinear(envMap, cY(ray.d));
224
227
  }
225
228
  return bg;
226
229
  }
227
230
 
228
231
  fn cW(ray: Ray, wavelength: f32) -> vec4f {
229
- let bg = hD(ray);
232
+ let bg = hH(ray);
230
233
  if (SPECTRAL) {
231
234
  return vec4f(ai(bg.rgb, wavelength), bg.a);
232
235
  }
@@ -253,20 +256,20 @@ let bg = cW(
253
256
  (*aa).ray,
254
257
  (*si).wavelength
255
258
  );
256
- let cT = select(fS((*aa).scatteringPdf,
257
- iv(aS((*aa).ray.d)) * rtUniform.envLightPmf),
259
+ let cT = select(fX((*aa).scatteringPdf,
260
+ iB(cY((*aa).ray.d)) * rtUniform.envLightPmf),
258
261
  1.0, (*aa).scatteringIsDelta);
259
262
  (*aa).li += cT * (*aa).beta * bg.rgb * bg.a;
260
263
  (*aa).alpha = max((*aa).alpha, bg.a);
261
264
  }
262
265
  else {
263
- let tJ = aS((*aa).ray.d);
264
- var emission = textureLinear(envMap, tJ).rgb;
266
+ let tQ = cY((*aa).ray.d);
267
+ var emission = textureLinear(envMap, tQ).rgb;
265
268
  if (SPECTRAL) {
266
269
  emission = ai(emission, (*si).wavelength);
267
270
  }
268
271
  (*aa).li += (*aa).beta * emission *
269
- fS((*aa).scatteringPdf, iv(tJ));
272
+ fX((*aa).scatteringPdf, iB(tQ));
270
273
  }
271
274
  }
272
275
  else {
@@ -297,10 +300,10 @@ if ((*aa).fromEye) {
297
300
  (USE_BACKGROUND && !USE_BACKGROUND_MAP);
298
301
  }
299
302
  else {
300
- let cam = hy(uv);
301
- let mC = dot(cam.d, (*aa).ray.d) > 0.0;
303
+ let cam = hC(uv);
304
+ let mL = dot(cam.d, (*aa).ray.d) > 0.0;
302
305
  if (rtUniform.transmissiveOutputAlphaMin < 1.0) {
303
- if (mC) {
306
+ if (mL) {
304
307
  (*aa).alpha = max((*aa).alpha, bg.a);
305
308
  } else {
306
309
  (*aa).alpha = 1.0;
@@ -309,11 +312,11 @@ if (mC) {
309
312
  if (!USE_ENVMAP) {
310
313
 
311
314
 
312
- if (mC) {
315
+ if (mL) {
313
316
 
314
317
 
315
318
  (*aa).li += (*aa).beta *
316
- fS((*aa).scatteringPdf, 1.0) * bg.rgb;
319
+ fX((*aa).scatteringPdf, 1.0) * bg.rgb;
317
320
  }
318
321
  }
319
322
  }
@@ -335,12 +338,12 @@ cH = true;
335
338
  if (!cH && rtUniform.transmissiveOutputAlphaMin < 1.0) {
336
339
 
337
340
 
338
- let tP = max(1.0 - (*ma).transmissionWeight, 1.0 - pow(1.0 - rtUniform.transmissiveOutputAlphaMin, f32(*depth)));
339
- (*aa).alpha = max(tP, (*aa).alpha);
341
+ let tW = max(1.0 - (*ma).transmissionWeight, 1.0 - pow(1.0 - rtUniform.transmissiveOutputAlphaMin, f32(*depth)));
342
+ (*aa).alpha = max(tW, (*aa).alpha);
340
343
  }
341
344
  if (!cH) {
342
- tE = u32(max(*depth, 0));
343
- lR(si, ma, aa);
345
+ tL = u32(max(*depth, 0));
346
+ mb(si, ma, aa);
344
347
  }
345
348
  else {
346
349
 
@@ -375,10 +378,10 @@ if (*depth > 4) {
375
378
 
376
379
  if (USE_RR) {
377
380
  if (*depth >= RR_MAX && !cH) {
378
- let oz = (*aa).beta;
381
+ let oH = (*aa).beta;
379
382
 
380
- let oo = max(max(oz.x, oz.y), oz.z);
381
- let q: f32 = max(0.0, 1.0 - oo);
383
+ let oy = max(max(oH.x, oH.y), oH.z);
384
+ let q: f32 = max(0.0, 1.0 - oy);
382
385
  if (dz(cw(RUSSIAN_ROULETTE)) < q) {
383
386
 
384
387
 
@@ -394,13 +397,13 @@ if ((*aa).abort) {
394
397
  return;
395
398
  }
396
399
 
397
- cY((*aa).ray, si, *depth, true, (*aa).isNextRefraction);
398
- eT(ma, (*si).materialIndex, (*si).uv, (*si).uv1, (*si).instanceIndex);
400
+ cZ((*aa).ray, si, *depth, true, (*aa).isNextRefraction);
401
+ eX(ma, (*si).materialIndex, (*si).uv, (*si).uv1, (*si).instanceIndex, (*si).vertexColor);
399
402
 
400
403
  if (SPECTRAL) {
401
404
 
402
405
  if ((*ma).transmissionWeight > 0.001) {
403
- (*ma).specularIor = eK(
406
+ (*ma).specularIor = eN(
404
407
  (*si).wavelength,
405
408
  (*ma).specularIor,
406
409
  (*ma).transmissionDispersionScale,
@@ -415,26 +418,26 @@ return;
415
418
 
416
419
 
417
420
  var lightSample: LightSampleRec;
418
- let hu = eo(3u) < (*ma).alpha;
421
+ let hy = eo(3u) < (*ma).alpha;
419
422
  for (var i = 0; i < rtUniform.lightsCount; i++) {
420
423
 
421
424
  let light: Light = analyticLights[i];
422
- let d = mo((*aa).ray, light, &lightSample);
425
+ let d = my((*aa).ray, light, &lightSample);
423
426
  lightSample.pdf *= light.selectionPmf;
424
- let mt = (*si).hit && d > distance((*si).position, (*aa).ray.o);
425
- if (d != INF && !(mt && hu)) {
426
- let eW = fS((*aa).scatteringPdf, lightSample.pdf);
427
+ let mC = (*si).hit && d > distance((*si).position, (*aa).ray.o);
428
+ if (d != INF && !(mC && hy)) {
429
+ let fa = fX((*aa).scatteringPdf, lightSample.pdf);
427
430
  if (SPECTRAL) {
428
431
  lightSample.emission = ai(lightSample.emission, (*si).wavelength);
429
432
  }
430
- (*aa).li += eW * (*aa).beta * lightSample.emission;
433
+ (*aa).li += fa * (*aa).beta * lightSample.emission;
431
434
  (*aa).alpha = 1.0;
432
435
  (*aa).abort = true;
433
436
  }
434
437
  }
435
438
 
436
439
  if (USE_ENVMAP) {
437
- if (!((*si).hit && hu)) {
440
+ if (!((*si).hit && hy)) {
438
441
  if ((*aa).isNextRefraction) {
439
442
 
440
443
 
@@ -443,19 +446,19 @@ let bg = cW(
443
446
  (*aa).ray,
444
447
  (*si).wavelength
445
448
  );
446
- let cT = select(fS((*aa).scatteringPdf,
447
- iv(aS((*aa).ray.d)) * rtUniform.envLightPmf),
449
+ let cT = select(fX((*aa).scatteringPdf,
450
+ iB(cY((*aa).ray.d)) * rtUniform.envLightPmf),
448
451
  1.0, (*aa).scatteringIsDelta);
449
452
  (*aa).li += cT * (*aa).beta * bg.rgb * bg.a;
450
453
  (*aa).alpha = max((*aa).alpha, bg.a);
451
454
  (*aa).abort = true;
452
455
  return;
453
456
  }
454
- let _uv = aS((*aa).ray.d);
457
+ let _uv = cY((*aa).ray.d);
455
458
  var emission = textureLinear(envMap, _uv).rgb;
456
- let eW = fS(
459
+ let fa = fX(
457
460
  (*aa).scatteringPdf,
458
- iv(_uv) * rtUniform.envLightPmf
461
+ iB(_uv) * rtUniform.envLightPmf
459
462
  );
460
463
  if (SPECTRAL) {
461
464
  emission = ai(emission, (*si).wavelength);
@@ -464,7 +467,7 @@ emission = ai(emission, (*si).wavelength);
464
467
  if (!USE_BACKGROUND) {
465
468
  (*aa).alpha = 1.0;
466
469
  }
467
- (*aa).li += (*aa).beta * emission * eW;
470
+ (*aa).li += (*aa).beta * emission * fa;
468
471
  (*aa).abort = true;
469
472
  }
470
473
  }
@@ -472,40 +475,40 @@ if (!USE_BACKGROUND) {
472
475
  *depth = *depth + 1;
473
476
  }
474
477
 
475
- fn hy(fD: vec2f) -> Ray {
476
- let origin = cameraUniform.viewProjectionInv * vec4f(fD * 2.0 - 1.0, -1.0, 1.0);
477
- let center = cameraUniform.viewProjectionInv * vec4f(fD * 2.0 - 1.0, 1.0, 1.0);
478
+ fn hC(fH: vec2f) -> Ray {
479
+ let origin = cameraUniform.viewProjectionInv * vec4f(fH * 2.0 - 1.0, -1.0, 1.0);
480
+ let center = cameraUniform.viewProjectionInv * vec4f(fH * 2.0 - 1.0, 1.0, 1.0);
478
481
  var cam: Ray;
479
- iw(&cam, origin.xyz / origin.w, normalize(center.xyz * origin.w - origin.xyz * center.w));
482
+ iC(&cam, origin.xyz / origin.w, normalize(center.xyz * origin.w - origin.xyz * center.w));
480
483
 
481
484
  return cam;
482
485
  }
483
486
 
484
487
 
485
- fn kp(radius: f32, xi: f32) -> vec2f {
488
+ fn kz(radius: f32, xi: f32) -> vec2f {
486
489
  var x = 0.25;
487
- for (var ns = 0; ns < 10; ns++) {
490
+ for (var nG = 0; nG < 10; nG++) {
488
491
  let x2 = x * x;
489
492
  let x3 = x2 * x;
490
- let kG = 1.0 - x;
493
+ let kP = 1.0 - x;
491
494
  let value = 10.0 * x2 - 20.0 * x3 + 15.0 * x2 * x2 -
492
495
  4.0 * x2 * x3 - xi;
493
- let lY = 20.0 * x * kG * kG * kG;
494
- if (abs(value) < 1e-6 || lY == 0.0) { break; }
495
- x = clamp(x - value / lY, 0.0, 1.0);
496
+ let mj = 20.0 * x * kP * kP * kP;
497
+ if (abs(value) < 1e-6 || mj == 0.0) { break; }
498
+ x = clamp(x - value / mj, 0.0, 1.0);
496
499
  }
497
- let jj = x * radius;
498
- return vec2f(jj, sqrt(max(radius * radius - jj * jj, 0.0)));
500
+ let jo = x * radius;
501
+ return vec2f(jo, sqrt(max(radius * radius - jo * jo, 0.0)));
499
502
  }
500
503
 
501
- fn iO(radius: f32, gs: f32) -> f32 {
502
- if (gs >= radius) { return 0.0; }
503
- let nV = radius - gs;
504
- return nV * nV * nV;
504
+ fn iT(radius: f32, gx: f32) -> f32 {
505
+ if (gx >= radius) { return 0.0; }
506
+ let og = radius - gx;
507
+ return og * og * og;
505
508
  }
506
509
 
507
510
 
508
- fn mi(source: ad, radius: f32) -> vec3f {
511
+ fn mt(source: ad, radius: f32) -> vec3f {
509
512
  var geometricNormal = source.faceNormal;
510
513
  if (dot(geometricNormal, source.vertexNormal) < 0.0) {
511
514
  geometricNormal = -geometricNormal;
@@ -513,73 +516,73 @@ geometricNormal = -geometricNormal;
513
516
  var tangent: vec3f;
514
517
  var bitangent: vec3f;
515
518
  aL(geometricNormal, &tangent, &bitangent);
516
- var iB = vec3f(0.0);
517
-
518
- for (var ia = 0; ia < BEVEL_SAMPLES; ia++) {
519
- let oY = fk(CAMERA_BEVEL_BASE + u32(ia));
520
- var cA = oY.x;
521
- let ox = oY.y;
522
- var di = geometricNormal;
523
- var fE = tangent;
519
+ var iF = vec3f(0.0);
520
+
521
+ for (var ig = 0; ig < BEVEL_SAMPLES; ig++) {
522
+ let ph = fp(CAMERA_BEVEL_BASE + u32(ig));
523
+ var cA = ph.x;
524
+ let oF = ph.y;
525
+ var dj = geometricNormal;
526
+ var fI = tangent;
524
527
  var ek = bitangent;
525
- var ga = 0.5;
526
- var hU = 0.25;
527
- var gA = 0.25;
528
+ var gf = 0.5;
529
+ var hY = 0.25;
530
+ var gH = 0.25;
528
531
  if (cA < 0.5) {
529
532
  cA *= 2.0;
530
533
  }
531
534
  else if (cA < 0.75) {
532
- let mA = di;
533
- di = fE;
534
- fE = mA;
535
- ga = 0.25;
536
- hU = 0.5;
535
+ let mJ = dj;
536
+ dj = fI;
537
+ fI = mJ;
538
+ gf = 0.25;
539
+ hY = 0.5;
537
540
  cA = (cA - 0.5) * 4.0;
538
541
  }
539
542
  else {
540
- let mA = di;
541
- di = ek;
542
- ek = mA;
543
- ga = 0.25;
544
- gA = 0.5;
543
+ let mJ = dj;
544
+ dj = ek;
545
+ ek = mJ;
546
+ gf = 0.25;
547
+ gH = 0.5;
545
548
  cA = (cA - 0.75) * 4.0;
546
549
  }
547
550
 
548
- let gQ = kp(radius, ox);
551
+ let gV = kz(radius, oF);
549
552
  let phi = TWOPI * cA;
550
- let qn = gQ.x *
551
- (cos(phi) * fE + sin(phi) * ek);
553
+ let qv = gV.x *
554
+ (cos(phi) * fI + sin(phi) * ek);
552
555
  var ray: Ray;
553
- iw(
556
+ iC(
554
557
  &ray,
555
- source.position + di * gQ.y + qn,
556
- -di
558
+ source.position + dj * gV.y + qv,
559
+ -dj
557
560
  );
558
561
  var hit: ad;
559
- iH(
562
+ iM(
560
563
  ray,
561
564
  &hit,
562
565
  source.instanceIndex,
563
- max(2.0 * gQ.y, EPS)
566
+ max(2.0 * gV.y, EPS)
564
567
  );
565
568
  if (!hit.hit) { continue; }
566
569
 
567
- let kH = ga * abs(dot(di, hit.faceNormal));
568
- let mw = hU * abs(dot(fE, hit.faceNormal));
569
- let jU = gA * abs(dot(ek, hit.faceNormal));
570
- var weight = kH / max(
571
- kH * kH + mw * mw +
572
- jU * jU,
570
+ let kQ = gf * abs(dot(dj, hit.faceNormal));
571
+ let mF = hY * abs(dot(fI, hit.faceNormal));
572
+ let kb = gH * abs(dot(ek, hit.faceNormal));
573
+ var weight = kQ / max(
574
+ kQ * kQ + mF * mF +
575
+ kb * kb,
573
576
  1e-8
574
577
  );
575
- weight *= iO(radius, distance(hit.position, source.position)) /
576
- max(iO(radius, gQ.x), 1e-8);
577
- iB += weight * hit.vertexNormal;
578
+ weight *= iT(radius, distance(hit.position, source.position)) /
579
+ max(iT(radius, gV.x), 1e-8);
580
+ iF += weight * hit.vertexNormal;
578
581
  }
579
582
 
580
- if (dot(iB, iB) <= 1e-12) { return source.normal; }
581
- let jC = normalize(iB);
582
- let result = source.normal + jC - source.vertexNormal;
583
+ if (dot(iF, iF) <= 1e-12) { return source.normal; }
584
+ let jH = normalize(iF);
585
+ let result = source.normal + jH - source.vertexNormal;
583
586
  if (dot(result, result) > 1e-12) { return normalize(result); }
584
587
  return source.normal;
585
588
  }
@@ -596,12 +599,12 @@ aa.scatteringIsDelta = false;
596
599
  aa.isNextRefraction = false;
597
600
  aa.abort = false;
598
601
 
599
- let rB = (*ma).transmissionWeight < 0.001 && (*ma).subsurfaceWeight < 0.001 && (*ma).alpha > 0.99;
602
+ let rJ = (*ma).transmissionWeight < 0.001 && (*ma).subsurfaceWeight < 0.001 && (*ma).alpha > 0.99;
600
603
  let bounceLimit = max(rtUniform.bounces, 0);
601
604
  var depth = 0;
602
605
 
603
606
  for (var idx: i32 = 0; idx < min(bounceLimit * 3, ${MAX_PATH_EVENTS}); idx = idx + 1) {
604
- if (rB && idx > bounceLimit) {
607
+ if (rJ && idx > bounceLimit) {
605
608
  aa.abort = true;
606
609
  }
607
610
  if (aa.abort) {
@@ -613,7 +616,7 @@ bounce(uv, &aa, &depth, si, ma, outAux);
613
616
  return vec4f(aa.li, aa.alpha);
614
617
  }
615
618
 
616
- fn iz(uv: vec2f, si: ptr<function, ad>, ray: Ray, ma: ptr<function, J>, outAux: ptr<function, RayTraceAuxiliary>) -> vec4f {
619
+ fn iD(uv: vec2f, si: ptr<function, ad>, ray: Ray, ma: ptr<function, J>, outAux: ptr<function, RayTraceAuxiliary>) -> vec4f {
617
620
  ${deterministicPrimaryAlpha ? /* wgsl */ `let coverage = clamp((*ma).alpha, 0.0, 1.0);
618
621
  if (!(*si).hit || ((*ma).materialType != STANDARD && (*ma).materialType != UNLIT) || coverage >= 1.0) {
619
622
  return bw(uv, si, ray, ma, outAux);
@@ -623,60 +626,60 @@ return bw(uv, si, ray, ma, outAux);
623
626
 
624
627
 
625
628
 
626
- var nN = ray;
627
- nN.o = (*si).position + ray.d * (EPS * 0.02);
628
- var dU = *si;
629
- dU.albedoSampled = false;
630
- cY(nN, &dU, 0, false, false);
631
- var rj: J;
632
- eT(&rj, dU.materialIndex, dU.uv, dU.uv1, dU.instanceIndex);
633
- var gh = *outAux;
634
- if (dU.hit && rj.materialType == STANDARD) {
635
- gh.albedo = select(
636
- rj.baseColor,
629
+ var nX = ray;
630
+ nX.o = (*si).position + ray.d * (EPS * 0.02);
631
+ var dE = *si;
632
+ dE.albedoSampled = false;
633
+ cZ(nX, &dE, 0, false, false);
634
+ var rr: J;
635
+ eX(&rr, dE.materialIndex, dE.uv, dE.uv1, dE.instanceIndex, dE.vertexColor);
636
+ var gn = *outAux;
637
+ if (dE.hit && rr.materialType == STANDARD) {
638
+ gn.albedo = select(
639
+ rr.baseColor,
637
640
  vec3f(1.0),
638
- rj.transmissionWeight > 0.5
641
+ rr.transmissionWeight > 0.5
639
642
  );
640
- gh.normal = select(
641
- dU.normal,
642
- -dU.normal,
643
+ gn.normal = select(
644
+ dE.normal,
645
+ -dE.normal,
643
646
  dot(
644
- dU.normal,
645
- dU.position - cameraUniform.viewInv[3].xyz
647
+ dE.normal,
648
+ dE.position - cameraUniform.viewInv[3].xyz
646
649
  ) > 0.0
647
650
  );
648
- dU.albedoSampled = rj.transmissionWeight > 0.5;
651
+ dE.albedoSampled = rr.transmissionWeight > 0.5;
649
652
  }
650
653
  let back = bw(
651
- uv, &dU, nN, &rj, &gh
654
+ uv, &dE, nX, &rr, &gn
652
655
  );
653
656
  if (coverage <= 0.0) {
654
- *outAux = gh;
657
+ *outAux = gn;
655
658
  return back;
656
659
  }
657
660
 
658
- var tk = *si;
659
- var uB = *ma;
660
- uB.alpha = 1.0;
661
- var iR = *outAux;
662
- let qQ = bw(
663
- uv, &tk, ray, &uB, &iR
661
+ var tu = *si;
662
+ var uI = *ma;
663
+ uI.alpha = 1.0;
664
+ var iW = *outAux;
665
+ let qY = bw(
666
+ uv, &tu, ray, &uI, &iW
664
667
  );
665
- (*outAux).albedo = mix(gh.albedo, iR.albedo, coverage);
666
- let fR = mix(gh.normal, iR.normal, coverage);
668
+ (*outAux).albedo = mix(gn.albedo, iW.albedo, coverage);
669
+ let fW = mix(gn.normal, iW.normal, coverage);
667
670
  (*outAux).normal = select(
668
671
  vec3f(0.0),
669
- normalize(fR),
670
- dot(fR, fR) > 1e-12
672
+ normalize(fW),
673
+ dot(fW, fW) > 1e-12
671
674
  );
672
- (*outAux).isBlank = gh.isBlank && iR.isBlank;
673
- (*outAux).isShadowCatcher = gh.isShadowCatcher && iR.isShadowCatcher;
674
- return mix(back, qQ, coverage);` : /* wgsl */ `return bw(uv, si, ray, ma, outAux);`}
675
+ (*outAux).isBlank = gn.isBlank && iW.isBlank;
676
+ (*outAux).isShadowCatcher = gn.isShadowCatcher && iW.isShadowCatcher;
677
+ return mix(back, qY, coverage);` : /* wgsl */ `return bw(uv, si, ray, ma, outAux);`}
675
678
  }
676
679
 
677
680
 
678
681
 
679
- fn mn(uv: vec2f, ray: Ray, outAux: ptr<function, RayTraceAuxiliary>) -> vec4f {
682
+ fn mx(uv: vec2f, ray: Ray, outAux: ptr<function, RayTraceAuxiliary>) -> vec4f {
680
683
  var si: ad;
681
684
  var ma: J;
682
685
  si.albedoSampled = false;
@@ -687,8 +690,8 @@ si.mediumAnisotropy = 0.0;
687
690
  si.barycentrics = vec2f(0.0);
688
691
 
689
692
 
690
- cY(ray, &si, 0, false, false);
691
- eT(&ma, si.materialIndex, si.uv, si.uv1, si.instanceIndex);
693
+ cZ(ray, &si, 0, false, false);
694
+ eX(&ma, si.materialIndex, si.uv, si.uv1, si.instanceIndex, si.vertexColor);
692
695
 
693
696
  if (si.hit && ma.materialType == SHADOW_CATCHER) {
694
697
  (*outAux).isShadowCatcher = true;
@@ -708,7 +711,7 @@ return vec4f(vec3f(1.0), aa.alpha);
708
711
  else {
709
712
  if (HAS_BEVEL && rtUniform.bevel != 0) {
710
713
  if (ma.bevel > 0.0) {
711
- si.normal = mi(si, ma.bevel);
714
+ si.normal = mt(si, ma.bevel);
712
715
  }
713
716
  }
714
717
 
@@ -734,40 +737,40 @@ if (SPECTRAL) {
734
737
 
735
738
 
736
739
 
737
- let sI = array<f32, 3>(650.0, 510.0, 475.0);
738
- var tH = vec3f(0.0);
740
+ let sQ = array<f32, 3>(650.0, 510.0, 475.0);
741
+ var tO = vec3f(0.0);
739
742
  var alpha = 0.0;
740
- var jz = vec3f(0.0);
741
- var jA = vec3f(0.0);
742
- var rX = true;
743
+ var jE = vec3f(0.0);
744
+ var jF = vec3f(0.0);
745
+ var sf = true;
743
746
  var si2 = si;
744
747
  var ma2 = ma;
745
- let qD = s0;
746
- let nJ = em;
748
+ let qL = s0;
749
+ let nT = em;
747
750
  let eh = rtUniform.dispersionWavelengths == 1;
748
- let jH = si.hit &&
751
+ let jM = si.hit &&
749
752
  ma.transmissionWeight > 0.001 &&
750
753
  ma.transmissionDispersionScale > 0.001;
751
- let rW = select(3, 1, eh);
752
- var lF = 0;
753
- if (eh && jH) {
754
+ let se = select(3, 1, eh);
755
+ var lO = 0;
756
+ if (eh && jM) {
754
757
 
755
758
 
756
- lF = min(i32(floor(dz(CAMERA_WAVELENGTH) * 3.0)), 2);
759
+ lO = min(i32(floor(dz(CAMERA_WAVELENGTH) * 3.0)), 2);
757
760
  }
758
- for (var i = 0; i < rW; i++) {
761
+ for (var i = 0; i < se; i++) {
759
762
 
760
763
 
761
764
 
762
765
  if (!eh) {
763
- s0 = qD;
764
- em = nJ;
766
+ s0 = qL;
767
+ em = nT;
765
768
  cF = 0u;
766
769
  }
767
770
  si.wavelength = 0.0;
768
- if (!eh || jH) {
769
- si.wavelength = sI[select(i, lF, eh)];
770
- ma.specularIor = eK(
771
+ if (!eh || jM) {
772
+ si.wavelength = sQ[select(i, lO, eh)];
773
+ ma.specularIor = eN(
771
774
  si.wavelength,
772
775
  ma.specularIor,
773
776
  ma.transmissionDispersionScale,
@@ -783,32 +786,32 @@ dD.normal = (*outAux).normal;
783
786
  dD.isBlank = false;
784
787
  dD.isShadowCatcher = false;
785
788
  }
786
- let res = iz(uv, &si, ray, &ma, &dD);
789
+ let res = iD(uv, &si, ray, &ma, &dD);
787
790
  if (eh) {
788
791
  *outAux = dD;
789
- let scale = select(1.0, 3.0, jH);
792
+ let scale = select(1.0, 3.0, jM);
790
793
  return vec4f(res.rgb * scale, res.a);
791
794
  }
792
- tH += res.rgb;
795
+ tO += res.rgb;
793
796
  alpha = max(alpha, res.a);
794
- jz += dD.albedo;
795
- jA += dD.normal;
796
- rX = rX && dD.isBlank;
797
+ jE += dD.albedo;
798
+ jF += dD.normal;
799
+ sf = sf && dD.isBlank;
797
800
  si = si2;
798
801
  ma = ma2;
799
802
  }
800
- (*outAux).albedo = jz / 3.0;
801
- (*outAux).normal = jA / 3.0;
802
- (*outAux).isBlank = rX;
803
- return vec4f(tH, alpha);
803
+ (*outAux).albedo = jE / 3.0;
804
+ (*outAux).normal = jF / 3.0;
805
+ (*outAux).isBlank = sf;
806
+ return vec4f(tO, alpha);
804
807
  }
805
808
  else {
806
- return iz(uv, &si, ray, &ma, outAux);
809
+ return iD(uv, &si, ray, &ma, outAux);
807
810
  }
808
811
  }
809
812
  }
810
813
 
811
- fn oC(ip: vec2f) -> vec2f {
814
+ fn oK(ip: vec2f) -> vec2f {
812
815
  let p = 2.0 * ip - 1.0;
813
816
  let greater = abs(p.x) > abs(p.y);
814
817
  let r = select(p.y, p.x, greater);
@@ -823,17 +826,17 @@ let outputSize = rtUniform.outputSize;
823
826
  let scaleOffset = rtUniform.scaleOffset;
824
827
  var jitter = rtUniform.jitter;
825
828
 
826
- let fD = globalId.xy * vec2u(scaleOffset.xy) + vec2u(scaleOffset.zw);
827
- if (fD.x >= u32(outputSize.x) || fD.y >= u32(outputSize.y)) {
829
+ let fH = globalId.xy * vec2u(scaleOffset.xy) + vec2u(scaleOffset.zw);
830
+ if (fH.x >= u32(outputSize.x) || fH.y >= u32(outputSize.y)) {
828
831
  return;
829
832
  }
830
- let idx = fD.x + fD.y * u32(outputSize.x);
833
+ let idx = fH.x + fH.y * u32(outputSize.x);
831
834
 
832
835
  if (
833
836
  rtUniform.adaptiveSampling != 0 &&
834
837
  outNormal[idx].a >= textureLoad(
835
838
  adaptiveSampleTargets,
836
- vec2i(fD),
839
+ vec2i(fH),
837
840
  0
838
841
  ).r
839
842
  ) {
@@ -843,26 +846,26 @@ return;
843
846
 
844
847
 
845
848
 
846
- let uv = (vec2<f32>(f32(fD.x), f32(fD.y)) + vec2f(0.5)) / outputSize;
849
+ let uv = (vec2<f32>(f32(fH.x), f32(fH.y)) + vec2f(0.5)) / outputSize;
847
850
 
848
- bc = fD;
851
+ bc = fH;
849
852
  bd = u32(outNormal[idx].a) + rtUniform.sampleSequenceOffset;
850
853
  cF = 0u; em = 0u;
851
854
  if (SAMPLING_PATTERN == 0 || SAMPLING_PATTERN == 1) {
852
- jitter = (fk(CAMERA_PIXEL) - 0.5) / outputSize;
855
+ jitter = (fp(CAMERA_PIXEL) - 0.5) / outputSize;
853
856
  }
854
- ka(fD, i32(bd ^ eg(rtUniform.sequenceSeed)));
855
- var cam = hy(uv + jitter);
857
+ kh(fH, i32(bd ^ eg(rtUniform.sequenceSeed)));
858
+ var cam = hC(uv + jitter);
856
859
 
857
860
  if (cameraUniform.apertureRadius > 0.0) {
858
861
 
859
862
  let eye = cameraUniform.viewInv[3].xyz;
860
- let nY = -normalize(cameraUniform.viewInv[2].xyz);
861
- let qq = eye + cam.d * (cameraUniform.focusDistance / dot(cam.d, nY));
862
- let rC = cameraUniform.apertureRadius * oC(fk(CAMERA_LENS));
863
- let origin = (cameraUniform.viewInv * vec4f(rC, 0.0, 1.0)).xyz;
864
- let dir = normalize(qq - origin);
865
- iw(&cam, origin, dir);
863
+ let oj = -normalize(cameraUniform.viewInv[2].xyz);
864
+ let qy = eye + cam.d * (cameraUniform.focusDistance / dot(cam.d, oj));
865
+ let rK = cameraUniform.apertureRadius * oK(fp(CAMERA_LENS));
866
+ let origin = (cameraUniform.viewInv * vec4f(rK, 0.0, 1.0)).xyz;
867
+ let dir = normalize(qy - origin);
868
+ iC(&cam, origin, dir);
866
869
  }
867
870
 
868
871
  var outAux: RayTraceAuxiliary;
@@ -870,7 +873,7 @@ outAux.albedo = vec3f(0.0);
870
873
  outAux.normal = vec3f(0.0);
871
874
  outAux.isBlank = false;
872
875
  outAux.isShadowCatcher = false;
873
- var aF = mn(uv + jitter, cam, &outAux);
876
+ var aF = mx(uv + jitter, cam, &outAux);
874
877
 
875
878
 
876
879
 
@@ -885,21 +888,21 @@ aF = vec4f(0.0, 0.0, 0.0, 1.0);
885
888
  if (outAux.isShadowCatcher) {
886
889
 
887
890
 
888
- let dn = hD(cam);
889
- let pY = select(0.0, 1.0, dn.a >= 0.01);
890
- let jq = vec4f(dn.rgb * dn.a, dn.a);
891
+ let aW = hH(cam);
892
+ let qg = select(0.0, 1.0, aW.a >= 0.01);
893
+ let jw = vec4f(aW.rgb * aW.a, aW.a);
891
894
 
892
895
 
893
- outShadowCatcher[idx].mask += vec4f(1.0, dn.a, pY, aF.a);
894
- outShadowCatcher[idx].background += jq;
895
- outColor[idx] += jq;
896
- outAlbedo[idx] += vec4f(outAux.albedo, pY);
897
- hG(idx, dn.rgb, outAux.normal);
896
+ outShadowCatcher[idx].mask += vec4f(1.0, aW.a, qg, aF.a);
897
+ outShadowCatcher[idx].background += jw;
898
+ outColor[idx] += jw;
899
+ outAlbedo[idx] += vec4f(outAux.albedo, qg);
900
+ hK(idx, aW.rgb, outAux.normal);
898
901
 
899
902
 
900
903
  let visibility = 1.0 - aF.a;
901
- iN(idx, visibility * select(
902
- 1.0, dot(dn.rgb, luminance), dn.a >= 0.01
904
+ iS(idx, visibility * select(
905
+ 1.0, dot(aW.rgb, luminance), aW.a >= 0.01
903
906
  ));
904
907
  }
905
908
  else {
@@ -914,8 +917,8 @@ outShadowCatcher[idx].mask.g += aF.a;
914
917
  }
915
918
  outColor[idx] += aF;
916
919
  outAlbedo[idx] += vec4f(outAux.albedo, select(1.0, 0.0, outAux.isBlank));
917
- hG(idx, aF.rgb, outAux.normal);
918
- iN(idx, dot(aF.rgb, luminance));
920
+ hK(idx, aF.rgb, outAux.normal);
921
+ iS(idx, dot(aF.rgb, luminance));
919
922
  }
920
923
  }
921
924
  `;