@driftengine/core 4.3.0 → 4.4.1

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 (218) hide show
  1. package/CHANGELOG.json +282 -0
  2. package/README.md +1 -1
  3. package/dist/cinematic/cameraPath.d.ts +53 -0
  4. package/dist/cinematic/cameraPath.js +118 -0
  5. package/dist/environment/daylight.d.ts +77 -0
  6. package/dist/environment/daylight.js +77 -0
  7. package/dist/geometry/meshConcat.d.ts +9 -0
  8. package/dist/geometry/meshConcat.js +101 -0
  9. package/dist/index.d.ts +12 -2
  10. package/dist/index.js +14 -1
  11. package/dist/render/ambientOcclusionPass.js +5 -1
  12. package/dist/render/backend/createRenderer.d.ts +13 -1
  13. package/dist/render/backend/createRenderer.js +6 -5
  14. package/dist/render/backend/webgl2/renderer.d.ts +147 -1
  15. package/dist/render/backend/webgl2/renderer.js +402 -23
  16. package/dist/render/backend/webgpu/buffers.js +46 -8
  17. package/dist/render/backend/webgpu/depthPass.d.ts +81 -3
  18. package/dist/render/backend/webgpu/depthPass.js +75 -14
  19. package/dist/render/backend/webgpu/exposurePass.d.ts +39 -0
  20. package/dist/render/backend/webgpu/exposurePass.js +190 -0
  21. package/dist/render/backend/webgpu/fieldCompose.d.ts +11 -0
  22. package/dist/render/backend/webgpu/fieldCompose.js +13 -0
  23. package/dist/render/backend/webgpu/flatPass.d.ts +3 -1
  24. package/dist/render/backend/webgpu/flatPass.js +12 -5
  25. package/dist/render/backend/webgpu/particlePass.d.ts +8 -0
  26. package/dist/render/backend/webgpu/particlePass.js +1 -0
  27. package/dist/render/backend/webgpu/postPass.d.ts +13 -3
  28. package/dist/render/backend/webgpu/probeBake.d.ts +59 -3
  29. package/dist/render/backend/webgpu/probeBake.js +97 -7
  30. package/dist/render/backend/webgpu/probeTargets.d.ts +65 -0
  31. package/dist/render/backend/webgpu/probeTargets.js +180 -0
  32. package/dist/render/backend/webgpu/renderer.d.ts +174 -11
  33. package/dist/render/backend/webgpu/renderer.js +682 -252
  34. package/dist/render/backend/webgpu/scatterPass.js +7 -7
  35. package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.d.ts +1 -1
  36. package/dist/render/backend/webgpu/skinPaletteRing.d.ts +4 -0
  37. package/dist/render/backend/webgpu/skinPaletteRing.js +9 -0
  38. package/dist/render/backend/webgpu/skyPass.js +5 -1
  39. package/dist/render/backend/webgpu/uniformRing.d.ts +31 -1
  40. package/dist/render/backend/webgpu/uniformRing.js +53 -3
  41. package/dist/render/bloomChain.d.ts +6 -0
  42. package/dist/render/bloomChain.js +8 -0
  43. package/dist/render/clusteredLights.d.ts +19 -11
  44. package/dist/render/clusteredLights.js +96 -45
  45. package/dist/render/cutoutCaster.d.ts +23 -0
  46. package/dist/render/cutoutCaster.js +20 -0
  47. package/dist/render/driftLight/bake.d.ts +34 -0
  48. package/dist/render/driftLight/bake.js +95 -0
  49. package/dist/render/driftLight/falloff.d.ts +16 -0
  50. package/dist/render/driftLight/falloff.js +23 -0
  51. package/dist/render/driftLight/layout.d.ts +59 -0
  52. package/dist/render/driftLight/layout.js +138 -0
  53. package/dist/render/driftLight/lightField.d.ts +108 -0
  54. package/dist/render/driftLight/lightField.js +179 -0
  55. package/dist/render/driftLight/uniforms.d.ts +28 -0
  56. package/dist/render/driftLight/uniforms.js +41 -0
  57. package/dist/render/driftLight/visibility.d.ts +18 -0
  58. package/dist/render/driftLight/visibility.js +47 -0
  59. package/dist/render/emptyTexture.d.ts +6 -0
  60. package/dist/render/emptyTexture.js +19 -0
  61. package/dist/render/exposurePass.d.ts +48 -0
  62. package/dist/render/exposurePass.js +172 -0
  63. package/dist/render/flameLight.d.ts +71 -0
  64. package/dist/render/flameLight.js +63 -0
  65. package/dist/render/gi/bounceLights.d.ts +34 -0
  66. package/dist/render/gi/bounceLights.js +66 -0
  67. package/dist/render/gi/fieldReach.d.ts +12 -0
  68. package/dist/render/gi/fieldReach.js +62 -0
  69. package/dist/render/gi/globalField.d.ts +8 -0
  70. package/dist/render/gi/globalField.js +31 -0
  71. package/dist/render/gi/probeTrace.d.ts +3 -1
  72. package/dist/render/gi/probeTrace.js +3 -1
  73. package/dist/render/gpuCapability.js +19 -4
  74. package/dist/render/lightBudget.d.ts +11 -0
  75. package/dist/render/lightBudget.js +11 -0
  76. package/dist/render/pointLightSelection.d.ts +16 -0
  77. package/dist/render/pointLightSelection.js +178 -83
  78. package/dist/render/pointShadowBudget.d.ts +12 -2
  79. package/dist/render/pointShadowBudget.js +16 -10
  80. package/dist/render/probeGrid.d.ts +11 -1
  81. package/dist/render/probeGrid.js +5 -2
  82. package/dist/render/probeSweeps.d.ts +45 -0
  83. package/dist/render/probeSweeps.js +77 -0
  84. package/dist/render/reflectionProbe.d.ts +43 -1
  85. package/dist/render/reflectionProbe.js +17 -3
  86. package/dist/render/renderQuality.d.ts +3 -1
  87. package/dist/render/rendererHarness.d.ts +9 -0
  88. package/dist/render/rendererHarness.js +18 -3
  89. package/dist/render/sceneTarget.d.ts +20 -0
  90. package/dist/render/sceneTarget.js +62 -1
  91. package/dist/render/shaders/ambientOcclusion.d.ts +63 -6
  92. package/dist/render/shaders/ambientOcclusion.js +188 -71
  93. package/dist/render/shaders/cutoutCoverage.d.ts +31 -0
  94. package/dist/render/shaders/cutoutCoverage.js +40 -0
  95. package/dist/render/shaders/depth.d.ts +25 -0
  96. package/dist/render/shaders/depth.js +69 -3
  97. package/dist/render/shaders/exposure.d.ts +52 -0
  98. package/dist/render/shaders/exposure.js +124 -0
  99. package/dist/render/shaders/filmLook.d.ts +47 -0
  100. package/dist/render/shaders/filmLook.js +98 -0
  101. package/dist/render/shaders/flat/directionalShadow.js +35 -4
  102. package/dist/render/shaders/flat/driftLight.d.ts +29 -0
  103. package/dist/render/shaders/flat/driftLight.js +75 -0
  104. package/dist/render/shaders/flat/index.js +5 -0
  105. package/dist/render/shaders/flat/lobes.js +13 -0
  106. package/dist/render/shaders/flat/main.d.ts +1 -1
  107. package/dist/render/shaders/flat/main.js +68 -9
  108. package/dist/render/shaders/flat/preamble.js +23 -5
  109. package/dist/render/shaders/flat/probeGrid.js +46 -3
  110. package/dist/render/shaders/generated/ambientOcclusion.wgsl.d.ts +8 -3
  111. package/dist/render/shaders/generated/ambientOcclusion.wgsl.js +8 -3
  112. package/dist/render/shaders/generated/depth.wgsl.d.ts +100 -0
  113. package/dist/render/shaders/generated/depth.wgsl.js +100 -0
  114. package/dist/render/shaders/generated/exposure.wgsl.d.ts +42 -0
  115. package/dist/render/shaders/generated/exposure.wgsl.js +48 -0
  116. package/dist/render/shaders/generated/flat.wgsl.d.ts +1800 -1344
  117. package/dist/render/shaders/generated/flat.wgsl.js +1816 -1360
  118. package/dist/render/shaders/generated/localExposure.wgsl.d.ts +18 -0
  119. package/dist/render/shaders/generated/localExposure.wgsl.js +24 -0
  120. package/dist/render/shaders/generated/rush.wgsl.d.ts +40 -10
  121. package/dist/render/shaders/generated/rush.wgsl.js +40 -10
  122. package/dist/render/shaders/generated/temporalResolve.wgsl.d.ts +1 -1
  123. package/dist/render/shaders/generated/temporalResolve.wgsl.js +1 -1
  124. package/dist/render/shaders/gi/driftLight.wgsl.d.ts +16 -0
  125. package/dist/render/shaders/gi/driftLight.wgsl.js +49 -0
  126. package/dist/render/shaders/gi/probeBake.wgsl.d.ts +29 -4
  127. package/dist/render/shaders/gi/probeBake.wgsl.js +190 -20
  128. package/dist/render/shaders/globalMedium.js +4 -0
  129. package/dist/render/shaders/localExposure.d.ts +35 -0
  130. package/dist/render/shaders/localExposure.js +138 -0
  131. package/dist/render/shaders/prefilter.d.ts +1 -1
  132. package/dist/render/shaders/prefilter.js +6 -0
  133. package/dist/render/shaders/rush.js +33 -5
  134. package/dist/render/shaders/tangentFrame.d.ts +1 -1
  135. package/dist/render/shaders/tangentFrame.js +15 -3
  136. package/dist/render/shaders/temporalResolve.js +39 -1
  137. package/dist/render/shadowCasters.d.ts +5 -3
  138. package/dist/render/shadowMap.js +13 -0
  139. package/dist/render/surfaceTexture.d.ts +5 -0
  140. package/package.json +6 -6
  141. package/scripts/gpuCompute.mjs +24 -3
  142. package/scripts/png.mjs +23 -12
  143. package/src/cinematic/cameraPath.ts +178 -0
  144. package/src/environment/daylight.ts +152 -0
  145. package/src/geometry/meshConcat.ts +100 -0
  146. package/src/index.ts +32 -0
  147. package/src/render/ambientOcclusionPass.ts +5 -1
  148. package/src/render/backend/createRenderer.ts +22 -6
  149. package/src/render/backend/webgl2/renderer.ts +439 -20
  150. package/src/render/backend/webgpu/buffers.ts +51 -8
  151. package/src/render/backend/webgpu/depthPass.ts +78 -10
  152. package/src/render/backend/webgpu/exposurePass.ts +234 -0
  153. package/src/render/backend/webgpu/fieldCompose.ts +15 -0
  154. package/src/render/backend/webgpu/flatPass.ts +10 -2
  155. package/src/render/backend/webgpu/particlePass.ts +9 -0
  156. package/src/render/backend/webgpu/probeBake.ts +143 -9
  157. package/src/render/backend/webgpu/probeTargets.ts +211 -0
  158. package/src/render/backend/webgpu/renderer.ts +808 -273
  159. package/src/render/backend/webgpu/scatterPass.ts +7 -7
  160. package/src/render/backend/webgpu/skinPaletteRing.ts +10 -0
  161. package/src/render/backend/webgpu/skyPass.ts +5 -1
  162. package/src/render/backend/webgpu/uniformRing.ts +49 -3
  163. package/src/render/bloomChain.ts +9 -0
  164. package/src/render/clusteredLights.ts +108 -63
  165. package/src/render/cutoutCaster.ts +44 -0
  166. package/src/render/driftLight/bake.ts +125 -0
  167. package/src/render/driftLight/falloff.ts +26 -0
  168. package/src/render/driftLight/layout.ts +177 -0
  169. package/src/render/driftLight/lightField.ts +227 -0
  170. package/src/render/driftLight/uniforms.ts +61 -0
  171. package/src/render/driftLight/visibility.ts +58 -0
  172. package/src/render/emptyTexture.ts +41 -0
  173. package/src/render/exposurePass.ts +186 -0
  174. package/src/render/flameLight.ts +135 -0
  175. package/src/render/gi/bounceLights.ts +68 -0
  176. package/src/render/gi/fieldReach.ts +74 -0
  177. package/src/render/gi/globalField.ts +39 -0
  178. package/src/render/gi/probeTrace.ts +3 -1
  179. package/src/render/gpuCapability.ts +18 -5
  180. package/src/render/lightBudget.ts +12 -0
  181. package/src/render/pointLightSelection.ts +191 -79
  182. package/src/render/pointShadowBudget.ts +16 -8
  183. package/src/render/probeGrid.ts +13 -2
  184. package/src/render/probeSweeps.ts +80 -0
  185. package/src/render/reflectionProbe.ts +54 -2
  186. package/src/render/renderQuality.ts +3 -1
  187. package/src/render/rendererHarness.ts +25 -3
  188. package/src/render/sceneTarget.ts +75 -1
  189. package/src/render/shaders/ambientOcclusion.ts +205 -71
  190. package/src/render/shaders/cutoutCoverage.ts +43 -0
  191. package/src/render/shaders/depth.ts +80 -3
  192. package/src/render/shaders/exposure.ts +128 -0
  193. package/src/render/shaders/filmLook.ts +111 -0
  194. package/src/render/shaders/flat/directionalShadow.ts +35 -4
  195. package/src/render/shaders/flat/driftLight.ts +75 -0
  196. package/src/render/shaders/flat/index.ts +5 -0
  197. package/src/render/shaders/flat/lobes.ts +13 -0
  198. package/src/render/shaders/flat/main.ts +68 -9
  199. package/src/render/shaders/flat/preamble.ts +23 -5
  200. package/src/render/shaders/flat/probeGrid.ts +46 -3
  201. package/src/render/shaders/generated/ambientOcclusion.wgsl.ts +8 -3
  202. package/src/render/shaders/generated/depth.wgsl.ts +103 -0
  203. package/src/render/shaders/generated/exposure.wgsl.ts +51 -0
  204. package/src/render/shaders/generated/flat.wgsl.ts +1816 -1360
  205. package/src/render/shaders/generated/localExposure.wgsl.ts +26 -0
  206. package/src/render/shaders/generated/rush.wgsl.ts +40 -10
  207. package/src/render/shaders/generated/temporalResolve.wgsl.ts +1 -1
  208. package/src/render/shaders/gi/driftLight.wgsl.ts +49 -0
  209. package/src/render/shaders/gi/probeBake.wgsl.ts +191 -20
  210. package/src/render/shaders/globalMedium.ts +4 -0
  211. package/src/render/shaders/localExposure.ts +154 -0
  212. package/src/render/shaders/prefilter.ts +6 -0
  213. package/src/render/shaders/rush.ts +33 -5
  214. package/src/render/shaders/tangentFrame.ts +15 -3
  215. package/src/render/shaders/temporalResolve.ts +39 -1
  216. package/src/render/shadowCasters.ts +5 -3
  217. package/src/render/shadowMap.ts +14 -0
  218. package/src/render/surfaceTexture.ts +5 -0
@@ -37,8 +37,13 @@ export const MAIN_GLSL = `void main() {
37
37
  if (uAlbedoEnabled != 0) {
38
38
  vec4 texel = texture(uAlbedo, vUv);
39
39
  // Discarded before anything else is computed: a thrown-away fragment should not pay
40
- // for the lighting it will never contribute to.
41
- if (texel.a < uAlbedoCutout) discard;
40
+ // for the lighting it will never contribute to. The test credits alpha for the mip level
41
+ // it samples, so a needle averaged thin down the chain is not lost; see cutoutCoverage.ts.
42
+ // Behind a branch on a uniform, so a material with no cutoff pays nothing for it.
43
+ if (uAlbedoCutout > 0.0) {
44
+ float tested = cutoutAlpha(texel.a, vUv * vec2(textureSize(uAlbedo, 0)));
45
+ if (tested < uAlbedoCutout) discard;
46
+ }
42
47
  albedo *= texel.rgb;
43
48
  coverage = texel.a;
44
49
  }
@@ -81,6 +86,15 @@ export const MAIN_GLSL = `void main() {
81
86
 
82
87
  if (uLightingEnabled != 0) {
83
88
  vec3 n = normalize(vNormal);
89
+ /*
90
+ * **Which face of a two-sided surface this is, from the normal and not from the rasteriser.**
91
+ * The rasteriser's own facing flag would say it exactly, and it is one more input to the stage: the flat
92
+ * shader already carries sixteen, WebGPU's ceiling, and the seventeenth made every pipeline
93
+ * invalid and every mesh draw nothing. A face whose own normal points away from the eye is the
94
+ * back of the sheet; what that gives up is a sliver at a curved silhouette, where a front face's
95
+ * interpolated normal already leans away and is lit as the back.
96
+ */
97
+ bool backFace = uDoubleSided != 0 && dot(n, uCameraPos - vWorldPos) < 0.0;
84
98
  /*
85
99
  * The authored normal, before either relief perturbs it.
86
100
  *
@@ -260,6 +274,15 @@ export const MAIN_GLSL = `void main() {
260
274
  );
261
275
  }
262
276
 
277
+ /*
278
+ * **The back face of a two-sided surface is lit as its front**, which is glTF's rule for
279
+ * \`doubleSided\`: the whole shading normal turned toward the viewer, after the map and the
280
+ * relief have perturbed it, as three.js turns its normal, tangent and bitangent together.
281
+ * Turning only the interpolated normal would leave a normal map's tilt pointing the wrong way
282
+ * across the fold of every curtain.
283
+ */
284
+ if (backFace) n = -n;
285
+
263
286
  /*
264
287
  * One dot product, used twice: ndl is the lit side and its negative is the night side below.
265
288
  * Shared rather than issued twice because it is the same number and one is cheaper, and not
@@ -273,8 +296,23 @@ export const MAIN_GLSL = `void main() {
273
296
  * term below needs it too. The sun and the moon are the only sources whose shadow
274
297
  * used to stop at a glowing surface.
275
298
  */
299
+ /*
300
+ * **The surface's own n·l, before any map tilted it: the side of the surface the sun is on.**
301
+ *
302
+ * A normal map says which way each texel faces within its surface; it cannot put a texel on the
303
+ * other side of that surface from the sun. Read from the mapped normal alone, the texels of a
304
+ * column's face turned from a high sun that leaned into the light were lit as though the column
305
+ * were not in the way: a field of white specks over stone in shade. So the shadow's band is
306
+ * chosen by this, and the sun is taken away as it reaches zero, over the last two hundredths of
307
+ * n·l, where an unmapped surface's own Lambert term is already under 0.02. Over a tenth it moved
308
+ * every smooth column's terminator in the published scenes. What it gives up is the bump-lit
309
+ * relief of a surface barely facing the sun, where the light was already grazing.
310
+ */
311
+ vec3 surfaceN = normalize(vNormal);
312
+ if (backFace) surfaceN = -surfaceN;
313
+ float surfaceNdl = dot(surfaceN, uDirectionalDir);
276
314
  #if DIRECTIONAL_SHADOWS
277
- float sunShade = shadowFactor(ndl);
315
+ float sunShade = shadowFactor(max(surfaceNdl, 0.0));
278
316
  #else
279
317
  float sunShade = 1.0;
280
318
  #endif
@@ -298,7 +336,13 @@ export const MAIN_GLSL = `void main() {
298
336
  * that shipped before it.
299
337
  */
300
338
  sunShade *= vSkyDirect;
301
- float direct = ndl * sunShade;
339
+ /*
340
+ * And the sun gone from a surface turned from it, whatever its map says. See \`surfaceNdl\`.
341
+ * Its own factor rather than folded into sunShade, which the emissive share reads as the sun's
342
+ * shadow: a lamp's pane turned from the moon is not in shadow, it is only unlit.
343
+ */
344
+ float sunFacing = smoothstep(0.0, 0.02, surfaceNdl);
345
+ float direct = ndl * sunShade * sunFacing;
302
346
 
303
347
  /*
304
348
  * Hemispheric: sky above, ground below, mixed by which way the surface looks. An
@@ -328,6 +372,7 @@ export const MAIN_GLSL = `void main() {
328
372
  * set, which is the guarantee that option was added to give.
329
373
  */
330
374
  vec3 irradiance = gridIrradiance(n, vWorldPos);
375
+ irradiance = mix(irradiance, ambient, probeGridOutside(surfaceN, vWorldPos));
331
376
  ambient = mix(ambient, irradiance, uProbeGridAmbient * uEnvironmentEnabled);
332
377
  #endif
333
378
  /*
@@ -406,7 +451,7 @@ export const MAIN_GLSL = `void main() {
406
451
  * before: \`sunSpec\` is \`vec3(vSpecular)\` at metal 0 and \`vSpecular\` defaults to 0.
407
452
  */
408
453
  vec3 sunHighlight =
409
- uDirectionalColor * specularLobe(max(dot(n, halfway), 0.0), surfaceRoughness) * sunSpec * sunShade;
454
+ uDirectionalColor * specularLobe(max(dot(n, halfway), 0.0), surfaceRoughness) * sunSpec * sunShade * sunFacing;
410
455
  /*
411
456
  * The dielectric's share goes in here, where it has always gone, so the environment blend
412
457
  * below dims it by exactly the reflectance it always dimmed it by. The metal's share is added
@@ -813,6 +858,7 @@ export const MAIN_GLSL = `void main() {
813
858
  */
814
859
  vec3 lampOpen = vec3(0.0);
815
860
  vec3 lampShadowed = vec3(0.0);
861
+ float driftShare = driftLightShare(vWorldPos);
816
862
 
817
863
  /*
818
864
  * Which froxel this fragment is in.
@@ -912,7 +958,7 @@ export const MAIN_GLSL = `void main() {
912
958
  cookie = uintBitsToFloat(rec4.w);
913
959
  } else {
914
960
  i = slot;
915
- if (i >= uLightCount) break;
961
+ if (i >= uLightCount || i >= MAX_LIGHTS) break;
916
962
  lightPos = uLightPos[i];
917
963
  lightRadius = uLightRadius[i];
918
964
  lightColor = uLightColor[i];
@@ -925,6 +971,9 @@ export const MAIN_GLSL = `void main() {
925
971
  iesAxis = uLightIesAxis[i];
926
972
  cookie = uLightCookie[i];
927
973
  }
974
+ /* A DriftLight field's own light carries a negative weight, and is shaded exactly only for the
975
+ share of this pixel the field does not stand in for. See \`driftLight.ts\`. */
976
+ if (lightWeight < 0.0) lightWeight = -lightWeight * (1.0 - driftShare);
928
977
  /*
929
978
  * **The cone, and a point light's is one that admits every direction.**
930
979
  *
@@ -987,6 +1036,8 @@ export const MAIN_GLSL = `void main() {
987
1036
  * grazing the angle is. Without it the cubemap's face seams show as a
988
1037
  * diagonal cross and the whole plane bands.
989
1038
  */
1039
+ /* How present this light's shadow is. See \`POINT_SHADOW_MIN_WEIGHT\`. */
1040
+ float shadowWeight = clamp(falloff * 2.0, 0.0, 1.0);
990
1041
  #if POINT_SHADOWS
991
1042
  float grazing = 1.0 - ndl;
992
1043
  float normalOffset = (0.06 + dist * 0.05) * grazing * grazing + 0.02;
@@ -1025,7 +1076,7 @@ export const MAIN_GLSL = `void main() {
1025
1076
  */
1026
1077
  int shadowRead = clamp(shadowSlot, 0, MAX_LIGHTS - 1);
1027
1078
  int layer = shadowSlot >= 0 && shadowSlot < MAX_LIGHTS ? uPointShadowLayer[shadowRead] : -1;
1028
- if (layer >= 0) {
1079
+ if (layer >= 0 && shadowWeight > POINT_SHADOW_MIN_WEIGHT) {
1029
1080
  occl = mix(
1030
1081
  1.0,
1031
1082
  pointShadow(
@@ -1054,7 +1105,7 @@ export const MAIN_GLSL = `void main() {
1054
1105
  float liveWeight = 0.0;
1055
1106
  int liveLayer =
1056
1107
  shadowSlot >= 0 && shadowSlot < MAX_LIGHTS ? uLivePointShadowLayer[shadowRead] : -1;
1057
- if (liveLayer >= 0) {
1108
+ if (liveLayer >= 0 && shadowWeight > POINT_SHADOW_MIN_WEIGHT) {
1058
1109
  liveOccl = pointShadow(
1059
1110
  uPointShadows,
1060
1111
  float(liveLayer),
@@ -1074,7 +1125,7 @@ export const MAIN_GLSL = `void main() {
1074
1125
  // Blend occlusion out as the light fades, so a shadow can never be more
1075
1126
  // present than the light casting it — and slot changes at the edge of
1076
1127
  // range become invisible rather than a pop.
1077
- float shaded = mix(1.0, occl, clamp(falloff * 2.0, 0.0, 1.0));
1128
+ float shaded = mix(1.0, occl, shadowWeight);
1078
1129
  /*
1079
1130
  * The cone multiplies the distance falloff rather than replacing it, which is what makes a
1080
1131
  * spot a point light with a direction rather than a second kind of light. It is exactly 1
@@ -1494,6 +1545,14 @@ export const MAIN_GLSL = `void main() {
1494
1545
  );
1495
1546
  #endif
1496
1547
  lit += lampOpenFloor * lampShade;
1548
+ /*
1549
+ * DriftLight: every fixed light past the frame's choice, summed and occluded, for the share of
1550
+ * this pixel the exact lights above no longer cover. Diffuse only, and so no metal term: see
1551
+ * \`driftLight.ts\`.
1552
+ */
1553
+ if (driftShare > 0.0) {
1554
+ lit += albedo * driftLightIrradiance(vWorldPos, n) * (driftShare * uDriftLight.w) * (1.0 - metal);
1555
+ }
1497
1556
 
1498
1557
  /*
1499
1558
  * Self-illuminated geometry, dimmed where a lamp's shadow crosses it.
@@ -38,6 +38,12 @@ import { FOG_GLSL } from '../fog.ts';
38
38
  export function preambleGlsl({ maxLights, maxAreaLights }: LightBudget): string {
39
39
  return `#version 300 es
40
40
  precision highp float;
41
+ /*
42
+ * highp int as well: a clustered light is decoded with uintBitsToFloat from texels that arrive as
43
+ * uvec4, and its texel index passes 32767 in a big world. The fragment default for int and uint is
44
+ * mediump, which a sixteen-bit driver truncates, and every clustered light then lights nothing.
45
+ */
46
+ precision highp int;
41
47
 
42
48
  in vec3 vNormal;
43
49
  in vec3 vColor;
@@ -140,6 +146,12 @@ uniform int uAlbedoEnabled;
140
146
  */
141
147
  uniform float uAlbedoCutout;
142
148
 
149
+ /**
150
+ * 1 for a surface seen from both faces: glTF's doubleSided, a curtain or a leaf card. Its draw culls
151
+ * nothing, and a back face is lit as a front, with the shading normal turned toward the viewer.
152
+ */
153
+ uniform int uDoubleSided;
154
+
143
155
  /**
144
156
  * A normal map, in the surface's own space.
145
157
  *
@@ -550,6 +562,12 @@ uniform vec3 uProbeGridCounts;
550
562
  * exactly as it did before any probe existed.
551
563
  */
552
564
  uniform float uProbeGridAmbient;
565
+ /**
566
+ * Which sets of layers the shading reads, and how far between them: the last whole sweep's layer
567
+ * offset, the newest whole sweep's, and the blend from the first toward the second. \`(0, 0, 0)\`
568
+ * for a grid that does not crossfade. See \`probeSweeps.ts\`.
569
+ */
570
+ uniform vec3 uProbeGridSets;
553
571
  #endif
554
572
  /** A world-space box that lights up regardless of time of day (run finished). */
555
573
  uniform vec3 uHighlightMin;
@@ -637,12 +655,12 @@ uvec4 clusterTexel(int texel) {
637
655
  * both numbers sit beside the budgets they come from.
638
656
  */
639
657
  /*
640
- * **Both arms have the same bound, and that equality is deliberate.** There is one loop, so a
641
- * larger clustered cap would raise the bound for the fixed path too, and a scene that never asks
642
- * for froxels would carry a loop of 28 where it carries 16 today. \`MAX_LIGHTS_PER_CLUSTER\` is
643
- * pinned equal to \`MAX_LIGHTS\` for that reason; a test in \`textureUnitBudget.test.ts\` asserts it.
658
+ * **The bound is the froxel's cap, and the fixed arm leaves long before it.** The two were equal
659
+ * until a candlelit interior needed more than sixteen lights in a froxel; see
660
+ * \`MAX_LIGHTS_PER_CLUSTER\`. The fixed arm breaks at \`uLightCount\` and at \`MAX_LIGHTS\`, so it
661
+ * iterates exactly what it did and never indexes its uniform arrays past their end.
644
662
  */
645
- #define LIGHT_LOOP_MAX MAX_LIGHTS
663
+ #define LIGHT_LOOP_MAX MAX_LIGHTS_PER_CLUSTER
646
664
  uniform int uLightCount;
647
665
  /** 0 keeps the radius-shaped falloff; 1 is physical inverse-square with a soft cutoff. */
648
666
  uniform int uLightFalloff;
@@ -73,10 +73,19 @@ void probeCell(vec3 worldPos, out vec3 base, out vec3 frac) {
73
73
  frac *= step(vec3(1.5), uProbeGridCounts);
74
74
  }
75
75
 
76
- /** One probe's diffuse light: the cosine convolution, at its own level, in one fetch. */
76
+ /**
77
+ * One probe's diffuse light: the cosine convolution, at its own level, in one fetch, or two where a
78
+ * crossfading grid is between sweeps. See \`probeSweeps.ts\`: the last whole sweep blended toward
79
+ * the newest, so a grid re-baked a probe a frame changes a little every frame rather than a probe's
80
+ * worth at once. The second fetch is behind a branch on a uniform, so a grid that is not blending
81
+ * pays for one.
82
+ */
77
83
  vec3 probeIrradiance(vec3 dir, float layer) {
78
84
  float level = uEnvironmentIrradianceLevel;
79
- return textureLod(uEnvironment, probeCoord(dir, level, layer), level).rgb;
85
+ vec3 last = textureLod(uEnvironment, probeCoord(dir, level, layer + uProbeGridSets.x), level).rgb;
86
+ if (uProbeGridSets.z <= 0.0) return last;
87
+ vec3 newest = textureLod(uEnvironment, probeCoord(dir, level, layer + uProbeGridSets.y), level).rgb;
88
+ return mix(last, newest, uProbeGridSets.z);
80
89
  }
81
90
 
82
91
  /**
@@ -85,8 +94,12 @@ vec3 probeIrradiance(vec3 dir, float layer) {
85
94
  * textureLod rather than texture throughout, per the 2026-08-07 rule and for a second reason on
86
95
  * top of it: the level is wanted here, and the fetches sit inside a loop that no compiler can
87
96
  * prove uniform.
97
+ *
98
+ * **From the newest whole sweep alone**, where a crossfading grid holds two: a reflection is a
99
+ * picture of the room, and the blend that smooths the diffuse light would be two pictures at once.
88
100
  */
89
- vec3 probeRadiance(vec3 dir, float lod, float layer) {
101
+ vec3 probeRadiance(vec3 dir, float lod, float layerIndex) {
102
+ float layer = layerIndex + uProbeGridSets.y;
90
103
  float lo = clamp(floor(lod), 0.0, uEnvironmentMaxLod);
91
104
  float hi = min(lo + 1.0, uEnvironmentMaxLod);
92
105
  vec3 coarse = textureLod(uEnvironment, probeCoord(dir, hi, layer), hi).rgb;
@@ -129,6 +142,36 @@ float probeVisible(vec3 fromProbe, float distanceM, float layer) {
129
142
  return pow(chebyshev, ${glslFloat(PROBE_VISIBILITY_SHARPNESS)});
130
143
  }
131
144
 
145
+ /**
146
+ * How far a surface outside the grid faces away from it, 0 to 1: how much of its diffuse light the
147
+ * grid cannot know.
148
+ *
149
+ * **Outside the box the grid clamps to its edge probes**, which is right for a floor below the
150
+ * lowest layer or a vault above the highest, where the surface faces back into the grid and sees
151
+ * what those probes see. It is wrong for a face turned away: a building's outer wall read its edge
152
+ * probe's light in the direction of that wall's normal, which from inside the courtyard is the
153
+ * shaded back of the same wall, and drew black under a noon sun. So a surface takes the open sky's
154
+ * hemisphere as it leaves the box facing out, from a metre past it to two and a half, and keeps the
155
+ * grid facing in. What it gives up is the grid's bounce on the outside of a model whose grid does
156
+ * not reach it, which the grid never had.
157
+ *
158
+ * **The normal is the surface's own, never a mapped one.** Read from the mapped normal, the back of a
159
+ * gallery floor a metre past the grid's last row took the sky on every texel its map tilted toward
160
+ * the wall: white glints over paving in shade. Which side of the grid a surface faces is a fact
161
+ * about the surface.
162
+ */
163
+ float probeGridOutside(vec3 n, vec3 worldPos) {
164
+ vec3 top = max(uProbeGridCounts - 1.0, vec3(0.0));
165
+ vec3 local = (worldPos - uProbeGridOrigin) * uProbeGridInvSpacing;
166
+ /* Only along an axis the grid spans: a grid one probe wide on an axis has no side there, and a
167
+ single probe, which lights a whole scene from one place, has none at all. */
168
+ vec3 beyond = (local - clamp(local, vec3(0.0), top)) / max(uProbeGridInvSpacing, vec3(1e-6));
169
+ beyond *= step(vec3(1.5), uProbeGridCounts);
170
+ float distanceM = length(beyond);
171
+ if (distanceM <= 0.0) return 0.0;
172
+ return smoothstep(1.0, 2.5, distanceM) * smoothstep(0.0, 0.5, dot(n, beyond / distanceM));
173
+ }
174
+
132
175
  /**
133
176
  * The grid's diffuse light at a point, trilinear over the eight probes around it.
134
177
  *
@@ -5,9 +5,9 @@
5
5
  * the next generation, and `npm run wgsl:check` fails the build when this is stale.
6
6
  */
7
7
 
8
- export const AO_BLUR_FRAG_WGSL = "struct Uniforms {\n uStep: vec2<f32>,\n uDepthToViewZ: vec4<f32>,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\n@group(0) @binding(34) \nvar uDepth_t: texture_2d<f32>;\n@group(0) @binding(35) \nvar uDepth_s: sampler;\nvar<private> vUv_1: vec2<f32>;\n@group(0) @binding(32) \nvar uAo_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uAo_s: sampler;\nvar<private> fragColor: f32;\n\nfn viewZ_u0028_f1_u003b(depth: ptr<function, f32>) -> f32 {\n var ndc: f32;\n\n let _e22 = (*depth);\n ndc = (1f - (_e22 * 2f));\n let _e27 = unnamed.uDepthToViewZ[0u];\n let _e28 = ndc;\n let _e32 = unnamed.uDepthToViewZ[1u];\n let _e36 = unnamed.uDepthToViewZ[2u];\n let _e37 = ndc;\n let _e41 = unnamed.uDepthToViewZ[3u];\n return (((_e27 * _e28) + _e32) / ((_e36 * _e37) + _e41));\n}\n\nfn main_1() {\n var centre: f32;\n var param: f32;\n var tolerance: f32;\n var sum: f32;\n var weight: f32;\n var i: i32;\n var uv: vec2<f32>;\n var z: f32;\n var param_1: f32;\n var w: f32;\n var local: f32;\n\n let _e31 = vUv_1;\n let _e32 = textureSampleLevel(uDepth_t, uDepth_s, _e31, 0f);\n param = _e32.x;\n let _e34 = viewZ_u0028_f1_u003b((&param));\n centre = _e34;\n let _e35 = centre;\n tolerance = ((0.02f * abs(_e35)) + 0.0001f);\n sum = 0f;\n weight = 0f;\n i = -3i;\n loop {\n let _e39 = i;\n if (_e39 <= 4i) {\n let _e41 = vUv_1;\n let _e43 = unnamed.uStep;\n let _e44 = i;\n uv = (_e41 + (_e43 * f32(_e44)));\n let _e48 = uv;\n let _e49 = textureSampleLevel(uDepth_t, uDepth_s, _e48, 0f);\n param_1 = _e49.x;\n let _e51 = viewZ_u0028_f1_u003b((&param_1));\n z = _e51;\n let _e52 = z;\n let _e53 = centre;\n let _e56 = tolerance;\n w = max(0f, (1f - (abs((_e52 - _e53)) / _e56)));\n let _e60 = uv;\n let _e61 = textureSampleLevel(uAo_t, uAo_s, _e60, 0f);\n let _e63 = w;\n let _e65 = sum;\n sum = (_e65 + (_e61.x * _e63));\n let _e67 = w;\n let _e68 = weight;\n weight = (_e68 + _e67);\n continue;\n } else {\n break;\n }\n continuing {\n let _e70 = i;\n i = (_e70 + 1i);\n }\n }\n let _e72 = weight;\n if (_e72 > 0f) {\n let _e74 = sum;\n let _e75 = weight;\n local = (_e74 / _e75);\n } else {\n let _e77 = vUv_1;\n let _e78 = textureSampleLevel(uAo_t, uAo_s, _e77, 0f);\n local = _e78.x;\n }\n let _e80 = local;\n fragColor = _e80;\n return;\n}\n\n@fragment \nfn main(@location(0) vUv: vec2<f32>) -> @location(0) f32 {\n vUv_1 = vUv;\n main_1();\n let _e3 = fragColor;\n return _e3;\n}\n";
8
+ export const AO_BLUR_FRAG_WGSL = "struct Uniforms {\n uStep: vec2<f32>,\n uDepthToViewZ: vec4<f32>,\n uAoScale: f32,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\n@group(0) @binding(34) \nvar uDepth_t: texture_2d<f32>;\n@group(0) @binding(35) \nvar uDepth_s: sampler;\nvar<private> vUv_1: vec2<f32>;\n@group(0) @binding(32) \nvar uAo_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uAo_s: sampler;\nvar<private> fragColor: f32;\n\nfn viewZ_u0028_f1_u003b(depth: ptr<function, f32>) -> f32 {\n var ndc: f32;\n\n let _e22 = (*depth);\n ndc = (1f - (_e22 * 2f));\n let _e27 = unnamed.uDepthToViewZ[0u];\n let _e28 = ndc;\n let _e32 = unnamed.uDepthToViewZ[1u];\n let _e36 = unnamed.uDepthToViewZ[2u];\n let _e37 = ndc;\n let _e41 = unnamed.uDepthToViewZ[3u];\n return (((_e27 * _e28) + _e32) / ((_e36 * _e37) + _e41));\n}\n\nfn main_1() {\n var depth_1: f32;\n var own: f32;\n var centre: f32;\n var param: f32;\n var inverse: f32;\n var stepAfter: f32;\n var param_1: f32;\n var stepBefore: f32;\n var param_2: f32;\n var slope: f32;\n var sum: f32;\n var weight: f32;\n var i: i32;\n var uv: vec2<f32>;\n var z: f32;\n var param_3: f32;\n var w: f32;\n var blurred: f32;\n var local: f32;\n\n let _e39 = vUv_1;\n let _e40 = textureSampleLevel(uDepth_t, uDepth_s, _e39, 0f);\n depth_1 = _e40.x;\n let _e42 = vUv_1;\n let _e43 = textureSampleLevel(uAo_t, uAo_s, _e42, 0f);\n own = _e43.x;\n let _e45 = depth_1;\n if (_e45 <= 0f) {\n let _e47 = own;\n let _e49 = unnamed.uAoScale;\n fragColor = min((_e47 * _e49), 1f);\n return;\n }\n let _e52 = depth_1;\n param = _e52;\n let _e53 = viewZ_u0028_f1_u003b((&param));\n centre = _e53;\n let _e54 = centre;\n inverse = (1f / _e54);\n let _e56 = vUv_1;\n let _e58 = unnamed.uStep;\n let _e60 = textureSampleLevel(uDepth_t, uDepth_s, (_e56 + _e58), 0f);\n param_1 = _e60.x;\n let _e62 = viewZ_u0028_f1_u003b((&param_1));\n let _e64 = inverse;\n stepAfter = ((1f / _e62) - _e64);\n let _e66 = inverse;\n let _e67 = vUv_1;\n let _e69 = unnamed.uStep;\n let _e71 = textureSampleLevel(uDepth_t, uDepth_s, (_e67 - _e69), 0f);\n param_2 = _e71.x;\n let _e73 = viewZ_u0028_f1_u003b((&param_2));\n stepBefore = (_e66 - (1f / _e73));\n let _e76 = stepAfter;\n let _e78 = stepBefore;\n let _e81 = stepAfter;\n let _e82 = stepBefore;\n slope = select(_e82, _e81, (abs(_e76) < abs(_e78)));\n sum = 0f;\n weight = 0f;\n i = -3i;\n loop {\n let _e84 = i;\n if (_e84 <= 4i) {\n let _e86 = vUv_1;\n let _e88 = unnamed.uStep;\n let _e89 = i;\n uv = (_e86 + (_e88 * f32(_e89)));\n let _e93 = uv;\n let _e94 = textureSampleLevel(uDepth_t, uDepth_s, _e93, 0f);\n param_3 = _e94.x;\n let _e96 = viewZ_u0028_f1_u003b((&param_3));\n z = _e96;\n let _e97 = z;\n let _e98 = inverse;\n let _e99 = slope;\n let _e100 = i;\n w = max(0f, (1f - (abs(((_e97 * (_e98 + (_e99 * f32(_e100)))) - 1f)) / 0.02f)));\n let _e110 = uv;\n let _e111 = textureSampleLevel(uAo_t, uAo_s, _e110, 0f);\n let _e113 = w;\n let _e115 = sum;\n sum = (_e115 + (_e111.x * _e113));\n let _e117 = w;\n let _e118 = weight;\n weight = (_e118 + _e117);\n continue;\n } else {\n break;\n }\n continuing {\n let _e120 = i;\n i = (_e120 + 1i);\n }\n }\n let _e122 = weight;\n if (_e122 > 0f) {\n let _e124 = sum;\n let _e125 = weight;\n local = (_e124 / _e125);\n } else {\n let _e127 = own;\n local = _e127;\n }\n let _e128 = local;\n blurred = _e128;\n let _e129 = blurred;\n let _e131 = unnamed.uAoScale;\n fragColor = min((_e129 * _e131), 1f);\n return;\n}\n\n@fragment \nfn main(@location(0) vUv: vec2<f32>) -> @location(0) f32 {\n vUv_1 = vUv;\n main_1();\n let _e3 = fragColor;\n return _e3;\n}\n";
9
9
 
10
- export const AO_FRAG_WGSL = "struct Uniforms {\n uProjScale: vec2<f32>,\n uInvProjection: mat4x4<f32>,\n uRadius: f32,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vUv_1: vec2<f32>;\n@group(0) @binding(32) \nvar uDepth_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uDepth_s: sampler;\nvar<private> fragColor: f32;\nvar<private> gl_FragCoord_1: vec4<f32>;\n\nfn viewPosition_u0028_vf2_u003b_f1_u003b(uv: ptr<function, vec2<f32>>, depth: ptr<function, f32>) -> vec3<f32> {\n var clip: vec4<f32>;\n var view: vec4<f32>;\n\n let _e33 = (*uv);\n let _e36 = ((_e33 * 2f) - vec2(1f));\n let _e37 = (*depth);\n clip = vec4<f32>(_e36.x, _e36.y, (1f - (_e37 * 2f)), 1f);\n let _e44 = unnamed.uInvProjection;\n let _e45 = clip;\n view = (_e44 * _e45);\n let _e47 = view;\n let _e50 = view[3u];\n return (_e47.xyz / vec3(_e50));\n}\n\nfn main_1() {\n var stepX: vec2<f32>;\n var stepY: vec2<f32>;\n var depth_1: f32;\n var p: vec3<f32>;\n var param: vec2<f32>;\n var param_1: f32;\n var dpdx_: vec3<f32>;\n var dpdy_: vec3<f32>;\n var right: vec3<f32>;\n var param_2: vec2<f32>;\n var param_3: f32;\n var left: vec3<f32>;\n var param_4: vec2<f32>;\n var param_5: f32;\n var down: vec3<f32>;\n var param_6: vec2<f32>;\n var param_7: f32;\n var up: vec3<f32>;\n var param_8: vec2<f32>;\n var param_9: f32;\n var here: f32;\n var edgeFloor: f32;\n var rightGap: f32;\n var leftGap: f32;\n var downGap: f32;\n var upGap: f32;\n var n: vec3<f32>;\n var reach: vec2<f32>;\n var tile: f32;\n var turn: f32;\n var sum: f32;\n var i: i32;\n var t: f32;\n var angle: f32;\n var uv_1: vec2<f32>;\n var sampled: f32;\n var v: vec3<f32>;\n var param_10: vec2<f32>;\n var param_11: f32;\n var vv: f32;\n\n let _e69 = vUv_1;\n let _e70 = dpdx(_e69);\n stepX = _e70;\n let _e71 = vUv_1;\n let _e72 = dpdy(_e71);\n stepY = _e72;\n let _e73 = vUv_1;\n let _e74 = textureSampleLevel(uDepth_t, uDepth_s, _e73, 0f);\n depth_1 = _e74.x;\n let _e76 = vUv_1;\n param = _e76;\n let _e77 = depth_1;\n param_1 = _e77;\n let _e78 = viewPosition_u0028_vf2_u003b_f1_u003b((&param), (&param_1));\n p = _e78;\n let _e79 = p;\n let _e80 = dpdx(_e79);\n dpdx_ = _e80;\n let _e81 = p;\n let _e82 = dpdy(_e81);\n dpdy_ = _e82;\n let _e83 = depth_1;\n if (_e83 <= 0f) {\n fragColor = 1f;\n return;\n }\n let _e85 = vUv_1;\n let _e86 = stepX;\n let _e88 = vUv_1;\n let _e89 = stepX;\n let _e91 = textureSampleLevel(uDepth_t, uDepth_s, (_e88 + _e89), 0f);\n param_2 = (_e85 + _e86);\n param_3 = _e91.x;\n let _e93 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_2), (&param_3));\n right = _e93;\n let _e94 = vUv_1;\n let _e95 = stepX;\n let _e97 = vUv_1;\n let _e98 = stepX;\n let _e100 = textureSampleLevel(uDepth_t, uDepth_s, (_e97 - _e98), 0f);\n param_4 = (_e94 - _e95);\n param_5 = _e100.x;\n let _e102 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_4), (&param_5));\n left = _e102;\n let _e103 = vUv_1;\n let _e104 = stepY;\n let _e106 = vUv_1;\n let _e107 = stepY;\n let _e109 = textureSampleLevel(uDepth_t, uDepth_s, (_e106 + _e107), 0f);\n param_6 = (_e103 + _e104);\n param_7 = _e109.x;\n let _e111 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_6), (&param_7));\n down = _e111;\n let _e112 = vUv_1;\n let _e113 = stepY;\n let _e115 = vUv_1;\n let _e116 = stepY;\n let _e118 = textureSampleLevel(uDepth_t, uDepth_s, (_e115 - _e116), 0f);\n param_8 = (_e112 - _e113);\n param_9 = _e118.x;\n let _e120 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_8), (&param_9));\n up = _e120;\n let _e122 = p[2u];\n here = -(_e122);\n let _e124 = here;\n edgeFloor = (0.05f * _e124);\n let _e127 = right[2u];\n let _e129 = here;\n rightGap = abs((-(_e127) - _e129));\n let _e133 = left[2u];\n let _e135 = here;\n leftGap = abs((-(_e133) - _e135));\n let _e139 = down[2u];\n let _e141 = here;\n downGap = abs((-(_e139) - _e141));\n let _e145 = up[2u];\n let _e147 = here;\n upGap = abs((-(_e145) - _e147));\n let _e150 = rightGap;\n let _e151 = leftGap;\n let _e153 = edgeFloor;\n if (_e150 > ((_e151 * 8f) + _e153)) {\n let _e156 = p;\n let _e157 = left;\n dpdx_ = (_e156 - _e157);\n } else {\n let _e159 = leftGap;\n let _e160 = rightGap;\n let _e162 = edgeFloor;\n if (_e159 > ((_e160 * 8f) + _e162)) {\n let _e165 = right;\n let _e166 = p;\n dpdx_ = (_e165 - _e166);\n }\n }\n let _e168 = downGap;\n let _e169 = upGap;\n let _e171 = edgeFloor;\n if (_e168 > ((_e169 * 8f) + _e171)) {\n let _e174 = p;\n let _e175 = up;\n dpdy_ = (_e174 - _e175);\n } else {\n let _e177 = upGap;\n let _e178 = downGap;\n let _e180 = edgeFloor;\n if (_e177 > ((_e178 * 8f) + _e180)) {\n let _e183 = down;\n let _e184 = p;\n dpdy_ = (_e183 - _e184);\n }\n }\n let _e186 = dpdx_;\n let _e187 = dpdy_;\n n = normalize(cross(_e186, _e187));\n let _e190 = n;\n let _e191 = p;\n if (dot(_e190, _e191) > 0f) {\n let _e194 = n;\n n = -(_e194);\n }\n let _e197 = unnamed.uRadius;\n let _e199 = unnamed.uProjScale;\n let _e203 = p[2u];\n reach = min((((_e199 * _e197) * 0.5f) / vec2(max(-(_e203), 0.001f))), vec2<f32>(0.06f, 0.06f));\n let _e210 = gl_FragCoord_1[0u];\n let _e216 = gl_FragCoord_1[1u];\n tile = ((_e210 - (floor((_e210 / 4f)) * 4f)) + (4f * (_e216 - (floor((_e216 / 4f)) * 4f))));\n let _e223 = tile;\n turn = (_e223 * 0.3926991f);\n sum = 0f;\n i = 0i;\n loop {\n let _e225 = i;\n if (_e225 < 12i) {\n let _e227 = i;\n t = ((f32(_e227) + 0.5f) / 12f);\n let _e231 = turn;\n let _e232 = i;\n angle = (_e231 + (f32(_e232) * 2.3999631f));\n let _e236 = vUv_1;\n let _e237 = angle;\n let _e239 = angle;\n let _e242 = t;\n let _e245 = reach;\n uv_1 = (_e236 + ((vec2<f32>(cos(_e237), sin(_e239)) * sqrt(_e242)) * _e245));\n let _e248 = uv_1;\n let _e249 = textureSampleLevel(uDepth_t, uDepth_s, _e248, 0f);\n sampled = _e249.x;\n let _e251 = sampled;\n if (_e251 <= 0f) {\n continue;\n }\n let _e253 = uv_1;\n param_10 = _e253;\n let _e254 = sampled;\n param_11 = _e254;\n let _e255 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_10), (&param_11));\n let _e256 = p;\n v = (_e255 - _e256);\n let _e258 = v;\n let _e259 = v;\n vv = dot(_e258, _e259);\n let _e261 = vv;\n let _e263 = unnamed.uRadius;\n let _e265 = unnamed.uRadius;\n if (_e261 > (_e263 * _e265)) {\n continue;\n }\n let _e268 = v;\n let _e269 = n;\n let _e272 = p[2u];\n let _e277 = vv;\n let _e280 = sum;\n sum = (_e280 + (max(0f, (dot(_e268, _e269) - (0.004f * -(_e272)))) / (_e277 + 0.01f)));\n continue;\n } else {\n break;\n }\n continuing {\n let _e282 = i;\n i = (_e282 + 1i);\n }\n }\n let _e285 = unnamed.uRadius;\n let _e287 = sum;\n fragColor = clamp((1f - (((2f * _e285) * _e287) / 12f)), 0f, 1f);\n return;\n}\n\n@fragment \nfn main(@location(0) vUv: vec2<f32>, @builtin(position) gl_FragCoord: vec4<f32>) -> @location(0) f32 {\n vUv_1 = vUv;\n gl_FragCoord_1 = gl_FragCoord;\n main_1();\n let _e5 = fragColor;\n return _e5;\n}\n";
10
+ export const AO_FRAG_WGSL = "struct Uniforms {\n uProjScale: vec2<f32>,\n uInvProjection: mat4x4<f32>,\n uRadius: f32,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vUv_1: vec2<f32>;\n@group(0) @binding(32) \nvar uDepth_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uDepth_s: sampler;\nvar<private> fragColor: f32;\nvar<private> gl_FragCoord_1: vec4<f32>;\n\nfn gtaoArc_u0028_f1_u003b_f1_u003b_f1_u003b(h0_: ptr<function, f32>, h1_: ptr<function, f32>, normal: ptr<function, f32>) -> f32 {\n var c: f32;\n var s2_: f32;\n\n let _e40 = (*normal);\n c = cos(_e40);\n let _e42 = (*normal);\n s2_ = (2f * sin(_e42));\n let _e45 = (*h0_);\n let _e47 = (*normal);\n let _e51 = c;\n let _e53 = (*h0_);\n let _e54 = s2_;\n let _e58 = (*h1_);\n let _e60 = (*normal);\n let _e64 = c;\n let _e66 = (*h1_);\n let _e67 = s2_;\n return ((0.25f * ((-(cos(((2f * _e45) - _e47))) + _e51) + (_e53 * _e54))) + (0.25f * ((-(cos(((2f * _e58) - _e60))) + _e64) + (_e66 * _e67))));\n}\n\nfn viewPosition_u0028_vf2_u003b_f1_u003b(uv: ptr<function, vec2<f32>>, depth: ptr<function, f32>) -> vec3<f32> {\n var clip: vec4<f32>;\n var view: vec4<f32>;\n\n let _e39 = (*uv);\n let _e42 = ((_e39 * 2f) - vec2(1f));\n let _e43 = (*depth);\n clip = vec4<f32>(_e42.x, _e42.y, (1f - (_e43 * 2f)), 1f);\n let _e50 = unnamed.uInvProjection;\n let _e51 = clip;\n view = (_e50 * _e51);\n let _e53 = view;\n let _e56 = view[3u];\n return (_e53.xyz / vec3(_e56));\n}\n\nfn main_1() {\n var stepX: vec2<f32>;\n var stepY: vec2<f32>;\n var depth_1: f32;\n var p: vec3<f32>;\n var param: vec2<f32>;\n var param_1: f32;\n var dpdx_: vec3<f32>;\n var dpdy_: vec3<f32>;\n var right: vec3<f32>;\n var param_2: vec2<f32>;\n var param_3: f32;\n var left: vec3<f32>;\n var param_4: vec2<f32>;\n var param_5: f32;\n var down: vec3<f32>;\n var param_6: vec2<f32>;\n var param_7: f32;\n var up: vec3<f32>;\n var param_8: vec2<f32>;\n var param_9: f32;\n var here: f32;\n var edgeFloor: f32;\n var rightGap: f32;\n var leftGap: f32;\n var downGap: f32;\n var upGap: f32;\n var n: vec3<f32>;\n var toEye: vec3<f32>;\n var reach: vec2<f32>;\n var tile: f32;\n var turn: f32;\n var stagger: f32;\n var pixel: vec2<f32>;\n var visible: f32;\n var slice: i32;\n var angle: f32;\n var screen: vec2<f32>;\n var along: vec3<f32>;\n var param_10: vec2<f32>;\n var param_11: f32;\n var across: vec3<f32>;\n var axis: vec3<f32>;\n var projected: vec3<f32>;\n var projectedLength: f32;\n var normalAngle: f32;\n var horizon0_: f32;\n var horizon1_: f32;\n var k: i32;\n var t: f32;\n var stride: vec2<f32>;\n var side: i32;\n var uv_1: vec2<f32>;\n var local: vec2<f32>;\n var sampled: f32;\n var v: vec3<f32>;\n var param_12: vec2<f32>;\n var param_13: f32;\n var distance2_: f32;\n var cosine: f32;\n var fade: f32;\n var local_1: f32;\n var local_2: f32;\n var h0_1: f32;\n var h1_1: f32;\n var param_14: f32;\n var param_15: f32;\n var param_16: f32;\n\n let _e102 = vUv_1;\n let _e103 = dpdx(_e102);\n stepX = _e103;\n let _e104 = vUv_1;\n let _e105 = dpdy(_e104);\n stepY = _e105;\n let _e106 = vUv_1;\n let _e107 = textureSampleLevel(uDepth_t, uDepth_s, _e106, 0f);\n depth_1 = _e107.x;\n let _e109 = vUv_1;\n param = _e109;\n let _e110 = depth_1;\n param_1 = _e110;\n let _e111 = viewPosition_u0028_vf2_u003b_f1_u003b((&param), (&param_1));\n p = _e111;\n let _e112 = p;\n let _e113 = dpdx(_e112);\n dpdx_ = _e113;\n let _e114 = p;\n let _e115 = dpdy(_e114);\n dpdy_ = _e115;\n let _e116 = depth_1;\n if (_e116 <= 0f) {\n fragColor = 1f;\n return;\n }\n let _e118 = vUv_1;\n let _e119 = stepX;\n let _e121 = vUv_1;\n let _e122 = stepX;\n let _e124 = textureSampleLevel(uDepth_t, uDepth_s, (_e121 + _e122), 0f);\n param_2 = (_e118 + _e119);\n param_3 = _e124.x;\n let _e126 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_2), (&param_3));\n right = _e126;\n let _e127 = vUv_1;\n let _e128 = stepX;\n let _e130 = vUv_1;\n let _e131 = stepX;\n let _e133 = textureSampleLevel(uDepth_t, uDepth_s, (_e130 - _e131), 0f);\n param_4 = (_e127 - _e128);\n param_5 = _e133.x;\n let _e135 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_4), (&param_5));\n left = _e135;\n let _e136 = vUv_1;\n let _e137 = stepY;\n let _e139 = vUv_1;\n let _e140 = stepY;\n let _e142 = textureSampleLevel(uDepth_t, uDepth_s, (_e139 + _e140), 0f);\n param_6 = (_e136 + _e137);\n param_7 = _e142.x;\n let _e144 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_6), (&param_7));\n down = _e144;\n let _e145 = vUv_1;\n let _e146 = stepY;\n let _e148 = vUv_1;\n let _e149 = stepY;\n let _e151 = textureSampleLevel(uDepth_t, uDepth_s, (_e148 - _e149), 0f);\n param_8 = (_e145 - _e146);\n param_9 = _e151.x;\n let _e153 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_8), (&param_9));\n up = _e153;\n let _e155 = p[2u];\n here = -(_e155);\n let _e157 = here;\n edgeFloor = (0.05f * _e157);\n let _e160 = right[2u];\n let _e162 = here;\n rightGap = abs((-(_e160) - _e162));\n let _e166 = left[2u];\n let _e168 = here;\n leftGap = abs((-(_e166) - _e168));\n let _e172 = down[2u];\n let _e174 = here;\n downGap = abs((-(_e172) - _e174));\n let _e178 = up[2u];\n let _e180 = here;\n upGap = abs((-(_e178) - _e180));\n let _e183 = rightGap;\n let _e184 = leftGap;\n let _e186 = edgeFloor;\n if (_e183 > ((_e184 * 8f) + _e186)) {\n let _e189 = p;\n let _e190 = left;\n dpdx_ = (_e189 - _e190);\n } else {\n let _e192 = leftGap;\n let _e193 = rightGap;\n let _e195 = edgeFloor;\n if (_e192 > ((_e193 * 8f) + _e195)) {\n let _e198 = right;\n let _e199 = p;\n dpdx_ = (_e198 - _e199);\n }\n }\n let _e201 = downGap;\n let _e202 = upGap;\n let _e204 = edgeFloor;\n if (_e201 > ((_e202 * 8f) + _e204)) {\n let _e207 = p;\n let _e208 = up;\n dpdy_ = (_e207 - _e208);\n } else {\n let _e210 = upGap;\n let _e211 = downGap;\n let _e213 = edgeFloor;\n if (_e210 > ((_e211 * 8f) + _e213)) {\n let _e216 = down;\n let _e217 = p;\n dpdy_ = (_e216 - _e217);\n }\n }\n let _e219 = dpdx_;\n let _e220 = dpdy_;\n n = normalize(cross(_e219, _e220));\n let _e223 = n;\n let _e224 = p;\n if (dot(_e223, _e224) > 0f) {\n let _e227 = n;\n n = -(_e227);\n }\n let _e229 = p;\n toEye = normalize(-(_e229));\n let _e233 = unnamed.uRadius;\n let _e235 = unnamed.uProjScale;\n let _e239 = p[2u];\n reach = min((((_e235 * _e233) * 0.5f) / vec2(max(-(_e239), 0.001f))), vec2<f32>(0.06f, 0.06f));\n let _e246 = gl_FragCoord_1[0u];\n let _e252 = gl_FragCoord_1[1u];\n tile = ((_e246 - (floor((_e246 / 4f)) * 4f)) + (4f * (_e252 - (floor((_e252 / 4f)) * 4f))));\n let _e259 = tile;\n turn = (_e259 * 0.098174766f);\n let _e261 = tile;\n stagger = fract((_e261 * 0.618034f));\n let _e264 = stepX;\n let _e266 = stepY;\n pixel = vec2<f32>(length(_e264), length(_e266));\n visible = 0f;\n slice = 0i;\n loop {\n let _e269 = slice;\n if (_e269 < 2i) {\n let _e271 = turn;\n let _e272 = slice;\n angle = (_e271 + (f32(_e272) * 1.5707964f));\n let _e276 = angle;\n let _e279 = pixel[0u];\n let _e282 = pixel[1u];\n let _e284 = angle;\n screen = vec2<f32>(((cos(_e276) * _e279) / _e282), sin(_e284));\n let _e287 = vUv_1;\n let _e288 = screen;\n param_10 = (_e287 + (_e288 * 0.001f));\n let _e291 = depth_1;\n param_11 = _e291;\n let _e292 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_10), (&param_11));\n let _e293 = p;\n along = normalize((_e292 - _e293));\n let _e296 = along;\n let _e297 = toEye;\n let _e298 = along;\n let _e299 = toEye;\n across = normalize((_e296 - (_e297 * dot(_e298, _e299))));\n let _e304 = across;\n let _e305 = toEye;\n axis = cross(_e304, _e305);\n let _e307 = n;\n let _e308 = axis;\n let _e309 = n;\n let _e310 = axis;\n projected = (_e307 - (_e308 * dot(_e309, _e310)));\n let _e314 = projected;\n projectedLength = length(_e314);\n let _e316 = projectedLength;\n if (_e316 < 0.0001f) {\n continue;\n }\n let _e318 = projected;\n let _e319 = across;\n let _e321 = projected;\n let _e322 = toEye;\n normalAngle = atan2(dot(_e318, _e319), dot(_e321, _e322));\n horizon0_ = -1f;\n horizon1_ = -1f;\n k = 0i;\n loop {\n let _e325 = k;\n if (_e325 < 6i) {\n let _e327 = k;\n let _e329 = stagger;\n t = ((f32(_e327) + _e329) / 6f);\n let _e332 = screen;\n let _e334 = reach[1u];\n let _e336 = t;\n let _e337 = t;\n stride = ((_e332 * _e334) * ((_e336 * _e337) + 0.013888889f));\n side = 0i;\n loop {\n let _e341 = side;\n if (_e341 < 2i) {\n let _e343 = side;\n if (_e343 == 0i) {\n let _e345 = vUv_1;\n let _e346 = stride;\n local = (_e345 - _e346);\n } else {\n let _e348 = vUv_1;\n let _e349 = stride;\n local = (_e348 + _e349);\n }\n let _e351 = local;\n uv_1 = _e351;\n let _e352 = uv_1;\n let _e353 = textureSampleLevel(uDepth_t, uDepth_s, _e352, 0f);\n sampled = _e353.x;\n let _e355 = sampled;\n if (_e355 <= 0f) {\n continue;\n }\n let _e357 = uv_1;\n param_12 = _e357;\n let _e358 = sampled;\n param_13 = _e358;\n let _e359 = viewPosition_u0028_vf2_u003b_f1_u003b((&param_12), (&param_13));\n let _e360 = p;\n v = (_e359 - _e360);\n let _e362 = v;\n let _e363 = v;\n distance2_ = dot(_e362, _e363);\n let _e365 = distance2_;\n if (_e365 < 0.00000001f) {\n continue;\n }\n let _e367 = v;\n let _e368 = toEye;\n let _e370 = distance2_;\n cosine = (dot(_e367, _e368) * inverseSqrt(_e370));\n let _e373 = distance2_;\n let _e375 = unnamed.uRadius;\n let _e377 = unnamed.uRadius;\n fade = clamp((1f - (_e373 / (_e375 * _e377))), 0f, 1f);\n let _e382 = cosine;\n let _e383 = fade;\n cosine = mix(-1f, _e382, _e383);\n let _e385 = side;\n if (_e385 == 0i) {\n let _e387 = cosine;\n let _e388 = horizon0_;\n if (_e387 > _e388) {\n let _e390 = cosine;\n local_1 = _e390;\n } else {\n let _e391 = horizon0_;\n let _e392 = cosine;\n local_1 = mix(_e391, _e392, 0.2f);\n }\n let _e394 = local_1;\n horizon0_ = _e394;\n } else {\n let _e395 = cosine;\n let _e396 = horizon1_;\n if (_e395 > _e396) {\n let _e398 = cosine;\n local_2 = _e398;\n } else {\n let _e399 = horizon1_;\n let _e400 = cosine;\n local_2 = mix(_e399, _e400, 0.2f);\n }\n let _e402 = local_2;\n horizon1_ = _e402;\n }\n continue;\n } else {\n break;\n }\n continuing {\n let _e403 = side;\n side = (_e403 + 1i);\n }\n }\n continue;\n } else {\n break;\n }\n continuing {\n let _e405 = k;\n k = (_e405 + 1i);\n }\n }\n let _e407 = horizon0_;\n let _e411 = normalAngle;\n h0_1 = max(-(acos(clamp(_e407, -1f, 1f))), (_e411 - 1.5707963f));\n let _e414 = horizon1_;\n let _e417 = normalAngle;\n h1_1 = min(acos(clamp(_e414, -1f, 1f)), (_e417 + 1.5707963f));\n let _e420 = projectedLength;\n let _e421 = h0_1;\n param_14 = _e421;\n let _e422 = h1_1;\n param_15 = _e422;\n let _e423 = normalAngle;\n param_16 = _e423;\n let _e424 = gtaoArc_u0028_f1_u003b_f1_u003b_f1_u003b((&param_14), (&param_15), (&param_16));\n let _e426 = visible;\n visible = (_e426 + (_e420 * _e424));\n continue;\n } else {\n break;\n }\n continuing {\n let _e428 = slice;\n slice = (_e428 + 1i);\n }\n }\n let _e430 = visible;\n fragColor = clamp(((_e430 / 2f) * 0.5f), 0f, 1f);\n return;\n}\n\n@fragment \nfn main(@location(0) vUv: vec2<f32>, @builtin(position) gl_FragCoord: vec4<f32>) -> @location(0) f32 {\n vUv_1 = vUv;\n gl_FragCoord_1 = gl_FragCoord;\n main_1();\n let _e5 = fragColor;\n return _e5;\n}\n";
11
11
 
12
12
  /**
13
13
  * What the transform assigned, so the renderer binds the same numbers.
@@ -17,7 +17,7 @@ export const AO_FRAG_WGSL = "struct Uniforms {\n uProjScale: vec2<f32>,\n
17
17
  export const AMBIENTOCCLUSION_BINDINGS = {
18
18
  "AO_BLUR_FRAG": {
19
19
  "uniforms": 1,
20
- "uniformSize": 32,
20
+ "uniformSize": 48,
21
21
  "fields": {
22
22
  "uStep": {
23
23
  "offset": 0,
@@ -28,6 +28,11 @@ export const AMBIENTOCCLUSION_BINDINGS = {
28
28
  "offset": 16,
29
29
  "size": 16,
30
30
  "type": "vec4"
31
+ },
32
+ "uAoScale": {
33
+ "offset": 32,
34
+ "size": 4,
35
+ "type": "float"
31
36
  }
32
37
  },
33
38
  "textures": {
@@ -5,8 +5,14 @@
5
5
  * the next generation, and `npm run wgsl:check` fails the build when this is stale.
6
6
  */
7
7
 
8
+ export const DEPTH_CUTOUT_FRAG_WGSL = "struct Uniforms {\n uPeelShadowLayer: i32,\n}\n\n@group(0) @binding(34) \nvar uCutoutMap_t: texture_2d<f32>;\n@group(0) @binding(35) \nvar uCutoutMap_s: sampler;\nvar<private> vUv_1: vec2<f32>;\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vLightPosition_1: vec4<f32>;\n@group(0) @binding(32) \nvar uPreviousShadowMap_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uPreviousShadowMap_s: sampler;\nvar<private> gl_FragCoord_1: vec4<f32>;\nvar<private> vAlphaCutout_1: f32;\n\nfn cutoutAlpha_u0028_f1_u003b_vf2_u003b(alpha: ptr<function, f32>, texels: ptr<function, vec2<f32>>) -> f32 {\n var dx: vec2<f32>;\n var dy: vec2<f32>;\n var level: f32;\n\n let _e23 = (*texels);\n let _e24 = dpdx(_e23);\n dx = _e24;\n let _e25 = (*texels);\n let _e26 = dpdy(_e25);\n dy = _e26;\n let _e27 = dx;\n let _e28 = dx;\n let _e30 = dy;\n let _e31 = dy;\n level = max(0f, (0.5f * log2(max(dot(_e27, _e28), dot(_e30, _e31)))));\n let _e37 = (*alpha);\n let _e38 = level;\n return (_e37 * (1f + (_e38 * 0.25f)));\n}\n\nfn main_1() {\n var alpha_1: f32;\n var param: f32;\n var param_1: vec2<f32>;\n var p: vec3<f32>;\n var uv: vec2<f32>;\n var previousDepth: f32;\n\n let _e24 = vUv_1;\n let _e25 = textureSample(uCutoutMap_t, uCutoutMap_s, _e24);\n let _e26 = vUv_1;\n let _e27 = textureDimensions(uCutoutMap_t, 0i);\n param = _e25.w;\n param_1 = (_e26 * vec2<f32>(vec2<i32>(_e27)));\n let _e32 = cutoutAlpha_u0028_f1_u003b_vf2_u003b((&param), (&param_1));\n alpha_1 = _e32;\n let _e34 = unnamed.uPeelShadowLayer;\n if (_e34 != 0i) {\n let _e36 = vLightPosition_1;\n let _e39 = vLightPosition_1[3u];\n p = (_e36.xyz / vec3(_e39));\n let _e42 = p;\n uv = ((_e42.xy * 0.5f) + vec2(0.5f));\n let _e47 = uv;\n let _e48 = textureSampleLevel(uPreviousShadowMap_t, uPreviousShadowMap_s, _e47, 0f);\n previousDepth = _e48.x;\n let _e51 = gl_FragCoord_1[2u];\n let _e52 = previousDepth;\n if (_e51 <= (_e52 + 0.00001f)) {\n discard;\n }\n }\n let _e55 = alpha_1;\n let _e56 = vAlphaCutout_1;\n if (_e55 < _e56) {\n discard;\n }\n return;\n}\n\n@fragment \nfn main(@location(1) vUv: vec2<f32>, @location(0) vLightPosition: vec4<f32>, @builtin(position) gl_FragCoord: vec4<f32>, @location(2) @interpolate(flat) vAlphaCutout: f32) {\n vUv_1 = vUv;\n vLightPosition_1 = vLightPosition;\n gl_FragCoord_1 = gl_FragCoord;\n vAlphaCutout_1 = vAlphaCutout;\n main_1();\n}\n";
9
+
10
+ export const DEPTH_CUTOUT_VERT_WGSL = "struct Uniforms {\n uLightViewProj: mat4x4<f32>,\n uModel: mat4x4<f32>,\n uWindDirection: vec2<f32>,\n uWindSpeed: f32,\n uWindGust: f32,\n uWindTime: f32,\n uWindSpatialPhase: vec2<f32>,\n uUvScale: vec2<f32>,\n uAlphaCutout: f32,\n}\n\nstruct gl_PerVertex {\n @builtin(position) gl_Position: vec4<f32>,\n gl_PointSize: f32,\n}\n\nstruct VertexOutput {\n @location(0) member: vec4<f32>,\n @builtin(position) gl_Position: vec4<f32>,\n @location(1) member_1: vec2<f32>,\n @location(2) @interpolate(flat) member_2: f32,\n}\n\n@group(0) @binding(0) \nvar<uniform> unnamed: Uniforms;\nvar<private> aPosition_1: vec3<f32>;\nvar<private> aChannel_1: vec4<f32>;\nvar<private> vLightPosition: vec4<f32>;\nvar<private> unnamed_1: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);\nvar<private> vUv: vec2<f32>;\nvar<private> aUv_1: vec2<f32>;\nvar<private> vAlphaCutout: f32;\n\nfn channelBend_u0028_vf3_u003b_f1_u003b(worldPos: ptr<function, vec3<f32>>, sway: ptr<function, f32>) -> vec3<f32> {\n var phase: f32;\n var bend: f32;\n\n let _e27 = (*sway);\n if (_e27 <= 0f) {\n let _e29 = (*worldPos);\n return _e29;\n }\n let _e30 = (*worldPos);\n let _e33 = unnamed.uWindSpatialPhase;\n let _e36 = unnamed.uWindTime;\n phase = (dot(_e30.xz, _e33) + _e36);\n let _e39 = unnamed.uWindSpeed;\n let _e41 = unnamed.uWindGust;\n let _e43 = phase;\n let _e46 = (*sway);\n bend = (((_e39 + _e41) * sin(_e43)) * _e46);\n let _e49 = (*worldPos)[0u];\n let _e52 = unnamed.uWindDirection[0u];\n let _e53 = bend;\n let _e57 = (*worldPos)[1u];\n let _e59 = (*worldPos)[2u];\n let _e62 = unnamed.uWindDirection[1u];\n let _e63 = bend;\n return vec3<f32>((_e49 + (_e52 * _e53)), _e57, (_e59 + (_e62 * _e63)));\n}\n\nfn main_1() {\n var local: vec4<f32>;\n var model: mat4x4<f32>;\n var world: vec4<f32>;\n var bent: vec3<f32>;\n var param: vec3<f32>;\n var param_1: f32;\n\n let _e29 = aPosition_1;\n local = vec4<f32>(_e29.x, _e29.y, _e29.z, 1f);\n let _e35 = unnamed.uModel;\n model = _e35;\n let _e36 = model;\n let _e37 = local;\n world = (_e36 * _e37);\n let _e39 = world;\n param = _e39.xyz;\n let _e42 = aChannel_1[0u];\n param_1 = _e42;\n let _e43 = channelBend_u0028_vf3_u003b_f1_u003b((&param), (&param_1));\n bent = _e43;\n let _e45 = unnamed.uLightViewProj;\n let _e46 = bent;\n let _e48 = world[3u];\n vLightPosition = (_e45 * vec4<f32>(_e46.x, _e46.y, _e46.z, _e48));\n let _e54 = vLightPosition;\n unnamed_1.gl_Position = _e54;\n let _e56 = aUv_1;\n let _e58 = unnamed.uUvScale;\n vUv = (_e56 * _e58);\n let _e61 = unnamed.uAlphaCutout;\n vAlphaCutout = _e61;\n return;\n}\n\n@vertex \nfn main(@location(0) aPosition: vec3<f32>, @location(13) aChannel: vec4<f32>, @location(5) aUv: vec2<f32>) -> VertexOutput {\n aPosition_1 = aPosition;\n aChannel_1 = aChannel;\n aUv_1 = aUv;\n main_1();\n let _e12 = unnamed_1.gl_Position.y;\n unnamed_1.gl_Position.y = -(_e12);\n let _e14 = vLightPosition;\n let _e15 = unnamed_1.gl_Position;\n let _e16 = vUv;\n let _e17 = vAlphaCutout;\n return VertexOutput(_e14, _e15, _e16, _e17);\n}\n";
11
+
8
12
  export const DEPTH_FRAG_WGSL = "struct Uniforms {\n uPeelShadowLayer: i32,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vLightPosition_1: vec4<f32>;\n@group(0) @binding(32) \nvar uPreviousShadowMap_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uPreviousShadowMap_s: sampler;\nvar<private> gl_FragCoord_1: vec4<f32>;\n\nfn main_1() {\n var p: vec3<f32>;\n var uv: vec2<f32>;\n var previousDepth: f32;\n\n let _e15 = unnamed.uPeelShadowLayer;\n if (_e15 != 0i) {\n let _e17 = vLightPosition_1;\n let _e20 = vLightPosition_1[3u];\n p = (_e17.xyz / vec3(_e20));\n let _e23 = p;\n uv = ((_e23.xy * 0.5f) + vec2(0.5f));\n let _e28 = uv;\n let _e29 = textureSample(uPreviousShadowMap_t, uPreviousShadowMap_s, _e28);\n previousDepth = _e29.x;\n let _e32 = gl_FragCoord_1[2u];\n let _e33 = previousDepth;\n if (_e32 <= (_e33 + 0.00001f)) {\n discard;\n }\n }\n return;\n}\n\n@fragment \nfn main(@location(0) vLightPosition: vec4<f32>, @builtin(position) gl_FragCoord: vec4<f32>) {\n vLightPosition_1 = vLightPosition;\n gl_FragCoord_1 = gl_FragCoord;\n main_1();\n}\n";
9
13
 
14
+ export const DEPTH_INSTANCED_CUTOUT_VERT_WGSL = "struct Uniforms {\n uLightViewProj: mat4x4<f32>,\n uUvScale: vec2<f32>,\n uAlphaCutout: f32,\n}\n\nstruct gl_PerVertex {\n @builtin(position) gl_Position: vec4<f32>,\n gl_PointSize: f32,\n}\n\nstruct VertexOutput {\n @location(0) member: vec4<f32>,\n @builtin(position) gl_Position: vec4<f32>,\n @location(1) member_1: vec2<f32>,\n @location(2) @interpolate(flat) member_2: f32,\n}\n\nvar<private> aPosition_1: vec3<f32>;\nvar<private> aInstanceModel0_1: vec4<f32>;\nvar<private> aInstanceModel1_1: vec4<f32>;\nvar<private> aInstanceModel2_1: vec4<f32>;\nvar<private> aInstanceModel3_1: vec4<f32>;\nvar<private> vLightPosition: vec4<f32>;\n@group(0) @binding(0) \nvar<uniform> unnamed: Uniforms;\nvar<private> unnamed_1: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);\nvar<private> vUv: vec2<f32>;\nvar<private> aUv_1: vec2<f32>;\nvar<private> vAlphaCutout: f32;\n\nfn main_1() {\n var local: vec4<f32>;\n var model: mat4x4<f32>;\n var world: vec4<f32>;\n var bent: vec3<f32>;\n\n let _e21 = aPosition_1;\n local = vec4<f32>(_e21.x, _e21.y, _e21.z, 1f);\n let _e26 = aInstanceModel0_1;\n let _e27 = aInstanceModel1_1;\n let _e28 = aInstanceModel2_1;\n let _e29 = aInstanceModel3_1;\n model = mat4x4<f32>(vec4<f32>(_e26.x, _e26.y, _e26.z, _e26.w), vec4<f32>(_e27.x, _e27.y, _e27.z, _e27.w), vec4<f32>(_e28.x, _e28.y, _e28.z, _e28.w), vec4<f32>(_e29.x, _e29.y, _e29.z, _e29.w));\n let _e51 = model;\n let _e52 = local;\n world = (_e51 * _e52);\n let _e54 = world;\n bent = _e54.xyz;\n let _e57 = unnamed.uLightViewProj;\n let _e58 = bent;\n let _e60 = world[3u];\n vLightPosition = (_e57 * vec4<f32>(_e58.x, _e58.y, _e58.z, _e60));\n let _e66 = vLightPosition;\n unnamed_1.gl_Position = _e66;\n let _e68 = aUv_1;\n let _e70 = unnamed.uUvScale;\n vUv = (_e68 * _e70);\n let _e73 = unnamed.uAlphaCutout;\n vAlphaCutout = _e73;\n return;\n}\n\n@vertex \nfn main(@location(0) aPosition: vec3<f32>, @location(11) aInstanceModel0_: vec4<f32>, @location(12) aInstanceModel1_: vec4<f32>, @location(13) aInstanceModel2_: vec4<f32>, @location(14) aInstanceModel3_: vec4<f32>, @location(5) aUv: vec2<f32>) -> VertexOutput {\n aPosition_1 = aPosition;\n aInstanceModel0_1 = aInstanceModel0_;\n aInstanceModel1_1 = aInstanceModel1_;\n aInstanceModel2_1 = aInstanceModel2_;\n aInstanceModel3_1 = aInstanceModel3_;\n aUv_1 = aUv;\n main_1();\n let _e18 = unnamed_1.gl_Position.y;\n unnamed_1.gl_Position.y = -(_e18);\n let _e20 = vLightPosition;\n let _e21 = unnamed_1.gl_Position;\n let _e22 = vUv;\n let _e23 = vAlphaCutout;\n return VertexOutput(_e20, _e21, _e22, _e23);\n}\n";
15
+
10
16
  export const DEPTH_INSTANCED_VERT_WGSL = "struct Uniforms {\n uLightViewProj: mat4x4<f32>,\n}\n\nstruct gl_PerVertex {\n @builtin(position) gl_Position: vec4<f32>,\n gl_PointSize: f32,\n}\n\nstruct VertexOutput {\n @location(0) member: vec4<f32>,\n @builtin(position) gl_Position: vec4<f32>,\n}\n\nvar<private> aPosition_1: vec3<f32>;\nvar<private> aInstanceModel0_1: vec4<f32>;\nvar<private> aInstanceModel1_1: vec4<f32>;\nvar<private> aInstanceModel2_1: vec4<f32>;\nvar<private> aInstanceModel3_1: vec4<f32>;\nvar<private> vLightPosition: vec4<f32>;\n@group(0) @binding(0) \nvar<uniform> unnamed: Uniforms;\nvar<private> unnamed_1: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);\n\nfn main_1() {\n var local: vec4<f32>;\n var model: mat4x4<f32>;\n var world: vec4<f32>;\n var bent: vec3<f32>;\n\n let _e16 = aPosition_1;\n local = vec4<f32>(_e16.x, _e16.y, _e16.z, 1f);\n let _e21 = aInstanceModel0_1;\n let _e22 = aInstanceModel1_1;\n let _e23 = aInstanceModel2_1;\n let _e24 = aInstanceModel3_1;\n model = mat4x4<f32>(vec4<f32>(_e21.x, _e21.y, _e21.z, _e21.w), vec4<f32>(_e22.x, _e22.y, _e22.z, _e22.w), vec4<f32>(_e23.x, _e23.y, _e23.z, _e23.w), vec4<f32>(_e24.x, _e24.y, _e24.z, _e24.w));\n let _e46 = model;\n let _e47 = local;\n world = (_e46 * _e47);\n let _e49 = world;\n bent = _e49.xyz;\n let _e52 = unnamed.uLightViewProj;\n let _e53 = bent;\n let _e55 = world[3u];\n vLightPosition = (_e52 * vec4<f32>(_e53.x, _e53.y, _e53.z, _e55));\n let _e61 = vLightPosition;\n unnamed_1.gl_Position = _e61;\n return;\n}\n\n@vertex \nfn main(@location(0) aPosition: vec3<f32>, @location(11) aInstanceModel0_: vec4<f32>, @location(12) aInstanceModel1_: vec4<f32>, @location(13) aInstanceModel2_: vec4<f32>, @location(14) aInstanceModel3_: vec4<f32>) -> VertexOutput {\n aPosition_1 = aPosition;\n aInstanceModel0_1 = aInstanceModel0_;\n aInstanceModel1_1 = aInstanceModel1_;\n aInstanceModel2_1 = aInstanceModel2_;\n aInstanceModel3_1 = aInstanceModel3_;\n main_1();\n let _e14 = unnamed_1.gl_Position.y;\n unnamed_1.gl_Position.y = -(_e14);\n let _e16 = vLightPosition;\n let _e17 = unnamed_1.gl_Position;\n return VertexOutput(_e16, _e17);\n}\n";
11
17
 
12
18
  export const DEPTH_SKINNED_VERT_WGSL = "struct Uniforms {\n uLightViewProj: mat4x4<f32>,\n uModel: mat4x4<f32>,\n uWindDirection: vec2<f32>,\n uWindSpeed: f32,\n uWindGust: f32,\n uWindTime: f32,\n uWindSpatialPhase: vec2<f32>,\n}\n\nstruct gl_PerVertex {\n @builtin(position) gl_Position: vec4<f32>,\n gl_PointSize: f32,\n}\n\nstruct VertexOutput {\n @location(0) member: vec4<f32>,\n @builtin(position) gl_Position: vec4<f32>,\n}\n\n@group(0) @binding(16) \nvar uJointPalette_t: texture_2d<f32>;\nvar<private> aJoints_1: vec4<f32>;\nvar<private> aWeights_1: vec4<f32>;\n@group(0) @binding(0) \nvar<uniform> unnamed: Uniforms;\nvar<private> aPosition_1: vec3<f32>;\nvar<private> aChannel_1: vec4<f32>;\nvar<private> vLightPosition: vec4<f32>;\nvar<private> unnamed_1: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);\n@group(0) @binding(17) \nvar uJointPalette_s: sampler;\n\nfn channelBend_u0028_vf3_u003b_f1_u003b(worldPos: ptr<function, vec3<f32>>, sway: ptr<function, f32>) -> vec3<f32> {\n var phase: f32;\n var bend: f32;\n\n let _e26 = (*sway);\n if (_e26 <= 0f) {\n let _e28 = (*worldPos);\n return _e28;\n }\n let _e29 = (*worldPos);\n let _e32 = unnamed.uWindSpatialPhase;\n let _e35 = unnamed.uWindTime;\n phase = (dot(_e29.xz, _e32) + _e35);\n let _e38 = unnamed.uWindSpeed;\n let _e40 = unnamed.uWindGust;\n let _e42 = phase;\n let _e45 = (*sway);\n bend = (((_e38 + _e40) * sin(_e42)) * _e45);\n let _e48 = (*worldPos)[0u];\n let _e51 = unnamed.uWindDirection[0u];\n let _e52 = bend;\n let _e56 = (*worldPos)[1u];\n let _e58 = (*worldPos)[2u];\n let _e61 = unnamed.uWindDirection[1u];\n let _e62 = bend;\n return vec3<f32>((_e48 + (_e51 * _e52)), _e56, (_e58 + (_e61 * _e62)));\n}\n\nfn jointMatrix_u0028_i1_u003b(index: ptr<function, i32>) -> mat4x4<f32> {\n var x: i32;\n\n let _e24 = (*index);\n x = (_e24 * 4i);\n let _e26 = x;\n let _e28 = textureLoad(uJointPalette_t, vec2<i32>(_e26, 0i), 0i);\n let _e29 = x;\n let _e32 = textureLoad(uJointPalette_t, vec2<i32>((_e29 + 1i), 0i), 0i);\n let _e33 = x;\n let _e36 = textureLoad(uJointPalette_t, vec2<i32>((_e33 + 2i), 0i), 0i);\n let _e37 = x;\n let _e40 = textureLoad(uJointPalette_t, vec2<i32>((_e37 + 3i), 0i), 0i);\n return mat4x4<f32>(vec4<f32>(_e28.x, _e28.y, _e28.z, _e28.w), vec4<f32>(_e32.x, _e32.y, _e32.z, _e32.w), vec4<f32>(_e36.x, _e36.y, _e36.z, _e36.w), vec4<f32>(_e40.x, _e40.y, _e40.z, _e40.w));\n}\n\nfn skinMatrix_u0028_() -> mat4x4<f32> {\n var param: i32;\n var param_1: i32;\n var param_2: i32;\n var param_3: i32;\n\n let _e27 = aJoints_1[0u];\n param = i32(_e27);\n let _e29 = jointMatrix_u0028_i1_u003b((&param));\n let _e31 = aWeights_1[0u];\n let _e32 = (_e29 * _e31);\n let _e34 = aJoints_1[1u];\n param_1 = i32(_e34);\n let _e36 = jointMatrix_u0028_i1_u003b((&param_1));\n let _e38 = aWeights_1[1u];\n let _e39 = (_e36 * _e38);\n let _e52 = mat4x4<f32>((_e32[0] + _e39[0]), (_e32[1] + _e39[1]), (_e32[2] + _e39[2]), (_e32[3] + _e39[3]));\n let _e54 = aJoints_1[2u];\n param_2 = i32(_e54);\n let _e56 = jointMatrix_u0028_i1_u003b((&param_2));\n let _e58 = aWeights_1[2u];\n let _e59 = (_e56 * _e58);\n let _e72 = mat4x4<f32>((_e52[0] + _e59[0]), (_e52[1] + _e59[1]), (_e52[2] + _e59[2]), (_e52[3] + _e59[3]));\n let _e74 = aJoints_1[3u];\n param_3 = i32(_e74);\n let _e76 = jointMatrix_u0028_i1_u003b((&param_3));\n let _e78 = aWeights_1[3u];\n let _e79 = (_e76 * _e78);\n return mat4x4<f32>((_e72[0] + _e79[0]), (_e72[1] + _e79[1]), (_e72[2] + _e79[2]), (_e72[3] + _e79[3]));\n}\n\nfn main_1() {\n var local: vec4<f32>;\n var model: mat4x4<f32>;\n var world: vec4<f32>;\n var bent: vec3<f32>;\n var param_4: vec3<f32>;\n var param_5: f32;\n\n let _e28 = skinMatrix_u0028_();\n let _e29 = aPosition_1;\n local = (_e28 * vec4<f32>(_e29.x, _e29.y, _e29.z, 1f));\n let _e36 = unnamed.uModel;\n model = _e36;\n let _e37 = model;\n let _e38 = local;\n world = (_e37 * _e38);\n let _e40 = world;\n param_4 = _e40.xyz;\n let _e43 = aChannel_1[0u];\n param_5 = _e43;\n let _e44 = channelBend_u0028_vf3_u003b_f1_u003b((&param_4), (&param_5));\n bent = _e44;\n let _e46 = unnamed.uLightViewProj;\n let _e47 = bent;\n let _e49 = world[3u];\n vLightPosition = (_e46 * vec4<f32>(_e47.x, _e47.y, _e47.z, _e49));\n let _e55 = vLightPosition;\n unnamed_1.gl_Position = _e55;\n return;\n}\n\n@vertex \nfn main(@location(11) aJoints: vec4<f32>, @location(12) aWeights: vec4<f32>, @location(0) aPosition: vec3<f32>, @location(13) aChannel: vec4<f32>) -> VertexOutput {\n aJoints_1 = aJoints;\n aWeights_1 = aWeights;\n aPosition_1 = aPosition;\n aChannel_1 = aChannel;\n main_1();\n let _e12 = unnamed_1.gl_Position.y;\n unnamed_1.gl_Position.y = -(_e12);\n let _e14 = vLightPosition;\n let _e15 = unnamed_1.gl_Position;\n return VertexOutput(_e14, _e15);\n}\n";
@@ -19,6 +25,81 @@ export const DEPTH_VERT_WGSL = "struct Uniforms {\n uLightViewProj: mat4x4<f3
19
25
  * A permuted shader has one entry per variant, keyed as `FLAT_FRAG_WGSL` is.
20
26
  */
21
27
  export const DEPTH_BINDINGS = {
28
+ "DEPTH_CUTOUT_FRAG": {
29
+ "uniforms": 1,
30
+ "uniformSize": 16,
31
+ "fields": {
32
+ "uPeelShadowLayer": {
33
+ "offset": 0,
34
+ "size": 4,
35
+ "type": "int"
36
+ }
37
+ },
38
+ "textures": {
39
+ "uPreviousShadowMap": {
40
+ "texture": 32,
41
+ "sampler": 33,
42
+ "type": "sampler2D"
43
+ },
44
+ "uCutoutMap": {
45
+ "texture": 34,
46
+ "sampler": 35,
47
+ "type": "sampler2D"
48
+ }
49
+ }
50
+ },
51
+ "DEPTH_CUTOUT_VERT": {
52
+ "uniforms": 0,
53
+ "uniformSize": 176,
54
+ "fields": {
55
+ "uLightViewProj": {
56
+ "offset": 0,
57
+ "size": 64,
58
+ "type": "mat4"
59
+ },
60
+ "uModel": {
61
+ "offset": 64,
62
+ "size": 64,
63
+ "type": "mat4"
64
+ },
65
+ "uWindDirection": {
66
+ "offset": 128,
67
+ "size": 8,
68
+ "type": "vec2"
69
+ },
70
+ "uWindSpeed": {
71
+ "offset": 136,
72
+ "size": 4,
73
+ "type": "float"
74
+ },
75
+ "uWindGust": {
76
+ "offset": 140,
77
+ "size": 4,
78
+ "type": "float"
79
+ },
80
+ "uWindTime": {
81
+ "offset": 144,
82
+ "size": 4,
83
+ "type": "float"
84
+ },
85
+ "uWindSpatialPhase": {
86
+ "offset": 152,
87
+ "size": 8,
88
+ "type": "vec2"
89
+ },
90
+ "uUvScale": {
91
+ "offset": 160,
92
+ "size": 8,
93
+ "type": "vec2"
94
+ },
95
+ "uAlphaCutout": {
96
+ "offset": 168,
97
+ "size": 4,
98
+ "type": "float"
99
+ }
100
+ },
101
+ "textures": {}
102
+ },
22
103
  "DEPTH_FRAG": {
23
104
  "uniforms": 1,
24
105
  "uniformSize": 16,
@@ -37,6 +118,28 @@ export const DEPTH_BINDINGS = {
37
118
  }
38
119
  }
39
120
  },
121
+ "DEPTH_INSTANCED_CUTOUT_VERT": {
122
+ "uniforms": 0,
123
+ "uniformSize": 80,
124
+ "fields": {
125
+ "uLightViewProj": {
126
+ "offset": 0,
127
+ "size": 64,
128
+ "type": "mat4"
129
+ },
130
+ "uUvScale": {
131
+ "offset": 64,
132
+ "size": 8,
133
+ "type": "vec2"
134
+ },
135
+ "uAlphaCutout": {
136
+ "offset": 72,
137
+ "size": 4,
138
+ "type": "float"
139
+ }
140
+ },
141
+ "textures": {}
142
+ },
40
143
  "DEPTH_INSTANCED_VERT": {
41
144
  "uniforms": 0,
42
145
  "uniformSize": 64,
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Generated from ../exposure.ts by `npm run wgsl`. Do not edit.
3
+ *
4
+ * The GLSL beside this file is the source of truth. A hand edit here is discarded by
5
+ * the next generation, and `npm run wgsl:check` fails the build when this is stale.
6
+ */
7
+
8
+ export const EXPOSURE_ADAPT_FRAG_WGSL = "struct Uniforms {\n uBlend: f32,\n}\n\n@group(0) @binding(32) \nvar uMeter_t: texture_2d<f32>;\n@group(0) @binding(34) \nvar uHeld_t: texture_2d<f32>;\nvar<private> fragColor: f32;\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\n@group(0) @binding(33) \nvar uMeter_s: sampler;\n@group(0) @binding(35) \nvar uHeld_s: sampler;\n\nfn main_1() {\n var sum: f32;\n var y: i32;\n var x: i32;\n var measured: f32;\n var held: f32;\n\n sum = 0f;\n y = 0i;\n loop {\n let _e18 = y;\n if (_e18 < 32i) {\n x = 0i;\n loop {\n let _e20 = x;\n if (_e20 < 32i) {\n let _e22 = x;\n let _e23 = y;\n let _e25 = textureLoad(uMeter_t, vec2<i32>(_e22, _e23), 0i);\n let _e27 = sum;\n sum = (_e27 + _e25.x);\n continue;\n } else {\n break;\n }\n continuing {\n let _e29 = x;\n x = (_e29 + 1i);\n }\n }\n continue;\n } else {\n break;\n }\n continuing {\n let _e31 = y;\n y = (_e31 + 1i);\n }\n }\n let _e33 = sum;\n measured = (_e33 / 1024f);\n let _e35 = textureLoad(uHeld_t, vec2<i32>(0i, 0i), 0i);\n held = _e35.x;\n let _e37 = held;\n let _e38 = measured;\n let _e40 = unnamed.uBlend;\n fragColor = mix(_e37, _e38, _e40);\n return;\n}\n\n@fragment \nfn main() -> @location(0) f32 {\n main_1();\n let _e1 = fragColor;\n return _e1;\n}\n";
9
+
10
+ export const EXPOSURE_METER_FRAG_WGSL = "var<private> vUv_1: vec2<f32>;\n@group(0) @binding(32) \nvar uScene_t: texture_2d<f32>;\n@group(0) @binding(33) \nvar uScene_s: sampler;\nvar<private> fragColor: f32;\n\nfn main_1() {\n var corner: vec2<f32>;\n var sum: f32;\n var y: i32;\n var x: i32;\n var uv: vec2<f32>;\n var c: vec3<f32>;\n var luma: f32;\n\n let _e27 = vUv_1;\n corner = (_e27 - vec2<f32>(0.015625f, 0.015625f));\n sum = 0f;\n y = 0i;\n loop {\n let _e29 = y;\n if (_e29 < 8i) {\n x = 0i;\n loop {\n let _e31 = x;\n if (_e31 < 8i) {\n let _e33 = corner;\n let _e34 = x;\n let _e36 = y;\n uv = (_e33 + ((vec2<f32>(f32(_e34), f32(_e36)) + vec2(0.5f)) / vec2(256f)));\n let _e44 = uv;\n let _e45 = textureSampleLevel(uScene_t, uScene_s, _e44, 0f);\n c = _e45.xyz;\n let _e47 = c;\n luma = dot(_e47, vec3<f32>(0.2126f, 0.7152f, 0.0722f));\n let _e49 = luma;\n let _e53 = sum;\n sum = (_e53 + clamp(log2(max(_e49, 0.00000001f)), -12f, 8f));\n continue;\n } else {\n break;\n }\n continuing {\n let _e55 = x;\n x = (_e55 + 1i);\n }\n }\n continue;\n } else {\n break;\n }\n continuing {\n let _e57 = y;\n y = (_e57 + 1i);\n }\n }\n let _e59 = sum;\n fragColor = (_e59 / 64f);\n return;\n}\n\n@fragment \nfn main(@location(0) vUv: vec2<f32>) -> @location(0) f32 {\n vUv_1 = vUv;\n main_1();\n let _e3 = fragColor;\n return _e3;\n}\n";
11
+
12
+ /**
13
+ * What the transform assigned, so the renderer binds the same numbers.
14
+ *
15
+ * A permuted shader has one entry per variant, keyed as `FLAT_FRAG_WGSL` is.
16
+ */
17
+ export const EXPOSURE_BINDINGS = {
18
+ "EXPOSURE_ADAPT_FRAG": {
19
+ "uniforms": 1,
20
+ "uniformSize": 16,
21
+ "fields": {
22
+ "uBlend": {
23
+ "offset": 0,
24
+ "size": 4,
25
+ "type": "float"
26
+ }
27
+ },
28
+ "textures": {
29
+ "uMeter": {
30
+ "texture": 32,
31
+ "sampler": 33,
32
+ "type": "sampler2D"
33
+ },
34
+ "uHeld": {
35
+ "texture": 34,
36
+ "sampler": 35,
37
+ "type": "sampler2D"
38
+ }
39
+ }
40
+ },
41
+ "EXPOSURE_METER_FRAG": {
42
+ "uniforms": null,
43
+ "textures": {
44
+ "uScene": {
45
+ "texture": 32,
46
+ "sampler": 33,
47
+ "type": "sampler2D"
48
+ }
49
+ }
50
+ }
51
+ } as const;