@meimu/mutracer 0.1.2 → 0.1.4

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 +4475 -4337
  3. package/docs/api.md +11 -9
  4. package/docs/threejs.md +30 -4
  5. package/lib/Engine.js +18 -1
  6. package/lib/Engine.js.map +1 -1
  7. package/lib/main.d.ts +1 -1
  8. package/lib/main.js.map +1 -1
  9. package/lib/oidn.d.ts +1 -1
  10. package/lib/oidnBundledWeights.cdn.d.ts +2 -2
  11. package/lib/renderer/MaterialTable.d.ts +1 -0
  12. package/lib/renderer/MaterialTable.js +10 -4
  13. package/lib/renderer/MaterialTable.js.map +1 -1
  14. package/lib/renderer/WGPUBloomPass.js +18 -18
  15. package/lib/renderer/WGPUFullQuadPass.js +6 -6
  16. package/lib/renderer/WGPUJNLMDenoiser.js +68 -68
  17. package/lib/renderer/WGPURayTraceOutput.js +16 -14
  18. package/lib/renderer/WGPURayTraceOutput.js.map +1 -1
  19. package/lib/renderer/WGPURayTracePass.d.ts +2 -0
  20. package/lib/renderer/WGPURayTracePass.js +13 -7
  21. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  22. package/lib/renderer/WGPURenderingPipeline.js +24 -22
  23. package/lib/renderer/WGPURenderingPipeline.js.map +1 -1
  24. package/lib/renderer/WebGLJNLMDenoiser.js +68 -68
  25. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  26. package/lib/renderer/WebGLRayTracePass.d.ts +1 -0
  27. package/lib/renderer/WebGLRayTracePass.js +7 -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 +69 -57
  36. package/lib/renderer/glsl/chunks/envMap.glsl.js.map +1 -1
  37. package/lib/renderer/glsl/chunks/intersect.glsl.js +316 -310
  38. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -1
  39. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +153 -121
  40. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -1
  41. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +540 -540
  42. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  43. package/lib/renderer/glsl/chunks/random.glsl.js +4 -4
  44. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +40 -39
  45. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -1
  46. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +71 -71
  47. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +84 -84
  48. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +13 -13
  49. package/lib/renderer/glsl/chunks/sampling.glsl.js +77 -77
  50. package/lib/renderer/glsl/chunks/sobol.glsl.js +65 -65
  51. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  52. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +11 -11
  53. package/lib/renderer/glsl/depthQuery.frag.js +5 -5
  54. package/lib/renderer/glsl/depthQuery.frag.js.map +1 -1
  55. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +8 -8
  56. package/lib/renderer/glsl/rayTrace.frag.js +165 -165
  57. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -1
  58. package/lib/renderer/glsl/shadowCatcher.frag.js +14 -14
  59. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -1
  60. package/lib/renderer/glsl/webglPipeline.frag.js +56 -56
  61. package/lib/renderer/lightsUtil.js +7 -5
  62. package/lib/renderer/lightsUtil.js.map +1 -1
  63. package/lib/renderer/materialChanges.js +1 -1
  64. package/lib/renderer/materialChanges.js.map +1 -1
  65. package/lib/renderer/materialComparison.generated.js +36 -18
  66. package/lib/renderer/materialComparison.generated.js.map +1 -1
  67. package/lib/renderer/prepareMeshBVH.js +2 -2
  68. package/lib/renderer/prepareMeshBVH.js.map +1 -1
  69. package/lib/renderer/sceneChangeDetector.js +4 -1
  70. package/lib/renderer/sceneChangeDetector.js.map +1 -1
  71. package/lib/renderer/sceneLightChanges.js +3 -2
  72. package/lib/renderer/sceneLightChanges.js.map +1 -1
  73. package/lib/renderer/scratchSampling.js +18 -18
  74. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  75. package/lib/renderer/wgsl/chunks/envMap.wgsl.d.ts +1 -1
  76. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +39 -31
  77. package/lib/renderer/wgsl/chunks/envMap.wgsl.js.map +1 -1
  78. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +475 -469
  79. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
  80. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +8 -8
  81. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +95 -61
  82. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -1
  83. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +562 -562
  84. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +1 -1
  85. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +117 -120
  86. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -1
  87. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  88. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +25 -22
  89. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -1
  90. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +128 -128
  91. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +143 -143
  92. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +6 -6
  93. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +75 -75
  94. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.d.ts +3 -3
  95. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js +2 -2
  96. package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js.map +1 -1
  97. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +69 -69
  98. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +11 -11
  99. package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +2 -2
  100. package/lib/renderer/wgsl/compose.frag.wgsl.js +130 -102
  101. package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -1
  102. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  103. package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +1 -1
  104. package/lib/renderer/wgsl/depthQuery.wgsl.js +5 -5
  105. package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -1
  106. package/lib/renderer/wgsl/offlineAdaptive.compute.js +28 -28
  107. package/lib/renderer/wgsl/rayTrace.compute.js +289 -277
  108. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  109. package/lib/scene/EnvironmentLight.d.ts +9 -3
  110. package/lib/scene/EnvironmentLight.js +9 -2
  111. package/lib/scene/EnvironmentLight.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 +5 -4
@@ -43,50 +43,50 @@ ${createOpenPbrBsdfWgsl(hasAnisotropyDirections, hasCoatNormals)}
43
43
  ${sampleLightWgsl}
44
44
 
45
45
 
46
- var<private> tw: u32 = 0u;
46
+ var<private> tL: u32 = 0u;
47
47
 
48
48
 
49
49
 
50
- fn jO() -> 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 po(wB: 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 jU = bc.x + bc.y * u32(rtUniform.outputSize.x);
64
- let key = aq(aq(jU, bd), rtUniform.sequenceSeed);
65
- let dimension = aq(cE, wB) ^ 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 tk(fd: f32, scatteringPdf: f32) -> f32 {
72
- let aW = jO();
73
- if (aW <= 1u) {
74
- return aF(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 iE = f32(aW) * fd;
77
- return iE /
78
- max(iE + 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 = jO();
84
- if (aW <= 1u) {
85
- return aF(scatteringPdf, fd);
82
+ fn fW(scatteringPdf: f32, fg: f32) -> f32 {
83
+ let aV = jX();
84
+ if (aV <= 1u) {
85
+ return aG(scatteringPdf, fg);
86
86
  }
87
- let iE = f32(aW) * fd;
87
+ let iJ = f32(aV) * fg;
88
88
  return scatteringPdf /
89
- max(scatteringPdf + iE, 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 hH(
105
- gZ: u32,
106
- vk: vec3f,
104
+ fn hK(
105
+ he: u32,
106
+ vy: vec3f,
107
107
  normal: vec3f
108
108
  ) {
109
109
  if (rtUniform.varianceMoments != 0) {
110
- let value = dot(vk, luminance);
111
- outNormal[gZ] += vec4f(value * value, 0.0, 0.0, 1.0);
110
+ let value = dot(vy, luminance);
111
+ outNormal[he] += vec4f(value * value, 0.0, 0.0, 1.0);
112
112
  }
113
113
  else {
114
- outNormal[gZ] += vec4f(normal, 1.0);
114
+ outNormal[he] += vec4f(normal, 1.0);
115
115
  }
116
116
  }
117
117
 
118
118
 
119
119
 
120
- fn iM(gZ: u32, value: f32) {
121
- outShadowCatcher[gZ].moments += vec4f(value, value * value, 0.0, 0.0);
120
+ fn iS(he: u32, value: f32) {
121
+ outShadowCatcher[he].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(sA: vec3f, height: f32, radius: f32) -> f32 {
134
- let fN = length(sA);
135
- if (fN < 0.00001) {
133
+ fn dq(sN: vec3f, height: f32, radius: f32) -> f32 {
134
+ let fQ = length(sN);
135
+ if (fQ < 0.00001) {
136
136
  return -radius;
137
137
  }
138
138
 
139
- let iC = radius * sA.y / fN;
140
- let ik = -1.5 * height;
139
+ let iG = radius * sN.y / fQ;
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 < ik) {
146
- ev = -height * fN / sA.y;
145
+ else if (iG < iq) {
146
+ ev = -height * fQ / sN.y;
147
147
  }
148
148
  else {
149
149
  let dW = 1.0
150
- - iC * iC / (3.0 * ik * ik);
150
+ - iG * iG / (3.0 * iq * iq);
151
151
  ev = radius * dW;
152
152
  }
153
- return fN - ev;
153
+ return fQ - 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 cB = -eI + sqrt(ej);
179
- if (cB <= 0.0) {
178
+ var cC = -eJ + sqrt(ej);
179
+ if (cC <= 0.0) {
180
180
  return direction;
181
181
  }
182
182
 
183
- let nB = bB + bY * cB;
184
- if (nB.y >= 0.0) {
185
- return normalize(nB);
183
+ let nP = bB + bY * cC;
184
+ if (nP.y >= 0.0) {
185
+ return normalize(nP);
186
186
  }
187
187
 
188
188
  if (bY.y < -0.00001 && params.y > 1.5 * params.x) {
189
- let hQ = (-params.x - bB.y) / bY.y;
190
- let nk = bB + bY * hQ;
191
- let nZ = (2.0 / 3.0)
189
+ let hT = (-params.x - bB.y) / bY.y;
190
+ let nF = bB + bY * hT;
191
+ let oo = (2.0 / 3.0)
192
192
  * sqrt(params.y * params.y - 2.25 * params.x * params.x);
193
- if (hQ > 0.0 && length(nk.xz) <= nZ) {
194
- return normalize(nk);
193
+ if (hT > 0.0 && length(nF.xz) <= oo) {
194
+ return normalize(nF);
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 + cB) * 0.5;
201
- let pp = bB + bY * fe;
202
- if (dq(pp, params.x, params.y) > 0.0) {
203
- cB = 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
- let hit = bB + bY * ((cN + cB) * 0.5);
209
+ let hit = bB + bY * ((cN + cC) * 0.5);
210
210
  return normalize(hit);
211
211
  }
212
212
 
213
- fn hE(ray: Ray) -> vec4f {
213
+ fn hH(ray: Ray) -> vec4f {
214
214
  var bg = vec4f(0.0);
215
215
  if (USE_BACKGROUND_MAP) {
216
- let pP = eQ(ray.o, ray.d);
217
- bg = textureLinear(backgroundMap, aS(pP));
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 = hE(ray);
232
+ let bg = hH(ray);
230
233
  if (SPECTRAL) {
231
234
  return vec4f(ai(bg.rgb, wavelength), bg.a);
232
235
  }
@@ -234,7 +237,7 @@ return bg;
234
237
  }
235
238
 
236
239
  fn bounce(uv: vec2f, aa: ptr<function, Path>, depth: ptr<function, i32>, si: ptr<function, ad>, ma: ptr<function, J>, outAux: ptr<function, RayTraceAuxiliary>) {
237
- cE = u32(max(*depth, 0));
240
+ cF = u32(max(*depth, 0));
238
241
  let matType = (*ma).materialType;
239
242
  let isShadowCatcher = matType == SHADOW_CATCHER;
240
243
  if (isShadowCatcher) {
@@ -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(fW((*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 tE = aS((*aa).ray.d);
264
- var emission = textureLinear(envMap, tE).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(tE));
272
+ fW((*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 = hz(uv);
301
- let mz = dot(cam.d, (*aa).ray.d) > 0.0;
303
+ let cam = hC(uv);
304
+ let mM = dot(cam.d, (*aa).ray.d) > 0.0;
302
305
  if (rtUniform.transmissiveOutputAlphaMin < 1.0) {
303
- if (mz) {
306
+ if (mM) {
304
307
  (*aa).alpha = max((*aa).alpha, bg.a);
305
308
  } else {
306
309
  (*aa).alpha = 1.0;
@@ -309,11 +312,11 @@ if (mz) {
309
312
  if (!USE_ENVMAP) {
310
313
 
311
314
 
312
- if (mz) {
315
+ if (mM) {
313
316
 
314
317
 
315
318
  (*aa).li += (*aa).beta *
316
- fS((*aa).scatteringPdf, 1.0) * bg.rgb;
319
+ fW((*aa).scatteringPdf, 1.0) * bg.rgb;
317
320
  }
318
321
  }
319
322
  }
@@ -321,7 +324,7 @@ fS((*aa).scatteringPdf, 1.0) * bg.rgb;
321
324
  return;
322
325
  }
323
326
 
324
- var cG = false;
327
+ var cH = false;
325
328
  if ((matType == STANDARD || matType == UNLIT)) {
326
329
  let alpha = clamp((*ma).alpha, 0.0, 1.0);
327
330
 
@@ -329,18 +332,18 @@ if (alpha < 1.0) {
329
332
 
330
333
 
331
334
  if (alpha <= 0.0 || eo(3u) > alpha) {
332
- cG = true;
335
+ cH = true;
333
336
  }
334
337
  }
335
- if (!cG && rtUniform.transmissiveOutputAlphaMin < 1.0) {
338
+ if (!cH && rtUniform.transmissiveOutputAlphaMin < 1.0) {
336
339
 
337
340
 
338
- let tK = max(1.0 - (*ma).transmissionWeight, 1.0 - pow(1.0 - rtUniform.transmissiveOutputAlphaMin, f32(*depth)));
339
- (*aa).alpha = max(tK, (*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
- if (!cG) {
342
- tw = u32(max(*depth, 0));
343
- lO(si, ma, aa);
344
+ if (!cH) {
345
+ tL = u32(max(*depth, 0));
346
+ mc(si, ma, aa);
344
347
  }
345
348
  else {
346
349
 
@@ -349,7 +352,7 @@ else {
349
352
  }
350
353
  }
351
354
 
352
- if (!(*si).albedoSampled && !cG) {
355
+ if (!(*si).albedoSampled && !cH) {
353
356
 
354
357
  if ((matType == STANDARD || matType == UNLIT)) {
355
358
  if (!((*ma).transmissionWeight > 0.5 ||
@@ -374,12 +377,12 @@ if (*depth > 4) {
374
377
 
375
378
 
376
379
  if (USE_RR) {
377
- if (*depth >= RR_MAX && !cG) {
378
- let ow = (*aa).beta;
380
+ if (*depth >= RR_MAX && !cH) {
381
+ let oI = (*aa).beta;
379
382
 
380
- let oj = max(max(ow.x, ow.y), ow.z);
381
- let q: f32 = max(0.0, 1.0 - oj);
382
- if (dz(cv(RUSSIAN_ROULETTE)) < q) {
383
+ let oz = max(max(oI.x, oI.y), oI.z);
384
+ let q: f32 = max(0.0, 1.0 - oz);
385
+ if (dz(cw(RUSSIAN_ROULETTE)) < q) {
383
386
 
384
387
 
385
388
  (*aa).alpha = 1.0;
@@ -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,
@@ -409,32 +412,32 @@ if ((*ma).transmissionWeight > 0.001) {
409
412
  }
410
413
  }
411
414
 
412
- if (cG) {
415
+ if (cH) {
413
416
  return;
414
417
  }
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 = mk((*aa).ray, light, &lightSample);
425
+ let d = mz((*aa).ray, light, &lightSample);
423
426
  lightSample.pdf *= light.selectionPmf;
424
- let mp = (*si).hit && d > distance((*si).position, (*aa).ray.o);
425
- if (d != INF && !(mp && hu)) {
426
- let eW = fS((*aa).scatteringPdf, lightSample.pdf);
427
+ let mD = (*si).hit && d > distance((*si).position, (*aa).ray.o);
428
+ if (d != INF && !(mD && hy)) {
429
+ let fa = fW((*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(fW((*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 = fW(
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,114 +475,114 @@ if (!USE_BACKGROUND) {
472
475
  *depth = *depth + 1;
473
476
  }
474
477
 
475
- fn hz(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(fG: vec2f) -> Ray {
479
+ let origin = cameraUniform.viewProjectionInv * vec4f(fG * 2.0 - 1.0, -1.0, 1.0);
480
+ let center = cameraUniform.viewProjectionInv * vec4f(fG * 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 kn(radius: f32, xi: f32) -> vec2f {
488
+ fn kz(radius: f32, xi: f32) -> vec2f {
486
489
  var x = 0.25;
487
- for (var np = 0; np < 10; np++) {
490
+ for (var nH = 0; nH < 10; nH++) {
488
491
  let x2 = x * x;
489
492
  let x3 = x2 * x;
490
- let kD = 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 lV = 20.0 * x * kD * kD * kD;
494
- if (abs(value) < 1e-6 || lV == 0.0) { break; }
495
- x = clamp(x - value / lV, 0.0, 1.0);
496
+ let mk = 20.0 * x * kP * kP * kP;
497
+ if (abs(value) < 1e-6 || mk == 0.0) { break; }
498
+ x = clamp(x - value / mk, 0.0, 1.0);
496
499
  }
497
- let jh = x * radius;
498
- return vec2f(jh, sqrt(max(radius * radius - jh * jh, 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 iN(radius: f32, gr: f32) -> f32 {
502
- if (gr >= radius) { return 0.0; }
503
- let nS = radius - gr;
504
- return nS * nS * nS;
504
+ fn iT(radius: f32, gw: f32) -> f32 {
505
+ if (gw >= radius) { return 0.0; }
506
+ let oh = radius - gw;
507
+ return oh * oh * oh;
505
508
  }
506
509
 
507
510
 
508
- fn mf(source: ad, radius: f32) -> vec3f {
511
+ fn mu(source: ad, radius: f32) -> vec3f {
509
512
  var geometricNormal = source.faceNormal;
510
513
  if (dot(geometricNormal, source.vertexNormal) < 0.0) {
511
514
  geometricNormal = -geometricNormal;
512
515
  }
513
516
  var tangent: vec3f;
514
517
  var bitangent: vec3f;
515
- aK(geometricNormal, &tangent, &bitangent);
516
- var iB = vec3f(0.0);
517
-
518
- for (var ib = 0; ib < BEVEL_SAMPLES; ib++) {
519
- let oU = fk(CAMERA_BEVEL_BASE + u32(ib));
520
- var cz = oU.x;
521
- let ou = oU.y;
522
- var di = geometricNormal;
523
- var fE = tangent;
518
+ aL(geometricNormal, &tangent, &bitangent);
519
+ var iF = vec3f(0.0);
520
+
521
+ for (var ig = 0; ig < BEVEL_SAMPLES; ig++) {
522
+ let ph = fo(CAMERA_BEVEL_BASE + u32(ig));
523
+ var cA = ph.x;
524
+ let oG = ph.y;
525
+ var dj = geometricNormal;
526
+ var fH = tangent;
524
527
  var ek = bitangent;
525
- var fZ = 0.5;
526
- var hV = 0.25;
527
- var gy = 0.25;
528
- if (cz < 0.5) {
529
- cz *= 2.0;
530
- }
531
- else if (cz < 0.75) {
532
- let mx = di;
533
- di = fE;
534
- fE = mx;
535
- fZ = 0.25;
536
- hV = 0.5;
537
- cz = (cz - 0.5) * 4.0;
528
+ var ge = 0.5;
529
+ var hY = 0.25;
530
+ var gG = 0.25;
531
+ if (cA < 0.5) {
532
+ cA *= 2.0;
533
+ }
534
+ else if (cA < 0.75) {
535
+ let mK = dj;
536
+ dj = fH;
537
+ fH = mK;
538
+ ge = 0.25;
539
+ hY = 0.5;
540
+ cA = (cA - 0.5) * 4.0;
538
541
  }
539
542
  else {
540
- let mx = di;
541
- di = ek;
542
- ek = mx;
543
- fZ = 0.25;
544
- gy = 0.5;
545
- cz = (cz - 0.75) * 4.0;
546
- }
547
-
548
- let gO = kn(radius, ou);
549
- let phi = TWOPI * cz;
550
- let qj = gO.x *
551
- (cos(phi) * fE + sin(phi) * ek);
543
+ let mK = dj;
544
+ dj = ek;
545
+ ek = mK;
546
+ ge = 0.25;
547
+ gG = 0.5;
548
+ cA = (cA - 0.75) * 4.0;
549
+ }
550
+
551
+ let gU = kz(radius, oG);
552
+ let phi = TWOPI * cA;
553
+ let qv = gU.x *
554
+ (cos(phi) * fH + sin(phi) * ek);
552
555
  var ray: Ray;
553
- iw(
556
+ iC(
554
557
  &ray,
555
- source.position + di * gO.y + qj,
556
- -di
558
+ source.position + dj * gU.y + qv,
559
+ -dj
557
560
  );
558
561
  var hit: ad;
559
- iG(
562
+ iM(
560
563
  ray,
561
564
  &hit,
562
565
  source.instanceIndex,
563
- max(2.0 * gO.y, EPS)
566
+ max(2.0 * gU.y, EPS)
564
567
  );
565
568
  if (!hit.hit) { continue; }
566
569
 
567
- let kE = fZ * abs(dot(di, hit.faceNormal));
568
- let mt = hV * abs(dot(fE, hit.faceNormal));
569
- let jS = gy * abs(dot(ek, hit.faceNormal));
570
- var weight = kE / max(
571
- kE * kE + mt * mt +
572
- jS * jS,
570
+ let kQ = ge * abs(dot(dj, hit.faceNormal));
571
+ let mG = hY * abs(dot(fH, hit.faceNormal));
572
+ let kb = gG * abs(dot(ek, hit.faceNormal));
573
+ var weight = kQ / max(
574
+ kQ * kQ + mG * mG +
575
+ kb * kb,
573
576
  1e-8
574
577
  );
575
- weight *= iN(radius, distance(hit.position, source.position)) /
576
- max(iN(radius, gO.x), 1e-8);
577
- iB += weight * hit.vertexNormal;
578
+ weight *= iT(radius, distance(hit.position, source.position)) /
579
+ max(iT(radius, gU.x), 1e-8);
580
+ iF += weight * hit.vertexNormal;
578
581
  }
579
582
 
580
- if (dot(iB, iB) <= 1e-12) { return source.normal; }
581
- let jA = normalize(iB);
582
- let result = source.normal + jA - 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 rt = (*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 (rt && 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 nK = ray;
627
- nK.o = (*si).position + ray.d * (EPS * 0.02);
628
- var dU = *si;
629
- dU.albedoSampled = false;
630
- cY(nK, &dU, 0, false, false);
631
- var rd: J;
632
- eT(&rd, dU.materialIndex, dU.uv, dU.uv1, dU.instanceIndex);
633
- var gg = *outAux;
634
- if (dU.hit && rd.materialType == STANDARD) {
635
- gg.albedo = select(
636
- rd.baseColor,
629
+ var nY = ray;
630
+ nY.o = (*si).position + ray.d * (EPS * 0.02);
631
+ var dE = *si;
632
+ dE.albedoSampled = false;
633
+ cZ(nY, &dE, 0, false, false);
634
+ var rr: J;
635
+ eX(&rr, dE.materialIndex, dE.uv, dE.uv1, dE.instanceIndex, dE.vertexColor);
636
+ var gm = *outAux;
637
+ if (dE.hit && rr.materialType == STANDARD) {
638
+ gm.albedo = select(
639
+ rr.baseColor,
637
640
  vec3f(1.0),
638
- rd.transmissionWeight > 0.5
641
+ rr.transmissionWeight > 0.5
639
642
  );
640
- gg.normal = select(
641
- dU.normal,
642
- -dU.normal,
643
+ gm.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 = rd.transmissionWeight > 0.5;
651
+ dE.albedoSampled = rr.transmissionWeight > 0.5;
649
652
  }
650
653
  let back = bw(
651
- uv, &dU, nK, &rd, &gg
654
+ uv, &dE, nY, &rr, &gm
652
655
  );
653
656
  if (coverage <= 0.0) {
654
- *outAux = gg;
657
+ *outAux = gm;
655
658
  return back;
656
659
  }
657
660
 
658
- var te = *si;
659
- var uw = *ma;
660
- uw.alpha = 1.0;
661
- var iQ = *outAux;
662
- let qL = bw(
663
- uv, &te, ray, &uw, &iQ
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(gg.albedo, iQ.albedo, coverage);
666
- let fR = mix(gg.normal, iQ.normal, coverage);
668
+ (*outAux).albedo = mix(gm.albedo, iW.albedo, coverage);
669
+ let fV = mix(gm.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(fV),
673
+ dot(fV, fV) > 1e-12
671
674
  );
672
- (*outAux).isBlank = gg.isBlank && iQ.isBlank;
673
- (*outAux).isShadowCatcher = gg.isShadowCatcher && iQ.isShadowCatcher;
674
- return mix(back, qL, coverage);` : /* wgsl */ `return bw(uv, si, ray, ma, outAux);`}
675
+ (*outAux).isBlank = gm.isBlank && iW.isBlank;
676
+ (*outAux).isShadowCatcher = gm.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 mj(uv: vec2f, ray: Ray, outAux: ptr<function, RayTraceAuxiliary>) -> vec4f {
682
+ fn my(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,10 +690,10 @@ 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
- if (ma.materialType == SHADOW_CATCHER) {
696
+ if (si.hit && ma.materialType == SHADOW_CATCHER) {
694
697
  (*outAux).isShadowCatcher = true;
695
698
 
696
699
 
@@ -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 = mf(si, ma.bevel);
714
+ si.normal = mu(si, ma.bevel);
712
715
  }
713
716
  }
714
717
 
@@ -734,40 +737,40 @@ if (SPECTRAL) {
734
737
 
735
738
 
736
739
 
737
- let sD = array<f32, 3>(650.0, 510.0, 475.0);
738
- var tC = 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 jw = vec3f(0.0);
741
- var jx = vec3f(0.0);
742
- var rS = 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 qz = s0;
746
- let nG = em;
748
+ let qL = s0;
749
+ let nU = em;
747
750
  let eh = rtUniform.dispersionWavelengths == 1;
748
- let jF = si.hit &&
751
+ let jM = si.hit &&
749
752
  ma.transmissionWeight > 0.001 &&
750
753
  ma.transmissionDispersionScale > 0.001;
751
- let rR = select(3, 1, eh);
752
- var lC = 0;
753
- if (eh && jF) {
754
+ let se = select(3, 1, eh);
755
+ var lP = 0;
756
+ if (eh && jM) {
754
757
 
755
758
 
756
- lC = min(i32(floor(dz(CAMERA_WAVELENGTH) * 3.0)), 2);
759
+ lP = min(i32(floor(dz(CAMERA_WAVELENGTH) * 3.0)), 2);
757
760
  }
758
- for (var i = 0; i < rR; i++) {
761
+ for (var i = 0; i < se; i++) {
759
762
 
760
763
 
761
764
 
762
765
  if (!eh) {
763
- s0 = qz;
764
- em = nG;
765
- cE = 0u;
766
+ s0 = qL;
767
+ em = nU;
768
+ cF = 0u;
766
769
  }
767
770
  si.wavelength = 0.0;
768
- if (!eh || jF) {
769
- si.wavelength = sD[select(i, lC, eh)];
770
- ma.specularIor = eK(
771
+ if (!eh || jM) {
772
+ si.wavelength = sQ[select(i, lP, 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, jF);
792
+ let scale = select(1.0, 3.0, jM);
790
793
  return vec4f(res.rgb * scale, res.a);
791
794
  }
792
- tC += res.rgb;
795
+ tO += res.rgb;
793
796
  alpha = max(alpha, res.a);
794
- jw += dD.albedo;
795
- jx += dD.normal;
796
- rS = rS && 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 = jw / 3.0;
801
- (*outAux).normal = jx / 3.0;
802
- (*outAux).isBlank = rS;
803
- return vec4f(tC, 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 oz(ip: vec2f) -> vec2f {
814
+ fn oL(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 fG = globalId.xy * vec2u(scaleOffset.xy) + vec2u(scaleOffset.zw);
830
+ if (fG.x >= u32(outputSize.x) || fG.y >= u32(outputSize.y)) {
828
831
  return;
829
832
  }
830
- let idx = fD.x + fD.y * u32(outputSize.x);
833
+ let idx = fG.x + fG.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(fG),
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(fG.x), f32(fG.y)) + vec2f(0.5)) / outputSize;
847
850
 
848
- bc = fD;
851
+ bc = fG;
849
852
  bd = u32(outNormal[idx].a) + rtUniform.sampleSequenceOffset;
850
- cE = 0u; em = 0u;
853
+ cF = 0u; em = 0u;
851
854
  if (SAMPLING_PATTERN == 0 || SAMPLING_PATTERN == 1) {
852
- jitter = (fk(CAMERA_PIXEL) - 0.5) / outputSize;
855
+ jitter = (fo(CAMERA_PIXEL) - 0.5) / outputSize;
853
856
  }
854
- jY(fD, i32(bd ^ eg(rtUniform.sequenceSeed)));
855
- var cam = hz(uv + jitter);
857
+ kh(fG, 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 nV = -normalize(cameraUniform.viewInv[2].xyz);
861
- let qm = eye + cam.d * (cameraUniform.focusDistance / dot(cam.d, nV));
862
- let ru = cameraUniform.apertureRadius * oz(fk(CAMERA_LENS));
863
- let origin = (cameraUniform.viewInv * vec4f(ru, 0.0, 1.0)).xyz;
864
- let dir = normalize(qm - origin);
865
- iw(&cam, origin, dir);
863
+ let ol = -normalize(cameraUniform.viewInv[2].xyz);
864
+ let qy = eye + cam.d * (cameraUniform.focusDistance / dot(cam.d, ol));
865
+ let rK = cameraUniform.apertureRadius * oL(fo(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,43 +873,52 @@ outAux.albedo = vec3f(0.0);
870
873
  outAux.normal = vec3f(0.0);
871
874
  outAux.isBlank = false;
872
875
  outAux.isShadowCatcher = false;
873
- var aN = mj(uv + jitter, cam, &outAux);
876
+ var aF = my(uv + jitter, cam, &outAux);
874
877
 
875
878
 
876
879
 
877
880
  if (rtUniform.clamping > 0.0) {
878
881
  let clamping = rtUniform.clamping;
879
- aN = vec4(clamp(aN.rgb, -vec3f(clamping), vec3f(clamping)), aN.a);
882
+ aF = vec4(clamp(aF.rgb, -vec3f(clamping), vec3f(clamping)), aF.a);
880
883
  }
881
- if (!(aN.x < INF && aN.x > -EPS)) {
882
- aN = vec4f(0.0, 0.0, 0.0, 1.0);
884
+ if (!(aF.x < INF && aF.x > -EPS)) {
885
+ aF = vec4f(0.0, 0.0, 0.0, 1.0);
883
886
  }
884
887
 
885
888
  if (outAux.isShadowCatcher) {
886
889
 
887
890
 
888
- let dn = hE(cam);
889
- let pU = select(0.0, 1.0, dn.a >= 0.01);
890
- let jo = 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, pU, aN.a);
894
- outShadowCatcher[idx].background += jo;
895
- outColor[idx] += jo;
896
- outAlbedo[idx] += vec4f(outAux.albedo, pU);
897
- hH(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
- let visibility = 1.0 - aN.a;
901
- iM(idx, visibility * select(
902
- 1.0, dot(dn.rgb, luminance), dn.a >= 0.01
903
+ let visibility = 1.0 - aF.a;
904
+ iS(idx, visibility * select(
905
+ 1.0, dot(aW.rgb, luminance), aW.a >= 0.01
903
906
  ));
904
907
  }
905
908
  else {
906
- outColor[idx] += aN;
909
+ if (HAS_SHADOW_CATCHER && outAux.isBlank && USE_BACKGROUND && !USE_BACKGROUND_MAP && rtUniform.backgroundColor.a >= 0.99999) {
910
+
911
+
912
+
913
+
914
+
915
+ outShadowCatcher[idx].background += aF;
916
+ outShadowCatcher[idx].mask.g += aF.a;
917
+ }
918
+ outColor[idx] += aF;
907
919
  outAlbedo[idx] += vec4f(outAux.albedo, select(1.0, 0.0, outAux.isBlank));
908
- hH(idx, aN.rgb, outAux.normal);
909
- iM(idx, dot(aN.rgb, luminance));
920
+ hK(idx, aF.rgb, outAux.normal);
921
+ iS(idx, dot(aF.rgb, luminance));
910
922
  }
911
923
  }
912
924
  `;