@driftengine/core 4.4.2 → 4.5.0

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 (193) hide show
  1. package/CHANGELOG.json +46 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +5 -1
  4. package/dist/index.js +7 -0
  5. package/dist/render/backend/api.d.ts +17 -11
  6. package/dist/render/backend/webgl2/glassTintPrograms.d.ts +13 -0
  7. package/dist/render/backend/webgl2/glassTintPrograms.js +38 -0
  8. package/dist/render/backend/webgl2/renderer.d.ts +79 -8
  9. package/dist/render/backend/webgl2/renderer.js +360 -105
  10. package/dist/render/backend/webgpu/buffers.d.ts +19 -1
  11. package/dist/render/backend/webgpu/buffers.js +27 -1
  12. package/dist/render/backend/webgpu/depthPass.d.ts +1 -1
  13. package/dist/render/backend/webgpu/depthPass.js +2 -1
  14. package/dist/render/backend/webgpu/flatPass.d.ts +2 -0
  15. package/dist/render/backend/webgpu/flatPass.js +20 -1
  16. package/dist/render/backend/webgpu/glassTintPass.d.ts +28 -0
  17. package/dist/render/backend/webgpu/glassTintPass.js +205 -0
  18. package/dist/render/backend/webgpu/gpuDrivenPass.d.ts +60 -1
  19. package/dist/render/backend/webgpu/gpuDrivenPass.js +305 -5
  20. package/dist/render/backend/webgpu/instanced.d.ts +12 -1
  21. package/dist/render/backend/webgpu/instanced.js +20 -1
  22. package/dist/render/backend/webgpu/latePass.d.ts +26 -0
  23. package/dist/render/backend/webgpu/latePass.js +133 -0
  24. package/dist/render/backend/webgpu/lightVolumePass.js +5 -1
  25. package/dist/render/backend/webgpu/motionPass.d.ts +95 -0
  26. package/dist/render/backend/webgpu/motionPass.js +491 -0
  27. package/dist/render/backend/webgpu/pipelineCache.d.ts +10 -1
  28. package/dist/render/backend/webgpu/pipelineCache.js +11 -1
  29. package/dist/render/backend/webgpu/pointGlassTintPass.d.ts +32 -0
  30. package/dist/render/backend/webgpu/pointGlassTintPass.js +193 -0
  31. package/dist/render/backend/webgpu/pointShadowPass.d.ts +35 -6
  32. package/dist/render/backend/webgpu/pointShadowPass.js +105 -20
  33. package/dist/render/backend/webgpu/postPass.d.ts +2 -12
  34. package/dist/render/backend/webgpu/renderer.d.ts +171 -54
  35. package/dist/render/backend/webgpu/renderer.js +944 -390
  36. package/dist/render/backend/webgpu/scatterPass.js +2 -1
  37. package/dist/render/backend/webgpu/skinPaletteRing.d.ts +4 -0
  38. package/dist/render/backend/webgpu/skinPaletteRing.js +4 -0
  39. package/dist/render/backend/webgpu/snapshotMips.d.ts +29 -0
  40. package/dist/render/backend/webgpu/snapshotMips.js +52 -0
  41. package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +5 -0
  42. package/dist/render/backend/webgpu/surfaceTexturePass.js +1 -1
  43. package/dist/render/glass.d.ts +45 -0
  44. package/dist/render/glass.js +39 -0
  45. package/dist/render/glassCasters.d.ts +40 -0
  46. package/dist/render/glassCasters.js +84 -0
  47. package/dist/render/glassShadow.d.ts +78 -0
  48. package/dist/render/glassShadow.js +125 -0
  49. package/dist/render/globalMediumPass.d.ts +2 -3
  50. package/dist/render/globalMediumPass.js +2 -8
  51. package/dist/render/gpudriven/lit.d.ts +12 -0
  52. package/dist/render/gpudriven/lit.js +23 -0
  53. package/dist/render/gpudriven/materialTable.d.ts +15 -5
  54. package/dist/render/gpudriven/materialTable.js +26 -6
  55. package/dist/render/gpudriven/pipeline.d.ts +1 -1
  56. package/dist/render/gpudriven/pipeline.js +4 -3
  57. package/dist/render/gpudriven/sunGlass.d.ts +35 -0
  58. package/dist/render/gpudriven/sunGlass.js +89 -0
  59. package/dist/render/lightBudget.d.ts +17 -5
  60. package/dist/render/lightBudget.js +17 -5
  61. package/dist/render/pointGlassTint.d.ts +59 -0
  62. package/dist/render/pointGlassTint.js +198 -0
  63. package/dist/render/pointShadowArray.d.ts +56 -3
  64. package/dist/render/pointShadowArray.js +127 -16
  65. package/dist/render/pointShadowMap.d.ts +23 -1
  66. package/dist/render/pointShadowMap.js +27 -1
  67. package/dist/render/recon/changeFrames.d.ts +15 -0
  68. package/dist/render/recon/changeFrames.js +21 -0
  69. package/dist/render/recon/lateRouting.d.ts +14 -0
  70. package/dist/render/recon/lateRouting.js +18 -0
  71. package/dist/render/recon/mover.d.ts +57 -0
  72. package/dist/render/recon/mover.js +86 -0
  73. package/dist/render/renderQuality.d.ts +35 -0
  74. package/dist/render/renderQuality.js +7 -0
  75. package/dist/render/rendererHarness.js +12 -0
  76. package/dist/render/sceneTarget.d.ts +7 -1
  77. package/dist/render/sceneTarget.js +58 -12
  78. package/dist/render/shaders/depth.d.ts +16 -1
  79. package/dist/render/shaders/depth.js +85 -9
  80. package/dist/render/shaders/flat/directionalShadow.js +91 -6
  81. package/dist/render/shaders/flat/glassTint.d.ts +6 -0
  82. package/dist/render/shaders/flat/glassTint.js +25 -0
  83. package/dist/render/shaders/flat/index.d.ts +13 -0
  84. package/dist/render/shaders/flat/index.js +4 -0
  85. package/dist/render/shaders/flat/lampGlass.d.ts +1 -0
  86. package/dist/render/shaders/flat/lampGlass.js +183 -0
  87. package/dist/render/shaders/flat/main.d.ts +1 -1
  88. package/dist/render/shaders/flat/main.js +115 -15
  89. package/dist/render/shaders/flat/pointShadow.d.ts +1 -1
  90. package/dist/render/shaders/flat/pointShadow.js +2 -0
  91. package/dist/render/shaders/flat/preamble.js +21 -6
  92. package/dist/render/shaders/generated/depth.wgsl.d.ts +227 -4
  93. package/dist/render/shaders/generated/depth.wgsl.js +227 -4
  94. package/dist/render/shaders/generated/flat.wgsl.d.ts +360 -312
  95. package/dist/render/shaders/generated/flat.wgsl.js +376 -328
  96. package/dist/render/shaders/generated/globalMedium.wgsl.d.ts +3 -13
  97. package/dist/render/shaders/generated/globalMedium.wgsl.js +3 -13
  98. package/dist/render/shaders/generated/lightVolume.wgsl.d.ts +3 -13
  99. package/dist/render/shaders/generated/lightVolume.wgsl.js +4 -14
  100. package/dist/render/shaders/generated/octahedralResolve.wgsl.d.ts +29 -0
  101. package/dist/render/shaders/generated/octahedralResolve.wgsl.js +29 -0
  102. package/dist/render/shaders/globalMedium.js +6 -6
  103. package/dist/render/shaders/gpudriven/blendRaster.wgsl.d.ts +7 -0
  104. package/dist/render/shaders/gpudriven/blendRaster.wgsl.js +86 -1
  105. package/dist/render/shaders/gpudriven/cull.wgsl.d.ts +1 -1
  106. package/dist/render/shaders/gpudriven/cull.wgsl.js +11 -2
  107. package/dist/render/shaders/gpudriven/materialTable.wgsl.d.ts +1 -1
  108. package/dist/render/shaders/gpudriven/materialTable.wgsl.js +3 -1
  109. package/dist/render/shaders/gpudriven/shade.wgsl.js +50 -1
  110. package/dist/render/shaders/gpudriven/sunGlass.wgsl.d.ts +9 -0
  111. package/dist/render/shaders/gpudriven/sunGlass.wgsl.js +133 -0
  112. package/dist/render/shaders/lightVolume.js +6 -6
  113. package/dist/render/shaders/octahedralResolve.d.ts +8 -0
  114. package/dist/render/shaders/octahedralResolve.js +48 -17
  115. package/dist/render/shaders/recon/lateDepth.wgsl.d.ts +1 -0
  116. package/dist/render/shaders/recon/lateDepth.wgsl.js +44 -0
  117. package/dist/render/shaders/recon/motion.wgsl.d.ts +1 -1
  118. package/dist/render/shaders/recon/motion.wgsl.js +84 -0
  119. package/dist/render/shadowCasters.d.ts +20 -1
  120. package/dist/render/shadowCasters.js +15 -1
  121. package/dist/render/shadowMap.d.ts +54 -5
  122. package/dist/render/shadowMap.js +190 -36
  123. package/dist/render/sunGlassTint.d.ts +25 -0
  124. package/dist/render/sunGlassTint.js +79 -0
  125. package/dist/render/translucentQueue.d.ts +6 -0
  126. package/dist/render/translucentQueue.js +15 -1
  127. package/package.json +6 -6
  128. package/src/index.ts +10 -0
  129. package/src/render/backend/api.ts +15 -9
  130. package/src/render/backend/webgl2/glassTintPrograms.ts +58 -0
  131. package/src/render/backend/webgl2/renderer.ts +401 -108
  132. package/src/render/backend/webgpu/buffers.ts +50 -2
  133. package/src/render/backend/webgpu/depthPass.ts +2 -1
  134. package/src/render/backend/webgpu/flatPass.ts +22 -1
  135. package/src/render/backend/webgpu/glassTintPass.ts +244 -0
  136. package/src/render/backend/webgpu/gpuDrivenPass.ts +349 -5
  137. package/src/render/backend/webgpu/instanced.ts +21 -1
  138. package/src/render/backend/webgpu/latePass.ts +152 -0
  139. package/src/render/backend/webgpu/lightVolumePass.ts +5 -1
  140. package/src/render/backend/webgpu/motionPass.ts +535 -0
  141. package/src/render/backend/webgpu/pipelineCache.ts +12 -1
  142. package/src/render/backend/webgpu/pointGlassTintPass.ts +233 -0
  143. package/src/render/backend/webgpu/pointShadowPass.ts +158 -26
  144. package/src/render/backend/webgpu/renderer.ts +1108 -421
  145. package/src/render/backend/webgpu/scatterPass.ts +2 -1
  146. package/src/render/backend/webgpu/skinPaletteRing.ts +4 -0
  147. package/src/render/backend/webgpu/snapshotMips.ts +80 -0
  148. package/src/render/backend/webgpu/surfaceTexturePass.ts +1 -1
  149. package/src/render/glass.ts +74 -0
  150. package/src/render/glassCasters.ts +164 -0
  151. package/src/render/glassShadow.ts +153 -0
  152. package/src/render/globalMediumPass.ts +4 -11
  153. package/src/render/gpudriven/lit.ts +31 -0
  154. package/src/render/gpudriven/materialTable.ts +28 -6
  155. package/src/render/gpudriven/pipeline.ts +4 -3
  156. package/src/render/gpudriven/sunGlass.ts +117 -0
  157. package/src/render/lightBudget.ts +19 -5
  158. package/src/render/pointGlassTint.ts +250 -0
  159. package/src/render/pointShadowArray.ts +188 -22
  160. package/src/render/pointShadowMap.ts +41 -0
  161. package/src/render/recon/changeFrames.ts +24 -0
  162. package/src/render/recon/lateRouting.ts +29 -0
  163. package/src/render/recon/mover.ts +118 -0
  164. package/src/render/renderQuality.ts +47 -0
  165. package/src/render/rendererHarness.ts +12 -0
  166. package/src/render/sceneTarget.ts +58 -11
  167. package/src/render/shaders/depth.ts +109 -9
  168. package/src/render/shaders/flat/directionalShadow.ts +97 -6
  169. package/src/render/shaders/flat/glassTint.ts +25 -0
  170. package/src/render/shaders/flat/index.ts +17 -0
  171. package/src/render/shaders/flat/lampGlass.ts +185 -0
  172. package/src/render/shaders/flat/main.ts +115 -15
  173. package/src/render/shaders/flat/pointShadow.ts +2 -0
  174. package/src/render/shaders/flat/preamble.ts +21 -6
  175. package/src/render/shaders/generated/depth.wgsl.ts +234 -4
  176. package/src/render/shaders/generated/flat.wgsl.ts +376 -328
  177. package/src/render/shaders/generated/globalMedium.wgsl.ts +3 -13
  178. package/src/render/shaders/generated/lightVolume.wgsl.ts +4 -14
  179. package/src/render/shaders/generated/octahedralResolve.wgsl.ts +30 -0
  180. package/src/render/shaders/globalMedium.ts +6 -6
  181. package/src/render/shaders/gpudriven/blendRaster.wgsl.ts +88 -1
  182. package/src/render/shaders/gpudriven/cull.wgsl.ts +11 -2
  183. package/src/render/shaders/gpudriven/materialTable.wgsl.ts +3 -1
  184. package/src/render/shaders/gpudriven/shade.wgsl.ts +50 -1
  185. package/src/render/shaders/gpudriven/sunGlass.wgsl.ts +139 -0
  186. package/src/render/shaders/lightVolume.ts +6 -6
  187. package/src/render/shaders/octahedralResolve.ts +50 -17
  188. package/src/render/shaders/recon/lateDepth.wgsl.ts +47 -0
  189. package/src/render/shaders/recon/motion.wgsl.ts +84 -0
  190. package/src/render/shadowCasters.ts +28 -1
  191. package/src/render/shadowMap.ts +231 -37
  192. package/src/render/sunGlassTint.ts +86 -0
  193. package/src/render/translucentQueue.ts +20 -1
@@ -82,6 +82,11 @@ export const MAIN_GLSL = `void main() {
82
82
  * the branch below builds a shaded result on top of it.
83
83
  */
84
84
  vec3 lit = albedo;
85
+ /* The light arriving at a glass pane from behind it, gathered in each light loop below and added
86
+ over the see-through at the end. Stays zero for anything that is not glass. See glass.ts. */
87
+ vec3 glassGlow = vec3(0.0);
88
+ float glassTransmission = uSeeThrough.z;
89
+ float glassFrost = uSeeThrough.w;
85
90
 
86
91
  if (uLightingEnabled != 0) {
87
92
  vec3 n = normalize(vNormal);
@@ -93,7 +98,13 @@ export const MAIN_GLSL = `void main() {
93
98
  * back of the sheet; what that gives up is a sliver at a curved silhouette, where a front face's
94
99
  * interpolated normal already leans away and is lit as the back.
95
100
  */
96
- bool backFace = uDoubleSided != 0 && dot(n, uCameraPos - vWorldPos) < 0.0;
101
+ /*
102
+ * **Glass is two-sided whatever its material says**: a pane is symmetric, so from behind the
103
+ * side the eye sees is the one lit, and the light on its far side is what glows through it.
104
+ * Taken from the stored normal alone, a pane seen from behind glowed with the light on the
105
+ * eye's side and not with the sun shining through it.
106
+ */
107
+ bool backFace = (uDoubleSided != 0 || glassTransmission > 0.0) && dot(n, uCameraPos - vWorldPos) < 0.0;
97
108
  /*
98
109
  * The authored normal, before either relief perturbs it.
99
110
  *
@@ -312,9 +323,13 @@ export const MAIN_GLSL = `void main() {
312
323
  float surfaceNdl = dot(surfaceN, uDirectionalDir);
313
324
  #if DIRECTIONAL_SHADOWS
314
325
  float sunShade = shadowFactor(max(surfaceNdl, 0.0));
326
+ /* What the sun keeps through any glass on its way here: see sunGlassLookup. */
327
+ vec3 sunGlass = sunGlassTint(max(surfaceNdl, 0.0));
315
328
  #else
316
329
  float sunShade = 1.0;
330
+ vec3 sunGlass = vec3(1.0);
317
331
  #endif
332
+ vec3 sunColor = uDirectionalColor * sunGlass;
318
333
  /*
319
334
  * **How much sky this vertex can see, applied to the sun and to nothing else.**
320
335
  *
@@ -342,6 +357,8 @@ export const MAIN_GLSL = `void main() {
342
357
  */
343
358
  float sunFacing = smoothstep(0.0, 0.02, surfaceNdl);
344
359
  float direct = ndl * sunShade * sunFacing;
360
+ /* Glass: the sun on the far side of a pane lights it through the glass. See glassGlow. */
361
+ if (glassTransmission > 0.0) glassGlow += sunColor * max(-surfaceNdl, 0.0) * sunShade;
345
362
 
346
363
  /*
347
364
  * Hemispheric: sky above, ground below, mixed by which way the surface looks. An
@@ -388,7 +405,7 @@ export const MAIN_GLSL = `void main() {
388
405
  * smallest change available in a shader with a documented history of shared subexpressions
389
406
  * rounding differently when their neighbours move. See the night-emissive term.
390
407
  */
391
- lit = albedo * (ambient + uDirectionalColor * direct * (1.0 - metal));
408
+ lit = albedo * (ambient + sunColor * direct * (1.0 - metal));
392
409
 
393
410
  /*
394
411
  * A sun highlight, for the few surfaces that ask for one.
@@ -450,7 +467,7 @@ export const MAIN_GLSL = `void main() {
450
467
  * before: \`sunSpec\` is \`vec3(vSpecular)\` at metal 0 and \`vSpecular\` defaults to 0.
451
468
  */
452
469
  vec3 sunHighlight =
453
- uDirectionalColor * specularLobe(max(dot(n, halfway), 0.0), surfaceRoughness) * sunSpec * sunShade * sunFacing;
470
+ sunColor * specularLobe(max(dot(n, halfway), 0.0), surfaceRoughness) * sunSpec * sunShade * sunFacing;
454
471
  /*
455
472
  * The dielectric's share goes in here, where it has always gone, so the environment blend
456
473
  * below dims it by exactly the reflectance it always dimmed it by. The metal's share is added
@@ -1022,7 +1039,14 @@ export const MAIN_GLSL = `void main() {
1022
1039
  }
1023
1040
  if (falloff <= 0.0) continue;
1024
1041
  float ndl = max(dot(n, toLight / max(dist, 1e-4)), 0.0);
1025
- if (ndl <= 0.0) continue;
1042
+ /*
1043
+ * **A lamp behind a pane is not skipped when the surface is glass**: it lights the pane through
1044
+ * the glass, shaped and shadowed like any lamp, and is added to glassGlow once its shape is
1045
+ * known below. For everything else a lamp behind the surface is skipped here, as always.
1046
+ */
1047
+ float backNdl =
1048
+ glassTransmission > 0.0 ? max(-dot(n, toLight / max(dist, 1e-4)), 0.0) : 0.0;
1049
+ if (ndl <= 0.0 && backNdl <= 0.0) continue;
1026
1050
 
1027
1051
  /*
1028
1052
  * Normal-offset bias.
@@ -1075,7 +1099,17 @@ export const MAIN_GLSL = `void main() {
1075
1099
  */
1076
1100
  int shadowRead = clamp(shadowSlot, 0, MAX_LIGHTS - 1);
1077
1101
  int layer = shadowSlot >= 0 && shadowSlot < MAX_LIGHTS ? uPointShadowLayer[shadowRead] : -1;
1102
+ /* What the panes between this receiver and the lamp let through, per map: lampGlass.ts. */
1103
+ vec3 staticGlass = vec3(1.0);
1104
+ vec3 liveGlass = vec3(1.0);
1078
1105
  if (layer >= 0 && shadowWeight > POINT_SHADOW_MIN_WEIGHT) {
1106
+ staticGlass = pointGlassTint(
1107
+ float(layer),
1108
+ receiverPoint - uPointShadowProjection[shadowRead].xyz,
1109
+ uPointShadowProjection[shadowRead].w,
1110
+ uPointShadowNear[shadowRead],
1111
+ uPointShadowSize[shadowRead]
1112
+ );
1079
1113
  occl = mix(
1080
1114
  1.0,
1081
1115
  pointShadow(
@@ -1115,10 +1149,20 @@ export const MAIN_GLSL = `void main() {
1115
1149
  uLivePointShadowSize[shadowRead]
1116
1150
  );
1117
1151
  liveWeight = uLivePointShadowWeight[shadowRead];
1152
+ liveGlass = pointGlassTint(
1153
+ float(liveLayer),
1154
+ receiverPoint - uLivePointShadowProjection[shadowRead].xyz,
1155
+ uLivePointShadowProjection[shadowRead].w,
1156
+ uLivePointShadowNear[shadowRead],
1157
+ uLivePointShadowSize[shadowRead]
1158
+ );
1118
1159
  }
1119
1160
  occl *= mix(1.0, liveOccl, liveWeight);
1161
+ /* Each map's glass faded in by that map's presence, as its occlusion is. */
1162
+ vec3 lampGlass = mix(vec3(1.0), staticGlass, uPointShadowWeight[shadowRead]) * mix(vec3(1.0), liveGlass, liveWeight);
1120
1163
  #else
1121
1164
  float occl = 1.0;
1165
+ vec3 lampGlass = vec3(1.0);
1122
1166
  #endif
1123
1167
 
1124
1168
  // Blend occlusion out as the light fades, so a shadow can never be more
@@ -1239,6 +1283,8 @@ export const MAIN_GLSL = `void main() {
1239
1283
  float photometric = mix(1.0, iesGain, step(0.0, iesProfile));
1240
1284
 
1241
1285
  float shape = (uLightFalloff == 1 ? falloff : falloff * falloff) * coneFalloff * photometric;
1286
+ glassGlow += lightColor * backNdl * shape * lightWeight * shaded * lampGlass;
1287
+ if (ndl <= 0.0) continue;
1242
1288
  /*
1243
1289
  * The cookie tints rather than scales, because a mask may be coloured — a stained window is
1244
1290
  * the case that makes the difference — and a greyscale one is exactly a scale. Applied to
@@ -1277,7 +1323,7 @@ export const MAIN_GLSL = `void main() {
1277
1323
  */
1278
1324
  vec3 lampDiffuse = albedo * lightColor * ndl * shape * lightWeight * (1.0 - metal);
1279
1325
  lampOpen += lampDiffuse;
1280
- lampShadowed += lampDiffuse * shaded;
1326
+ lampShadowed += lampDiffuse * shaded * lampGlass;
1281
1327
 
1282
1328
  /*
1283
1329
  * A lamp reflected in a polished surface, which point lights could not do at all.
@@ -1312,7 +1358,7 @@ export const MAIN_GLSL = `void main() {
1312
1358
  lightColor * sphereLobe(max(dot(n, lampHalfway), 0.0), surfaceRoughness, lightSourceRadius, dist)
1313
1359
  * lampSpec * shape * lightWeight;
1314
1360
  lampOpen += lampHighlight;
1315
- lampShadowed += lampHighlight * shaded;
1361
+ lampShadowed += lampHighlight * shaded * lampGlass;
1316
1362
  }
1317
1363
  /*
1318
1364
  * The most any light in range shadows this point, for the emissive term below —
@@ -1373,7 +1419,11 @@ export const MAIN_GLSL = `void main() {
1373
1419
  */
1374
1420
  float signedForm = quadFormFactor(n, vWorldPos, c0, c1, c2, c3);
1375
1421
  float form = mix(max(0.0, signedForm), abs(signedForm), uAreaLightTwoSided[a]);
1376
- if (form <= 0.0) continue;
1422
+ /* The form factor is linear in the normal, so the one seen from behind is its negation. */
1423
+ float backForm = glassTransmission > 0.0
1424
+ ? mix(max(0.0, -signedForm), abs(signedForm), uAreaLightTwoSided[a])
1425
+ : 0.0;
1426
+ if (form <= 0.0 && backForm <= 0.0) continue;
1377
1427
 
1378
1428
  /*
1379
1429
  * **How much of the rectangle this fragment can actually see past whatever is in the way.**
@@ -1400,6 +1450,7 @@ export const MAIN_GLSL = `void main() {
1400
1450
  * is a constant nobody has measured. \`docs/IMPROVEMENTS.md\` carries the row.
1401
1451
  */
1402
1452
  float areaOccl = 1.0;
1453
+ vec3 areaGlass = vec3(1.0);
1403
1454
  #if POINT_SHADOWS
1404
1455
  /*
1405
1456
  * The sample position is pushed along the surface normal before the lookup, and it scales
@@ -1440,6 +1491,12 @@ export const MAIN_GLSL = `void main() {
1440
1491
  ),
1441
1492
  uAreaShadowWeight[a]
1442
1493
  );
1494
+ /* What the panes before the rectangle let through, faded in as its occlusion is. */
1495
+ areaGlass = mix(
1496
+ vec3(1.0),
1497
+ areaGlassTint(float(areaLayer), areaShadowFrom, uAreaShadowFar[a], uAreaShadowNear[a], right, up, halfSize),
1498
+ uAreaShadowWeight[a]
1499
+ );
1443
1500
  }
1444
1501
  int areaLiveLayer = uLiveAreaShadowLayer[a];
1445
1502
  if (areaLiveLayer >= 0) {
@@ -1457,13 +1514,28 @@ export const MAIN_GLSL = `void main() {
1457
1514
  ),
1458
1515
  uLiveAreaShadowWeight[a]
1459
1516
  );
1517
+ areaGlass *= mix(
1518
+ vec3(1.0),
1519
+ areaGlassTint(
1520
+ float(areaLiveLayer),
1521
+ areaShadowFrom,
1522
+ uLiveAreaShadowFar[a],
1523
+ uLiveAreaShadowNear[a],
1524
+ right,
1525
+ up,
1526
+ halfSize
1527
+ ),
1528
+ uLiveAreaShadowWeight[a]
1529
+ );
1460
1530
  }
1461
1531
  #endif
1462
1532
 
1533
+ glassGlow += uAreaLightColor[a] * backForm * areaOccl * areaGlass;
1534
+ if (form <= 0.0) continue;
1463
1535
  /* Held back with the point lamps', and shadowed by the same term it always was. */
1464
1536
  vec3 areaDiffuse = albedo * uAreaLightColor[a] * form * (1.0 - metal);
1465
1537
  lampOpen += areaDiffuse;
1466
- lampShadowed += areaDiffuse * areaOccl;
1538
+ lampShadowed += areaDiffuse * areaOccl * areaGlass;
1467
1539
 
1468
1540
  if (vSpecular > 0.0 || metal > 0.0) {
1469
1541
  /*
@@ -1490,7 +1562,7 @@ export const MAIN_GLSL = `void main() {
1490
1562
  vec3 areaSpec = specColor * areaDfg.x + vec3(areaDfg.y);
1491
1563
  vec3 areaHighlight = areaSpec * uAreaLightColor[a] * coverage;
1492
1564
  lampOpen += areaHighlight;
1493
- lampShadowed += areaHighlight * areaOccl;
1565
+ lampShadowed += areaHighlight * areaOccl * areaGlass;
1494
1566
  }
1495
1567
  }
1496
1568
  }
@@ -1550,6 +1622,9 @@ export const MAIN_GLSL = `void main() {
1550
1622
  * \`driftLight.ts\`.
1551
1623
  */
1552
1624
  if (driftShare > 0.0) {
1625
+ if (glassTransmission > 0.0) {
1626
+ glassGlow += driftLightIrradiance(vWorldPos, -n) * (driftShare * uDriftLight.w);
1627
+ }
1553
1628
  lit += albedo * driftLightIrradiance(vWorldPos, n) * (driftShare * uDriftLight.w) * (1.0 - metal);
1554
1629
  }
1555
1630
 
@@ -1737,14 +1812,39 @@ export const MAIN_GLSL = `void main() {
1737
1812
  * splitting the specular out before the fog, which is a larger change to the one shader every
1738
1813
  * draw uses.
1739
1814
  */
1740
- if (uRefractStrength > 0.0) {
1815
+ if (uSeeThrough.x > 0.0 || glassTransmission > 0.0) {
1741
1816
  vec3 refractN = normalize(vNormal);
1742
1817
  vec3 refractV = normalize(uCameraPos - vWorldPos);
1743
- vec2 screenUv = gl_FragCoord.xy / vec2(textureSize(uRefractScene, 0));
1744
- vec2 bent = clamp(screenUv + refractN.xy * uRefractStrength, vec2(0.0), vec2(1.0));
1745
- vec3 behind = texture(uRefractScene, bent).rgb;
1746
- float pathLength = uRefractThickness * vThickness / max(dot(refractN, refractV), 0.05);
1747
- shaded = behind * pow(uRefractTint, vec3(pathLength));
1818
+ ivec2 snapSize = textureSize(uRefractScene, 0);
1819
+ vec2 screenUv = gl_FragCoord.xy / vec2(snapSize);
1820
+ vec2 bent = clamp(screenUv + refractN.xy * uSeeThrough.x, vec2(0.0), vec2(1.0));
1821
+ /*
1822
+ * **An explicit level, and frost is what picks it** — the 2026-08-07 rule, and the reason a
1823
+ * frosted pane blurs rather than fades: the copy carries a mip chain on a frame that draws glass,
1824
+ * so a milkier pane reads a coarser level of it. Level 0 on a copy with one level is exactly what
1825
+ * \`texture()\` read here before, so plain refraction draws as it did.
1826
+ */
1827
+ /* Two short of the last level: a fully frosted pane still shows the large light and dark of what
1828
+ is behind it, where the chain's last level is one texel, the whole frame's average. */
1829
+ float levels = max(floor(log2(float(max(snapSize.x, snapSize.y)))) - 2.0, 0.0);
1830
+ vec3 behind = textureLod(uRefractScene, bent, glassFrost * levels).rgb;
1831
+ /* Unsigned: a pane passes the same light seen from either side, and so does its Fresnel. */
1832
+ float cosView = max(abs(dot(refractN, refractV)), 0.05);
1833
+ float pathLength = uSeeThrough.y * vThickness / cosView;
1834
+ vec3 seen = behind * pow(uRefractTint, vec3(pathLength));
1835
+ if (glassTransmission > 0.0) {
1836
+ /*
1837
+ * **Glass keeps its own surface and shows what is behind over it**, by how much it lets
1838
+ * through and how little it reflects at this angle — Schlick's Fresnel at 0.04, the arithmetic
1839
+ * \`glass.ts\` states. So a clear pane keeps its highlight, and a pane seen edge-on is a mirror.
1840
+ * The glow of the lights behind it is added last, by how frosted it is.
1841
+ */
1842
+ float fresnel = 0.04 + 0.96 * pow(1.0 - cosView, 5.0);
1843
+ shaded = mix(shaded, seen * uGlassTint, glassTransmission * (1.0 - fresnel)) +
1844
+ applyOutputTransform(glassGlow * uGlassTint * (glassFrost * glassTransmission) * (1.0 - fog));
1845
+ } else {
1846
+ shaded = seen;
1847
+ }
1748
1848
  }
1749
1849
  /*
1750
1850
  * The per-vertex alpha lane, folded in here rather than given an expression of its own so the
@@ -1 +1 @@
1
- export declare const POINTSHADOW_GLSL = "/**\n * How much of one tap's occlusion survives its own penumbra.\n *\n * **How much of a shadow survives, as well as how soft it is.** A penumbra does not merely blur\n * with distance from its caster, it *takes over*: far enough from the occluder, relative to how\n * big the source is, every point on the receiver can see part of the flame and there is no umbra\n * left at all. The shadow is gone, not blurry. Without it, two columns lit by a brazier threw\n * full-strength edges fifteen metres across the terrace, and the gap between them read as a\n * spotlight cone with straight sides rather than as a fire.\n *\n * **Per tap, and it was once for the whole filter, taken from the centre tap alone.** That is a\n * blocker search of one sample standing in for twelve, and it is right wherever the taps agree \u2014\n * inside an umbra they all find the same occluder, so this returns exactly what the shared value\n * did, and the umbra is unchanged to the bit. It is wrong exactly where they disagree, which is\n * the silhouette: there the centre ray *misses*, so the search reports no occluder, the spread is\n * zero and the fade is switched off \u2014 while the taps that do land on the caster then draw at full\n * strength. What that paints is a hard one-texel line around a shadow whose interior has\n * correctly faded to nothing.\n *\n * Reported as shadows \"faded out but NOT shadow outlines, generating long lines around the\n * world\", and on a brazier as a bare square outline lying on the ground with no shadow inside it.\n *\n * **What it costs** is two multiplies and a divide per occluded tap, against a tap that has\n * already paid for a texture fetch. **What would make it wrong** is a filter wide enough that one\n * tap's occluder is not the occluder a neighbouring tap is estimating for, which is the same\n * limit the shared value had and is what `MAX_FILTER_RADIUS` bounds.\n */\nfloat tapStrength(float receiverDistance, float occluderDistance, float sourceRadius) {\n float spread = max(receiverDistance - occluderDistance, 0.0) / max(occluderDistance, 0.05);\n float penumbra = clamp(sourceRadius * spread * PENUMBRA_FADE, 0.0, 1.0);\n return 1.0 - penumbra * penumbra;\n}\n\nfloat pointShadow(\n highp sampler2DArray maps,\n float layer,\n vec3 toFrag,\n float far,\n float near,\n float sourceRadius\n) {\n /*\n * The receiver's own distance, and it is the *radius* now rather than a cube face's local Z.\n *\n * That difference removes two things. Every tap of an angular disk shares this one number,\n * where a cube needed each tap's own face-local Z recomputed \u2014 offsets changed it, and\n * comparing them all against the centre ray drew repeated wedges on large receivers. And the\n * stored value converts with a multiply instead of the perspective divide, which used to\n * magnify whatever error the sample arrived with, worst near the far plane.\n */\n float dist = length(toFrag);\n\n /*\n * A receiver nearer than the near plane is not shadowed at all.\n *\n * The near plane already says \"nothing this close to the source is rendered into the\n * map\", and a caller raises it so a fixture does not shadow its own housing. That was\n * only ever applied to *casters*, so a surface inside the same distance still went\n * through the comparison \u2014 against a map that, by the caller's own instruction, holds\n * nothing about anything near it.\n *\n * Reported on a ceiling with recessed strip lights hung a hand's width below it: shadows\n * that \"go on and off\" as the camera moves. The seams that made it unmissable are gone;\n * the gate stays, because comparing against a map that holds nothing is still wrong.\n *\n * The gate is the caller's own number rather than a new constant. A consumer that wants\n * the surface right beside its lamp to take a shadow can lower it, which is the same\n * knob and the same meaning it has always had for the other side of the transaction.\n */\n if (dist <= near) return 1.0;\n\n // Modest depth bias only. The heavy lifting is done by offsetting the\n // sample position along the surface normal before this is called \u2014 see the\n // call site \u2014 which is the cure for grazing receivers that depth bias alone\n // cannot fix without peter-panning.\n float bias = 0.04 + dist * 0.015;\n\n /*\n * Penumbra from the emitter's actual size.\n *\n * A shadow's softness is not a constant: it is set by how large the source is\n * and how far the caster stands from the surface it falls on. Find the\n * occluder with a centre tap, then widen the filter by\n * sourceRadius * (receiver - occluder) / occluder \u2014 the real geometry of a\n * penumbra. A bulb stays crisp; a flame goes soft with distance, which is\n * what makes a fire read as a fire rather than a large lamp.\n *\n * textureLod(..., 0.0), not the implicit-derivative texture() call this replaced.\n * pointShadowArray.ts allocates the array with texStorage3D at one storage level,\n * NEAREST both filters \u2014 there is no mip to select, so the two calls fetch the\n * identical texel. Not a quality trade; the output is bit-for-bit the same.\n *\n * It matters because implicit derivatives are only well-defined under *uniform*\n * control flow, and this sits inside the light loop below. See AGENTS.md, 2026-08-07.\n */\n float centreStored = textureLod(maps, vec3(octEncode(toFrag), layer), 0.0).r;\n float occluderDistance = centreStored >= 0.9999 ? dist : centreStored * far;\n float spread = max(dist - occluderDistance, 0.0) / max(occluderDistance, 0.05);\n /*\n * Softness comes from *fading the shadow*, not from widening the filter.\n *\n * Four attempts went into widening it, and the fourth is what identified why\n * none of them worked. The decisive observation was that the light pool looked\n * right until a column entered it. With no occluder the penumbra estimate is zero,\n * the filter stays at its floor, and the light pool is clean. The instant a\n * column is found the filter widens \u2014 and a wide angular filter on a *cube*\n * map is what crossed face seams. The artefact was never the columns' shadows;\n * it was the search for their penumbra.\n *\n * The map has no seams now, so the cap could open. It has not, in this change:\n * the storage moved and nothing else did, and the widening is a picture decision\n * taken against a tree that already renders correctly.\n */\n float radius = clamp(sourceRadius * spread, 0.01, MAX_FILTER_RADIUS) + 0.012;\n\n /*\n * Taps are placed on a disk *perpendicular to the light ray*, turned by half a golden\n * angle on every other column of pixels.\n *\n * Offsetting the ray by fixed 3D vectors was the earlier approach and it has\n * two faults that only show on a wide filter. The offsets are not\n * perpendicular to the ray, so part of each one moves the sample along its own\n * depth instead of across the shadow; and twelve *fixed* taps at a large\n * radius align, so the penumbra breaks into hard straight bands following the\n * tap pattern \u2014 reported, on a brazier behind a rank of columns, as strange\n * straight lines across the light pool.\n *\n * **The cure for that was a per-fragment hash, and it is what made the penumbra\n * stipple.** Twelve taps are a coarse estimate of how much of the emitter this point can\n * see; turning them by an unrelated angle at every pixel makes each pixel's error\n * independent of its neighbour's, which is the definition of noise. Something has to\n * average that back out, and this engine's lit pass is the last thing to touch the frame \u2014\n * there is no blur and no temporal resolve behind it, so the noise reached the screen. Two\n * games reported the same coarse cross-hatch across a light pool.\n *\n * **So the turn comes from a two-pixel tile instead, and the pair is averaged afterwards.**\n * A pixel's own x parity picks one of two tap sets half a golden angle apart, and\n * `main` folds the pair together once the light loop is over \u2014 see the resolve there. The\n * pair's twenty-four taps are the filter; each pixel pays for twelve of them.\n *\n * **A *column* pair rather than a 2x2 square, and that was measured rather than assumed.**\n * Four turns on a square tile, resolved with both derivatives, came back at 3.88 against this\n * pair's 2.46 on the same build \u2014 because the second derivative hands the lower row of a quad\n * the upper row's difference on hardware that answers a coarse derivative, and with four turns\n * that is the wrong difference. Two turns keyed on the column alone make it the right one,\n * which is why the tile's shape and the resolve are one decision rather than two.\n *\n * **Neither half works alone**, which is the same pairing `ambientOcclusion.ts` describes\n * between its rotation tile and its blur. Measured on `demo/dev/pointshadow.html` at\n * `?exposure=6`, as mean absolute luminance difference to the right and down neighbour over\n * the mover's penumbra, on WebGL2: **4.60** for the per-fragment hash this replaces, **2.88**\n * for this tile with no resolve \u2014 and a one-pixel vertical comb in the picture, which is the\n * tile itself on screen \u2014 against **2.37** for the pair resolved. A frame with the shadow\n * switched off measures 0.81, and WebGPU answers 4.56 and 2.33 for the same two builds.\n *\n * **Unchanged by the move to an octahedral map, and that is the point.** The offsets are\n * angular perturbations of a direction, so every tap is still a direction and octEncode is\n * defined on all of them. Nothing offsets in UV, so the map's border needs no wrap\n * arithmetic and a tap that would have crossed a cube join lands on the adjacent texel.\n */\n vec3 fwd = normalize(toFrag);\n vec3 up = abs(fwd.y) < 0.9 ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0);\n vec3 tu = normalize(cross(up, fwd));\n vec3 tv = cross(fwd, tu);\n /*\n * Integer arithmetic, because this is a lattice: a shader compiler is free to implement\n * `mod(x, 2.0)` as a multiply by a reciprocal, and a GPU here answers 3 for `3.0 % 3.0`.\n * `gl_FragCoord.x` is the pixel's centre, so truncating it is the pixel's own column.\n */\n float angle = float(int(gl_FragCoord.x) & 1) * PCF_PAIR_TURN;\n float ca = cos(angle);\n float sa = sin(angle);\n\n float lit = 0.0;\n for (int i = 0; i < 12; i++) {\n if (i >= uShadowFilterTaps) break;\n vec2 disk = PCF_OFFSETS[i];\n vec2 turned = vec2(disk.x * ca - disk.y * sa, disk.x * sa + disk.y * ca);\n // Perpendicular to the ray, and *not* scaled by its length: the offsets are\n // an angular perturbation of a direction, which is what the encoding takes.\n vec3 sampleDir = toFrag + (tu * turned.x + tv * turned.y) * radius;\n float stored = textureLod(maps, vec3(octEncode(sampleDir), layer), 0.0).r;\n if (stored >= 0.9999) {\n // Beyond the far plane nothing was rendered: treat as lit.\n lit += 1.0;\n continue;\n }\n float storedDistance = stored * far;\n if (dist - bias > storedDistance) {\n // A point shadow cannot outlive the finite light that casts it, so its\n // occlusion fades smoothly before the light's far plane.\n float reach = shadowReach(max(dist - storedDistance, 0.0), far);\n lit += 1.0 - reach * tapStrength(dist, storedDistance, sourceRadius);\n } else {\n lit += 1.0;\n }\n }\n return lit / float(max(uShadowFilterTaps, 1));\n}\n\n/**\n * The same filter for a source that has a *shape* rather than a radius.\n *\n * **One map from the rectangle's centre, and the rectangle's own extent as the filter's shape.**\n * That is the whole difference from `pointShadow` above, and it is what makes the result read as\n * one wide emitter rather than as a lamp: a bulb's penumbra is round, so a row of nine of them\n * gives nine round shadows that pile up darker where they overlap, and a strip's penumbra is a\n * strip \u2014 soft along the cable, tight across it, one shadow with one soft edge.\n *\n * **The taps land on the emitter's silhouette as this fragment sees it**, which is the part a\n * scalar radius cannot express. The rectangle's two axes are projected onto the plane across the\n * light ray and each keeps its own width, so the sample pattern is an ellipse rather than a disk,\n * and a rectangle seen edge-on along one axis has no penumbra in that direction \u2014 which is correct\n * and is what a strip light actually does. Four dot products and two square roots more than the\n * round filter.\n *\n * **The fade is driven by the *narrower* projected half extent, and the reason is a strip.** A\n * penumbra does not only blur a shadow, it takes over: past the point where every part of the\n * receiver can see part of the emitter there is no umbra left. Driven by the wider extent, a\n * three-metre cable would delete its own shadow at a metre of caster clearance \u2014 but across the\n * cable the source is nearly a line, so an umbra band survives there and only the length is\n * smeared. `min` keeps that band; `max` would erase it.\n *\n * **What it costs** is a second copy of the tap loop, about 30 lines, compiled into the eight\n * permutations that carry point shadows. Folding the two into one loop was the alternative and was\n * not taken: the shared form has to multiply the disk offset by a width before scaling the axis\n * rather than after, which is a different rounding order on every tap of the *point* path \u2014 so the\n * saving is paid for by perturbing eight scenes that currently gate at zero pixels, in a change\n * about area lights. `docs/IMPROVEMENTS.md` carries the row.\n *\n * **What would make it wrong** is a rectangle much wider than its distance to the caster, where\n * different points on the emitter genuinely see different silhouettes and no single map from the\n * centre stands in for all of them \u2014 a ceiling-wide panel a hand's width above a table. The honest\n * answer there is several maps across the emitter, which is several bakes.\n */\nfloat areaShadow(\n highp sampler2DArray maps,\n float layer,\n vec3 toFrag,\n float far,\n float near,\n vec3 right,\n vec3 up,\n vec2 halfSize\n) {\n float dist = length(toFrag);\n /* The near plane says nothing this close to the emitter was rendered; see `pointShadow`. */\n if (dist <= near) return 1.0;\n\n float bias = 0.04 + dist * 0.015;\n\n /*\n * The blocker search, one tap along the centre ray, exactly as the round filter does it. Similar\n * triangles turn the two distances into how much wider than the emitter the penumbra is.\n *\n * `textureLod(..., 0.0)` rather than `texture()`: the array carries one storage level and\n * NEAREST both filters, so the two fetch the identical texel \u2014 and this sits inside the area\n * light loop, which is not provably uniform control flow. See AGENTS.md, 2026-08-07.\n */\n float centreStored = textureLod(maps, vec3(octEncode(toFrag), layer), 0.0).r;\n float occluderDistance = centreStored >= 0.9999 ? dist : centreStored * far;\n float spread = max(dist - occluderDistance, 0.0) / max(occluderDistance, 0.05);\n\n vec3 fwd = toFrag / dist;\n /*\n * Each axis with its along-the-ray component removed: the rectangle's outline flattened onto the\n * plane the taps move in. The lengths that come back are the foreshortening \u2014 1 for a rectangle\n * seen face-on, 0 for one seen exactly edge-on along that axis \u2014 so the two widths below carry\n * both the emitter's size and how much of it this fragment can see.\n */\n vec3 acrossX = right - fwd * dot(right, fwd);\n vec3 acrossY = up - fwd * dot(up, fwd);\n float seenX = length(acrossX);\n float seenY = length(acrossY);\n /*\n * A collapsed axis offsets nothing rather than offsetting along an arbitrary direction. Both\n * cannot collapse at once: `right` and `up` are perpendicular, so a ray parallel to one of\n * them is perpendicular to the other.\n */\n vec3 alongX = seenX > 1e-5 ? acrossX / seenX : vec3(0.0);\n vec3 alongY = seenY > 1e-5 ? acrossY / seenY : vec3(0.0);\n\n float halfX = halfSize.x * seenX;\n float halfY = halfSize.y * seenY;\n /* The same ceiling and the same floor the round filter uses, per axis. See MAX_FILTER_RADIUS. */\n float widthX = min(halfX * spread, MAX_FILTER_RADIUS) + 0.012;\n float widthY = min(halfY * spread, MAX_FILTER_RADIUS) + 0.012;\n\n /*\n * Turned inside the unit disk *before* the ellipse maps it, so the half-turn that separates\n * the two halves of a pixel pair survives the anisotropy. The same two-pixel tile the round\n * filter uses and for the same reasons \u2014 see `pointShadow`, which carries the measurement;\n * a rectangle's shadow stippled exactly as a lamp's did, because it is the same twelve taps.\n */\n float angle = float(int(gl_FragCoord.x) & 1) * PCF_PAIR_TURN;\n float ca = cos(angle);\n float sa = sin(angle);\n\n float lit = 0.0;\n for (int i = 0; i < 12; i++) {\n if (i >= uShadowFilterTaps) break;\n vec2 disk = PCF_OFFSETS[i];\n vec2 turned = vec2(disk.x * ca - disk.y * sa, disk.x * sa + disk.y * ca);\n vec3 sampleDir = toFrag + alongX * (turned.x * widthX) + alongY * (turned.y * widthY);\n float stored = textureLod(maps, vec3(octEncode(sampleDir), layer), 0.0).r;\n if (stored >= 0.9999) {\n /* Beyond the far plane nothing was rendered: treat as lit. */\n lit += 1.0;\n continue;\n }\n float storedDistance = stored * far;\n if (dist - bias > storedDistance) {\n /* An area light's occlusion cannot outlive the map that carries it either. */\n float reach = shadowReach(max(dist - storedDistance, 0.0), far);\n /* The narrower half extent, for the reason in the header: it is what keeps a strip's\n umbra. Per tap, for the reason `tapStrength` gives. */\n lit += 1.0 - reach * tapStrength(dist, storedDistance, min(halfX, halfY));\n } else {\n lit += 1.0;\n }\n }\n return lit / float(max(uShadowFilterTaps, 1));\n}\n#endif\n\nout vec4 outColor;\n\n\n/** 0 none, 1 sRGB, 2 ACES then sRGB. See renderQuality.ts. */\nuniform int uOutputTransform;\n/** Scales the scene into the tone curve. 1 is the reference grade. See renderQuality.ts. */\nuniform float uOutputExposure;\n\n/*\n * ACES: the reference fit, not the cheap one.\n *\n * This was Narkowicz's single rational function, on the argument that the difference from\n * the reference curve is invisible next to the gain. That argument holds for a look and\n * fails for a *match*, which is what this option is for \u2014 aces exists so a world ported\n * from three.js reads the same, and three.js applies the full fit: into AP1 through\n * ACESInputMat, the RRT and ODT together, then back out through ACESOutputMat.\n *\n * The two curves are not a shade apart. Narkowicz is markedly brighter through the\n * midtones, which is exactly where an interior scene lives, and it is a large part of a\n * measured ~1.7x that survived correcting the colour space and the missing Lambert pi.\n * An approximation of a standard is the wrong thing to hold when the standard is the\n * specification.\n */\nvec3 rrtAndOdtFit(vec3 v) {\n vec3 a = v * (v + 0.0245786) - 0.000090537;\n vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\n return a / b;\n}\n\nvec3 acesFilmic(vec3 x) {\n /*\n * Exposure first, because a tone curve is only defined relative to one.\n *\n * The reference RRT and ODT are graded for a dark cinema. Every renderer that ships ACES\n * scales its input to suit whatever it is actually shown on, and the factor each one\n * picks is a *look*, not a standard - so this engine takes no position and reads it from\n * the caller. Neutral by default, which is the reference grade unmodified. three.js's own\n * pick is 1 / 0.6, for a consumer matching one.\n */\n x *= uOutputExposure;\n // Columns, as GLSL reads them: sRGB -> XYZ -> D65_2_D60 -> AP1 -> RRT_SAT.\n const mat3 ACES_INPUT = mat3(\n 0.59719, 0.07600, 0.02840,\n 0.35458, 0.90834, 0.13383,\n 0.04823, 0.01566, 0.83777\n );\n // ODT_SAT -> XYZ -> D60_2_D65 -> sRGB.\n const mat3 ACES_OUTPUT = mat3(\n 1.60475, -0.10208, -0.00327,\n -0.53108, 1.10813, -0.07276,\n -0.07367, -0.00605, 1.07602\n );\n return clamp(ACES_OUTPUT * rrtAndOdtFit(ACES_INPUT * x), 0.0, 1.0);\n}\n\n/*\n * Linear to sRGB. The piecewise form rather than a plain pow: the linear toe near black\n * is where banding lives in an 8-bit buffer, and the cheap approximation puts it in the\n * wrong place.\n */\nvec3 linearToSrgb(vec3 c) {\n vec3 low = c * 12.92;\n vec3 high = 1.055 * pow(max(c, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;\n return mix(high, low, step(c, vec3(0.0031308)));\n}\n\nvec3 applyOutputTransform(vec3 c) {\n if (uOutputTransform == 0) return c;\n if (uOutputTransform == 2) c = acesFilmic(c);\n return linearToSrgb(c);\n}\n\n\n/**\n * A fixed Poisson disk avoids the grid-shaped edge left by square 3x3 PCF.\n * Directional and point shadows consume the same maximum filter-tap budget;\n * their texture sizes differ because one is a 2D projection of a frustum and one\n * is an octahedral projection of the whole sphere, not because one is a lower\n * quality tier.\n */\n#if DIRECTIONAL_SHADOWS\nconst vec2 DIRECTIONAL_PCF_OFFSETS[12] = vec2[12](\n vec2(-0.326, -0.406), vec2( 0.519, 0.767), vec2( 0.962, -0.195), vec2(-0.696, 0.457),\n vec2(-0.840, -0.074), vec2( 0.185, -0.893), vec2( 0.896, 0.412), vec2(-0.203, 0.621),\n vec2( 0.473, -0.480), vec2( 0.507, 0.064), vec2(-0.322, -0.933), vec2(-0.792, -0.598)\n);\n\n/** Anything outside the light frustum or beyond its far plane counts as lit. */";
1
+ export declare const POINTSHADOW_GLSL: string;
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import { MAX_SHADOW_FILTER_TAPS } from '../../renderQuality.js';
16
16
  import { OUTPUT_TRANSFORM_GLSL } from '../outputTransform.js';
17
+ import { LAMP_GLASS_GLSL } from './lampGlass.js';
17
18
  export const POINTSHADOW_GLSL = `/**
18
19
  * How much of one tap's occlusion survives its own penumbra.
19
20
  *
@@ -337,6 +338,7 @@ float areaShadow(
337
338
  }
338
339
  return lit / float(max(uShadowFilterTaps, 1));
339
340
  }
341
+ ${LAMP_GLASS_GLSL}
340
342
  #endif
341
343
 
342
344
  out vec4 outColor;
@@ -96,13 +96,20 @@ in float vThickness;
96
96
  * paid by every consumer whether or not they refract, against 19.8 KB for a branch -- which is the
97
97
  * price table Track D's three shipped rows measured.
98
98
  *
99
- * uRefractStrength at 0 is every draw that shipped before this existed, and it is the default, so
99
+ * uSeeThrough.x, the strength, at 0 is every draw that shipped before this existed, and it is the default, so
100
100
  * the sampler is bound to an empty texture and read nowhere on a frame that refracts nothing.
101
101
  */
102
102
  uniform sampler2D uRefractScene;
103
- uniform float uRefractStrength;
103
+ /*
104
+ * **Four numbers in one vector: refraction's strength and path thickness, glass's transmission and
105
+ * frost** (x, y, z, w). One vector rather than four, and that is the whole reason: on a device at the
106
+ * WebGL2 floor of 256 fragment uniform vectors, every loose float is a vector the light budget
107
+ * gives up, and four separate floats cost half the shadowed lights such a device can have. The tints
108
+ * stay colours of their own. Zero transmission is not glass — see glass.ts.
109
+ */
110
+ uniform vec4 uSeeThrough;
104
111
  uniform vec3 uRefractTint;
105
- uniform float uRefractThickness;
112
+ uniform vec3 uGlassTint;
106
113
  flat in int vHasTangents;
107
114
 
108
115
  /**
@@ -256,9 +263,13 @@ uniform vec3 uEmissiveScale;
256
263
  * half of the file, because a test asserts that a profile without a probe mentions them
257
264
  * nowhere — a comment is source too, and it failed that test first.
258
265
  */
259
- uniform highp sampler2D uStaticShadowMap; // wgsl:share shadow
260
- uniform highp sampler2D uPeeledShadowMap; // wgsl:share shadow
261
- uniform highp sampler2D uDynamicShadowMap; // wgsl:share shadow
266
+ /* The sun's static, moving and peeled maps, as layers of one array: see shadowMap.ts. Where glass
267
+ has cast, the last two layers are the nearest pane's depth, static then moving. */
268
+ uniform highp sampler2DArray uSunShadows; // wgsl:share shadow
269
+ /* What the sun keeps through glass, static then moving: colour times colour, and clarity (see
270
+ glassShadow.ts). A one-texel stand-in where no glass has cast, which the lookup reads as none.
271
+ Mipmapped and filtered, unlike the depths: frost reads the level its spread asks for. */
272
+ uniform highp sampler2DArray uSunGlassTints; // wgsl:share tint
262
273
  /** 0 disables directional shadows when their source is not emitting. */
263
274
  uniform float uShadowStrength;
264
275
  uniform float uShadowMapSize;
@@ -854,6 +865,10 @@ uniform float uPointShadowWeight[MAX_LIGHTS];
854
865
  * it exists.
855
866
  */
856
867
  uniform highp sampler2DArray uPointShadows; // wgsl:share shadow
868
+ /* What each light keeps through glass: one layer a light, colour times colour and clarity, beside
869
+ the array above — whose light L then keeps its depth at 2L and its nearest pane at 2L + 1 (see
870
+ pointShadowArray.ts). A one-texel stand-in where no lamp has met glass, read as none. */
871
+ uniform highp sampler2DArray uPointGlassTints; // wgsl:share tint
857
872
 
858
873
  /**
859
874
  * Moving casters are separate from persistent world maps. Two live maps exist