@driftengine/core 4.8.7 → 4.10.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 (263) hide show
  1. package/CHANGELOG.json +123 -11
  2. package/README.md +43 -38
  3. package/dist/index.d.ts +8 -1
  4. package/dist/index.js +11 -3
  5. package/dist/render/ambientHarmonics.d.ts +1 -1
  6. package/dist/render/ambientHarmonics.js +1 -1
  7. package/dist/render/areaLights.d.ts +4 -4
  8. package/dist/render/areaLights.js +1 -1
  9. package/dist/render/atmosphere.d.ts +13 -0
  10. package/dist/render/atmosphere.js +9 -1
  11. package/dist/render/backend/api.d.ts +19 -4
  12. package/dist/render/backend/createRenderer.d.ts +6 -0
  13. package/dist/render/backend/createRenderer.js +4 -1
  14. package/dist/render/backend/select.js +11 -5
  15. package/dist/render/backend/webgl2/boneAnimations.d.ts +29 -0
  16. package/dist/render/backend/webgl2/boneAnimations.js +80 -0
  17. package/dist/render/backend/webgl2/instanced.d.ts +5 -1
  18. package/dist/render/backend/webgl2/instanced.js +13 -1
  19. package/dist/render/backend/webgl2/renderer.d.ts +180 -4
  20. package/dist/render/backend/webgl2/renderer.js +550 -40
  21. package/dist/render/backend/webgl2/skinPaletteTexture.d.ts +5 -3
  22. package/dist/render/backend/webgl2/skinPaletteTexture.js +6 -4
  23. package/dist/render/backend/webgpu/boneAnimations.d.ts +34 -0
  24. package/dist/render/backend/webgpu/boneAnimations.js +76 -0
  25. package/dist/render/backend/webgpu/buffers.d.ts +19 -4
  26. package/dist/render/backend/webgpu/buffers.js +18 -11
  27. package/dist/render/backend/webgpu/compressedUpload.d.ts +0 -1
  28. package/dist/render/backend/webgpu/compressedUpload.js +53 -8
  29. package/dist/render/backend/webgpu/depthPass.d.ts +59 -3
  30. package/dist/render/backend/webgpu/depthPass.js +49 -14
  31. package/dist/render/backend/webgpu/device.d.ts +7 -1
  32. package/dist/render/backend/webgpu/device.js +31 -3
  33. package/dist/render/backend/webgpu/drawCommand.d.ts +18 -4
  34. package/dist/render/backend/webgpu/drawCommand.js +10 -3
  35. package/dist/render/backend/webgpu/flatPass.d.ts +100 -42
  36. package/dist/render/backend/webgpu/flatPass.js +191 -43
  37. package/dist/render/backend/webgpu/instanced.d.ts +14 -1
  38. package/dist/render/backend/webgpu/instanced.js +24 -1
  39. package/dist/render/backend/webgpu/materialStore.d.ts +101 -0
  40. package/dist/render/backend/webgpu/materialStore.js +265 -0
  41. package/dist/render/backend/webgpu/pipelineCache.d.ts +6 -0
  42. package/dist/render/backend/webgpu/pipelineCache.js +7 -0
  43. package/dist/render/backend/webgpu/postPass.d.ts +51 -9
  44. package/dist/render/backend/webgpu/postPass.js +16 -2
  45. package/dist/render/backend/webgpu/reflectionSurfacePass.d.ts +30 -0
  46. package/dist/render/backend/webgpu/reflectionSurfacePass.js +100 -0
  47. package/dist/render/backend/webgpu/renderer.d.ts +283 -37
  48. package/dist/render/backend/webgpu/renderer.js +1363 -202
  49. package/dist/render/backend/webgpu/skinPaletteRing.d.ts +7 -3
  50. package/dist/render/backend/webgpu/skinPaletteRing.js +13 -7
  51. package/dist/render/backend/webgpu/skinPaletteTexture.d.ts +6 -0
  52. package/dist/render/backend/webgpu/skinPaletteTexture.js +7 -1
  53. package/dist/render/backend/webgpu/staticBundles.d.ts +125 -0
  54. package/dist/render/backend/webgpu/staticBundles.js +241 -0
  55. package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +10 -3
  56. package/dist/render/backend/webgpu/surfaceTexturePass.js +20 -2
  57. package/dist/render/backend/webgpu/uniformRing.d.ts +21 -0
  58. package/dist/render/backend/webgpu/uniformRing.js +9 -1
  59. package/dist/render/bloomChain.d.ts +3 -3
  60. package/dist/render/boneAnimation.d.ts +92 -0
  61. package/dist/render/boneAnimation.js +133 -0
  62. package/dist/render/compressedSource.d.ts +33 -13
  63. package/dist/render/compressedSource.js +70 -25
  64. package/dist/render/displayRange.d.ts +31 -0
  65. package/dist/render/displayRange.js +47 -0
  66. package/dist/render/filmicCurve.d.ts +74 -0
  67. package/dist/render/filmicCurve.js +203 -0
  68. package/dist/render/fog.d.ts +4 -1
  69. package/dist/render/fog.js +12 -2
  70. package/dist/render/frame/resources.d.ts +2 -2
  71. package/dist/render/frame/resources.js +6 -0
  72. package/dist/render/frameReflections.d.ts +40 -0
  73. package/dist/render/frameReflections.js +48 -0
  74. package/dist/render/glCompressed.js +83 -0
  75. package/dist/render/instances.d.ts +26 -0
  76. package/dist/render/lightBudget.d.ts +10 -0
  77. package/dist/render/lightBudget.js +10 -0
  78. package/dist/render/lightmap.d.ts +1 -1
  79. package/dist/render/mesh.d.ts +5 -0
  80. package/dist/render/mesh.js +6 -0
  81. package/dist/render/pass.d.ts +49 -0
  82. package/dist/render/pointLightSelection.d.ts +4 -4
  83. package/dist/render/reflectionSurfaceTargets.d.ts +28 -0
  84. package/dist/render/reflectionSurfaceTargets.js +99 -0
  85. package/dist/render/renderQuality.d.ts +39 -8
  86. package/dist/render/renderQuality.js +4 -0
  87. package/dist/render/sceneTarget.d.ts +5 -0
  88. package/dist/render/sceneTarget.js +24 -1
  89. package/dist/render/screenSpaceReflection.d.ts +7 -1
  90. package/dist/render/screenSpaceReflection.js +5 -0
  91. package/dist/render/shaders/arcane.d.ts +1 -1
  92. package/dist/render/shaders/bolt.d.ts +1 -1
  93. package/dist/render/shaders/boneAnimation.d.ts +19 -0
  94. package/dist/render/shaders/boneAnimation.js +63 -0
  95. package/dist/render/shaders/caustics.d.ts +1 -1
  96. package/dist/render/shaders/depth.d.ts +7 -0
  97. package/dist/render/shaders/depth.js +35 -10
  98. package/dist/render/shaders/film.d.ts +1 -1
  99. package/dist/render/shaders/filmLook.js +2 -1
  100. package/dist/render/shaders/fire.d.ts +1 -1
  101. package/dist/render/shaders/flat/glassTint.d.ts +1 -1
  102. package/dist/render/shaders/flat/glassTint.js +2 -0
  103. package/dist/render/shaders/flat/index.d.ts +16 -0
  104. package/dist/render/shaders/flat/index.js +33 -5
  105. package/dist/render/shaders/flat/main.d.ts +1 -1
  106. package/dist/render/shaders/flat/main.js +43 -5
  107. package/dist/render/shaders/flat/models.js +1 -1
  108. package/dist/render/shaders/flat/overlay.d.ts +16 -0
  109. package/dist/render/shaders/flat/overlay.js +117 -0
  110. package/dist/render/shaders/flat/pointShadow.js +3 -3
  111. package/dist/render/shaders/flat/preamble.js +38 -24
  112. package/dist/render/shaders/flat/reflectionSurface.d.ts +21 -0
  113. package/dist/render/shaders/flat/reflectionSurface.js +61 -0
  114. package/dist/render/shaders/fog.d.ts +1 -1
  115. package/dist/render/shaders/fog.js +9 -2
  116. package/dist/render/shaders/fringe.d.ts +29 -0
  117. package/dist/render/shaders/fringe.js +55 -0
  118. package/dist/render/shaders/generated/arcane.wgsl.d.ts +1 -1
  119. package/dist/render/shaders/generated/arcane.wgsl.js +1 -1
  120. package/dist/render/shaders/generated/bolt.wgsl.d.ts +1 -1
  121. package/dist/render/shaders/generated/bolt.wgsl.js +1 -1
  122. package/dist/render/shaders/generated/caustics.wgsl.d.ts +1 -1
  123. package/dist/render/shaders/generated/caustics.wgsl.js +1 -1
  124. package/dist/render/shaders/generated/depth.wgsl.d.ts +93 -0
  125. package/dist/render/shaders/generated/depth.wgsl.js +93 -0
  126. package/dist/render/shaders/generated/film.wgsl.d.ts +1 -1
  127. package/dist/render/shaders/generated/film.wgsl.js +1 -1
  128. package/dist/render/shaders/generated/fire.wgsl.d.ts +1 -1
  129. package/dist/render/shaders/generated/fire.wgsl.js +1 -1
  130. package/dist/render/shaders/generated/flat.wgsl.d.ts +3254 -2920
  131. package/dist/render/shaders/generated/flat.wgsl.js +3292 -2957
  132. package/dist/render/shaders/generated/line.wgsl.d.ts +1 -1
  133. package/dist/render/shaders/generated/line.wgsl.js +1 -1
  134. package/dist/render/shaders/generated/particle.wgsl.d.ts +4 -4
  135. package/dist/render/shaders/generated/particle.wgsl.js +4 -4
  136. package/dist/render/shaders/generated/rush.wgsl.d.ts +56 -26
  137. package/dist/render/shaders/generated/rush.wgsl.js +56 -26
  138. package/dist/render/shaders/generated/scatter.wgsl.d.ts +1 -1
  139. package/dist/render/shaders/generated/scatter.wgsl.js +1 -1
  140. package/dist/render/shaders/generated/smoke.wgsl.d.ts +1 -1
  141. package/dist/render/shaders/generated/smoke.wgsl.js +1 -1
  142. package/dist/render/shaders/generated/ssrResolve.wgsl.d.ts +29 -0
  143. package/dist/render/shaders/generated/ssrResolve.wgsl.js +29 -0
  144. package/dist/render/shaders/generated/ssrTrace.wgsl.d.ts +22 -2
  145. package/dist/render/shaders/generated/ssrTrace.wgsl.js +22 -2
  146. package/dist/render/shaders/generated/water.wgsl.d.ts +1 -1
  147. package/dist/render/shaders/generated/water.wgsl.js +1 -1
  148. package/dist/render/shaders/gpudriven/fog.wgsl.d.ts +2 -2
  149. package/dist/render/shaders/gpudriven/fog.wgsl.js +11 -3
  150. package/dist/render/shaders/line.d.ts +1 -1
  151. package/dist/render/shaders/outputTransform.d.ts +7 -0
  152. package/dist/render/shaders/outputTransform.js +28 -14
  153. package/dist/render/shaders/particle.d.ts +3 -3
  154. package/dist/render/shaders/rush.js +54 -11
  155. package/dist/render/shaders/scatter.d.ts +1 -1
  156. package/dist/render/shaders/smoke.d.ts +1 -1
  157. package/dist/render/shaders/ssrResolve.d.ts +17 -0
  158. package/dist/render/shaders/ssrResolve.js +51 -0
  159. package/dist/render/shaders/ssrTrace.js +26 -0
  160. package/dist/render/shaders/vertexChannel.d.ts +7 -0
  161. package/dist/render/shaders/vertexChannel.js +26 -0
  162. package/dist/render/shaders/water.d.ts +1 -1
  163. package/dist/render/ssrPass.d.ts +16 -0
  164. package/dist/render/ssrPass.js +106 -1
  165. package/dist/render/staticDraws.d.ts +47 -0
  166. package/dist/render/staticDraws.js +43 -0
  167. package/dist/render/surfaceOverlay.d.ts +132 -0
  168. package/dist/render/surfaceOverlay.js +85 -0
  169. package/dist/render/surfaceTexture.d.ts +57 -7
  170. package/dist/render/surfaceTexture.js +125 -17
  171. package/dist/render/temporalAa.d.ts +14 -0
  172. package/dist/render/temporalAa.js +20 -0
  173. package/dist/render/vertexDefaults.d.ts +17 -0
  174. package/dist/render/vertexDefaults.js +24 -0
  175. package/package.json +6 -6
  176. package/src/index.ts +24 -2
  177. package/src/render/ambientHarmonics.ts +1 -1
  178. package/src/render/areaLights.ts +4 -4
  179. package/src/render/atmosphere.ts +22 -1
  180. package/src/render/backend/api.ts +22 -3
  181. package/src/render/backend/createRenderer.ts +18 -1
  182. package/src/render/backend/select.ts +10 -5
  183. package/src/render/backend/webgl2/boneAnimations.ts +105 -0
  184. package/src/render/backend/webgl2/instanced.ts +20 -1
  185. package/src/render/backend/webgl2/renderer.ts +672 -37
  186. package/src/render/backend/webgl2/skinPaletteTexture.ts +6 -4
  187. package/src/render/backend/webgpu/boneAnimations.ts +97 -0
  188. package/src/render/backend/webgpu/buffers.ts +42 -16
  189. package/src/render/backend/webgpu/compressedUpload.ts +59 -9
  190. package/src/render/backend/webgpu/depthPass.ts +51 -10
  191. package/src/render/backend/webgpu/device.ts +42 -3
  192. package/src/render/backend/webgpu/drawCommand.ts +22 -4
  193. package/src/render/backend/webgpu/flatPass.ts +250 -40
  194. package/src/render/backend/webgpu/instanced.ts +32 -1
  195. package/src/render/backend/webgpu/materialStore.ts +276 -0
  196. package/src/render/backend/webgpu/pipelineCache.ts +7 -0
  197. package/src/render/backend/webgpu/postPass.ts +18 -0
  198. package/src/render/backend/webgpu/reflectionSurfacePass.ts +114 -0
  199. package/src/render/backend/webgpu/renderer.ts +1655 -230
  200. package/src/render/backend/webgpu/skinPaletteRing.ts +13 -7
  201. package/src/render/backend/webgpu/skinPaletteTexture.ts +7 -1
  202. package/src/render/backend/webgpu/staticBundles.ts +363 -0
  203. package/src/render/backend/webgpu/surfaceTexturePass.ts +29 -3
  204. package/src/render/backend/webgpu/uniformRing.ts +10 -1
  205. package/src/render/bloomChain.ts +3 -3
  206. package/src/render/boneAnimation.ts +223 -0
  207. package/src/render/compressedSource.ts +121 -29
  208. package/src/render/displayRange.ts +61 -0
  209. package/src/render/filmicCurve.ts +229 -0
  210. package/src/render/fog.ts +19 -3
  211. package/src/render/frame/resources.ts +6 -0
  212. package/src/render/frameReflections.ts +72 -0
  213. package/src/render/glCompressed.ts +83 -0
  214. package/src/render/instances.ts +27 -0
  215. package/src/render/lightBudget.ts +11 -0
  216. package/src/render/lightmap.ts +1 -1
  217. package/src/render/mesh.ts +6 -0
  218. package/src/render/pass.ts +53 -1
  219. package/src/render/pointLightSelection.ts +4 -4
  220. package/src/render/reflectionSurfaceTargets.ts +105 -0
  221. package/src/render/renderQuality.ts +44 -8
  222. package/src/render/sceneTarget.ts +30 -2
  223. package/src/render/screenSpaceReflection.ts +7 -1
  224. package/src/render/shaders/boneAnimation.ts +63 -0
  225. package/src/render/shaders/depth.ts +45 -10
  226. package/src/render/shaders/filmLook.ts +2 -1
  227. package/src/render/shaders/flat/glassTint.ts +5 -1
  228. package/src/render/shaders/flat/index.ts +49 -5
  229. package/src/render/shaders/flat/main.ts +43 -5
  230. package/src/render/shaders/flat/models.ts +1 -1
  231. package/src/render/shaders/flat/overlay.ts +117 -0
  232. package/src/render/shaders/flat/pointShadow.ts +3 -3
  233. package/src/render/shaders/flat/preamble.ts +38 -24
  234. package/src/render/shaders/flat/reflectionSurface.ts +61 -0
  235. package/src/render/shaders/fog.ts +9 -2
  236. package/src/render/shaders/fringe.ts +59 -0
  237. package/src/render/shaders/generated/arcane.wgsl.ts +1 -1
  238. package/src/render/shaders/generated/bolt.wgsl.ts +1 -1
  239. package/src/render/shaders/generated/caustics.wgsl.ts +1 -1
  240. package/src/render/shaders/generated/depth.wgsl.ts +95 -0
  241. package/src/render/shaders/generated/film.wgsl.ts +1 -1
  242. package/src/render/shaders/generated/fire.wgsl.ts +1 -1
  243. package/src/render/shaders/generated/flat.wgsl.ts +3292 -2957
  244. package/src/render/shaders/generated/line.wgsl.ts +1 -1
  245. package/src/render/shaders/generated/particle.wgsl.ts +4 -4
  246. package/src/render/shaders/generated/rush.wgsl.ts +56 -26
  247. package/src/render/shaders/generated/scatter.wgsl.ts +1 -1
  248. package/src/render/shaders/generated/smoke.wgsl.ts +1 -1
  249. package/src/render/shaders/generated/ssrResolve.wgsl.ts +30 -0
  250. package/src/render/shaders/generated/ssrTrace.wgsl.ts +22 -2
  251. package/src/render/shaders/generated/water.wgsl.ts +1 -1
  252. package/src/render/shaders/gpudriven/fog.wgsl.ts +11 -3
  253. package/src/render/shaders/outputTransform.ts +30 -14
  254. package/src/render/shaders/rush.ts +54 -11
  255. package/src/render/shaders/ssrResolve.ts +52 -0
  256. package/src/render/shaders/ssrTrace.ts +26 -0
  257. package/src/render/shaders/vertexChannel.ts +27 -0
  258. package/src/render/ssrPass.ts +138 -1
  259. package/src/render/staticDraws.ts +95 -0
  260. package/src/render/surfaceOverlay.ts +195 -0
  261. package/src/render/surfaceTexture.ts +161 -27
  262. package/src/render/temporalAa.ts +20 -0
  263. package/src/render/vertexDefaults.ts +28 -0
@@ -26,6 +26,10 @@ export const MAIN_GLSL = `void main() {
26
26
  vec2 fxDx = dFdx(surfaceAt.xy);
27
27
  vec2 fxDy = dFdy(surfaceAt.xy);
28
28
  if (uWriteMode.y != 0.0 && !ditherKeeps(uWriteMode.y)) discard;
29
+ /* A draw's dissolve cuts the surface away before anything is shaded: overlay.ts. */
30
+ if (SURFACE_OVERLAY) {
31
+ if (overlayCuts(surfaceAt.xy)) discard;
32
+ }
29
33
 
30
34
  /*
31
35
  * Surface colour and its coverage, resolved before anything else — including before it is
@@ -78,7 +82,7 @@ export const MAIN_GLSL = `void main() {
78
82
  */
79
83
  float share = cutoutShare(tested, uCutout.x);
80
84
  if (uCutout.y == 1.0) {
81
- if (!cutoutKeeps(share, gl_FragCoord.xy, uCutout.z)) discard;
85
+ if (!cutoutKeeps(share, gl_FragCoord.xy, uHighlightMin.w)) discard;
82
86
  kept = 1.0;
83
87
  } else {
84
88
  kept = share;
@@ -140,6 +144,11 @@ export const MAIN_GLSL = `void main() {
140
144
  }
141
145
 
142
146
  vec3 lit = albedo;
147
+ /* How much of the environment the frame shows here, and how a found reflection would land:
148
+ reflectionSurface.ts. None where nothing is reflected. */
149
+ vec3 reflectedProbe = vec3(0.0);
150
+ vec3 reflectedTint = vec3(0.0);
151
+ float reflectedRoughness = 1.0;
143
152
  /* Skin's diffuse, held before emission for the screen-space blur's own pass: models.ts. */
144
153
  vec3 diffuseAlone = vec3(0.0);
145
154
  /* The light arriving at a glass pane from behind it, gathered in each light loop below and added
@@ -187,7 +196,10 @@ export const MAIN_GLSL = `void main() {
187
196
  * right: a mipped colour image, sampled under uniform control flow, exactly as uAlbedo is
188
197
  * below. The rule is about non-uniform branches, and this branch is on a uniform.
189
198
  */
199
+ vec3 unmapped = n;
190
200
  if (uNormalStrength > 0.0) n = normalMapped(n, surfaceAt);
201
+ /* A draw's wrinkles, by region, over whatever the map made: overlay.ts. */
202
+ if (SURFACE_OVERLAY) n = overlayWrinkle(n, unmapped, surfaceAt.xy);
191
203
 
192
204
  /*
193
205
  * Microscopic relief: the surface's own texture, as a turn of the normal rather than a change
@@ -916,6 +928,15 @@ export const MAIN_GLSL = `void main() {
916
928
  environment * mix(vec3(1.0), albedo, metal),
917
929
  weight
918
930
  );
931
+ reflectedTint = mix(vec3(1.0), albedo, metal) * weight;
932
+ reflectedProbe = environment * reflectedTint;
933
+ reflectedRoughness = surfaceRoughness;
934
+ }
935
+ /* The reflection pass's surface half leaves here, before the lamps: reflectionSurface.ts. */
936
+ if (REFLECTION_SURFACE) {
937
+ reflectionSurfaceOut(reflectedProbe, reflectedTint, reflectedRoughness, ormOcclusion,
938
+ reflectionAir());
939
+ return;
919
940
  }
920
941
  /*
921
942
  * The sun's highlight, on top of whatever the surface reflects rather than underneath it —
@@ -1260,7 +1281,7 @@ export const MAIN_GLSL = `void main() {
1260
1281
  */
1261
1282
  float falloff;
1262
1283
  /*
1263
- * **A light may name its own falloff, and then it is Unreal's for a light without
1284
+ * **A light may name its own falloff, and then it is the usual one for a light without
1264
1285
  * inverse-square falloff**: \`(1 - (d/R)^2)^n\` with no distance term, so a fill authored to
1265
1286
  * light a whole hall across a hundred metres does, where the inverse square would have it
1266
1287
  * gone a few metres out. Zero is the frame's own rule below, which every light was before.
@@ -1940,6 +1961,9 @@ export const MAIN_GLSL = `void main() {
1940
1961
  * mix(1.0, min(lightShade, sunShade), EMISSIVE_SHADOW_SHARE) * fxGlow;
1941
1962
  /* And a lit window's glow, which the scene's lit share already times: not gated on night. */
1942
1963
  lit += windowGlow * uEmission.x;
1964
+ /* And a draw's overlay: its rim, its dissolve's band and the colour laid over. Not gated on the
1965
+ night, as emission is: a glow the surface wears rather than light it gives off. overlay.ts. */
1966
+ if (SURFACE_OVERLAY) lit += overlayGlow(surfaceAt.xy, n);
1943
1967
 
1944
1968
  #if NIGHT_EMISSIVE
1945
1969
  /*
@@ -1973,7 +1997,7 @@ export const MAIN_GLSL = `void main() {
1973
1997
  // finishing a run reads the same at noon and at midnight. Costs one compare
1974
1998
  // per fragment and no extra draw call — the box is a uniform, not geometry.
1975
1999
  if (uHighlightMax.w > 0.0) {
1976
- vec3 inside = step(uHighlightMin, vWorldPos) * step(vWorldPos, uHighlightMax.xyz);
2000
+ vec3 inside = step(uHighlightMin.xyz, vWorldPos) * step(vWorldPos, uHighlightMax.xyz);
1977
2001
  lit += albedo * uHighlightMax.w * inside.x * inside.y * inside.z;
1978
2002
  }
1979
2003
  }
@@ -2077,7 +2101,17 @@ export const MAIN_GLSL = `void main() {
2077
2101
  vec3 refractV = normalize(uCameraPos - vWorldPos);
2078
2102
  ivec2 snapSize = textureSize(uRefractScene, 0);
2079
2103
  vec2 screenUv = gl_FragCoord.xy / vec2(snapSize);
2080
- vec2 bent = clamp(screenUv + refractN.xy * uSeeThrough.x, vec2(0.0), vec2(1.0));
2104
+ /*
2105
+ * **The normal's sideways part as the eye sees it**: the shading normal in view space, its x
2106
+ * and y across the screen, y turned to the way this frame's rows run (w of the tint). It was the
2107
+ * normal's world x and y until 4.10.0, which on a quad facing the camera is the quad's own lean
2108
+ * against the world's axes: one offset over the whole quad, a lens, with a normal map's tilt a
2109
+ * small change on top. In view space a quad facing the eye bends by nothing but its map, which
2110
+ * is a shimmer, and a pane bends by how it leans toward the eye wherever the eye stands.
2111
+ */
2112
+ vec3 seenN = mat3(uView) * refractN;
2113
+ vec2 bend = vec2(seenN.x, seenN.y * uRefractTint.w);
2114
+ vec2 bent = clamp(screenUv + bend * uSeeThrough.x, vec2(0.0), vec2(1.0));
2081
2115
  /*
2082
2116
  * **An explicit level, and frost is what picks it** — the 2026-08-07 rule, and the reason a
2083
2117
  * frosted pane blurs rather than fades: the copy carries a mip chain on a frame that draws glass,
@@ -2091,7 +2125,7 @@ export const MAIN_GLSL = `void main() {
2091
2125
  /* Unsigned: a pane passes the same light seen from either side, and so does its Fresnel. */
2092
2126
  float cosView = max(abs(dot(refractN, refractV)), 0.05);
2093
2127
  float pathLength = uSeeThrough.y * vThickness / cosView;
2094
- vec3 seen = behind * pow(uRefractTint, vec3(pathLength));
2128
+ vec3 seen = behind * pow(uRefractTint.rgb, vec3(pathLength));
2095
2129
  if (glassTransmission > 0.0) {
2096
2130
  /*
2097
2131
  * **Glass keeps its own surface and shows what is behind over it**, by how much it lets
@@ -2138,6 +2172,10 @@ export const MAIN_GLSL = `void main() {
2138
2172
  return;
2139
2173
  }
2140
2174
 
2175
+ /* WebGL2's frame writes the reflection maps itself, with the fog already reckoned above. */
2176
+ if (REFLECTION_MAPS) {
2177
+ reflectionSurfaceOut(reflectedProbe, reflectedTint, reflectedRoughness, ormOcclusion, fog);
2178
+ }
2141
2179
  outColor = vec4(shaded, alpha);
2142
2180
  }
2143
2181
  `;
@@ -59,7 +59,7 @@ const bool PHYSICAL_SPECULAR = PHYSICAL_SPECULAR_ON; // wgsl:override
59
59
  * A model's numbers, two vectors a material — the lit stage's uniform budget has no more room
60
60
  * (surfaceModel.ts) — and whether a model map is bound, in the last component.
61
61
  */
62
- uniform vec4 uModelParams[2];
62
+ uniform vec4 uModelParams[2]; // wgsl:material
63
63
  /* The model's own channels, in the albedo's layout: what each means is each model's to say. */
64
64
  uniform highp sampler2DArray uModelMap;
65
65
 
@@ -0,0 +1,117 @@
1
+ /**
2
+ * A draw's surface overlay in the lit stage: the rim, the dissolve and the wrinkles
3
+ * `surfaceOverlay.ts` packs into `uOverlay`. Called from `main` at three places — the dissolve's cut
4
+ * before anything is shaded, the wrinkles after the normal map, and the glow beside emission.
5
+ *
6
+ * **A lit switch, `SURFACE_OVERLAY`**, off until a draw first sets an overlay and then on for good,
7
+ * as `litSwitchesGlsl`'s are; declared after the models so every switch before it keeps its id.
8
+ * Compiled out, the three calls are stubs and the fifteen vectors are not declared at all, which is
9
+ * what lets WebGL2 build a lit program without them on a device that has no room.
10
+ *
11
+ * **Images come from the atlas bound where the frame's refraction copy goes**, which an opaque draw
12
+ * never reads; a draw that refracts or is glass reads that copy there, so its overlay reads no image
13
+ * (`overlayImagesBound`). Each image is read by `textureLod` at level 0: several are reached under a
14
+ * branch on a per-pixel value, and the atlas carries no chain anyway.
15
+ */
16
+ export function overlayGlsl(on: boolean): string {
17
+ if (!on) {
18
+ return /* glsl */ `
19
+ const bool SURFACE_OVERLAY = false; // wgsl:override
20
+ bool overlayCuts(vec2 uv) { return false; }
21
+ vec3 overlayWrinkle(vec3 mapped, vec3 unmapped, vec2 uv) { return mapped; }
22
+ vec3 overlayGlow(vec2 uv, vec3 n) { return vec3(0.0); }
23
+ `;
24
+ }
25
+ return /* glsl */ `
26
+ /* Whether this program carries a draw's overlay. Off but where one has been set: overlay.ts. */
27
+ const bool SURFACE_OVERLAY = true; // wgsl:override
28
+ /* The overlay's fifteen vectors; packSurfaceOverlay in surfaceOverlay.ts says what each holds. */
29
+ uniform vec4 uOverlay[15]; // wgsl:material
30
+
31
+ /* Whether the atlas is what the refraction slot holds: not where this draw refracts or is glass. */
32
+ bool overlayImagesBound() {
33
+ return uSeeThrough.x <= 0.0 && uSeeThrough.z <= 0.0;
34
+ }
35
+
36
+ /* One image of the atlas at uv, repeated within its region; zero where the region has no size. */
37
+ vec4 overlayImage(vec4 region, vec2 uv) {
38
+ if (region.x <= 0.0) return vec4(0.0);
39
+ return textureLod(uRefractScene, region.zw + fract(uv) * region.xy, 0.0);
40
+ }
41
+
42
+ /* The dissolve's noise at uv, and whether the draw dissolves at all: -1 where it does not. */
43
+ float overlayDissolveNoise(vec2 uv) {
44
+ if (uOverlay[6].x <= 0.0 || uOverlay[7].z <= 0.0) return -1.0;
45
+ if (!overlayImagesBound()) return -1.0;
46
+ return overlayImage(uOverlay[6], uv * uOverlay[7].xy).r;
47
+ }
48
+
49
+ /* Whether the dissolve cuts this fragment away: where its noise is under the threshold, or all of
50
+ it at a threshold of 1. */
51
+ bool overlayCuts(vec2 uv) {
52
+ float noise = overlayDissolveNoise(uv);
53
+ if (noise < 0.0) return false;
54
+ return noise < uOverlay[7].z || uOverlay[7].z >= 1.0;
55
+ }
56
+
57
+ /*
58
+ * The wrinkle normal blended into the mapped one by the two masks' channels times the six weights,
59
+ * in the frame the normal map is read in. **Under uniform control flow up to the frame**, which
60
+ * takes derivatives: every branch before it is on the overlay's numbers alone, and the weight a
61
+ * pixel takes is a mix rather than a branch.
62
+ */
63
+ vec3 overlayWrinkle(vec3 mapped, vec3 unmapped, vec2 uv) {
64
+ if (uOverlay[10].x <= 0.0 || !overlayImagesBound()) return mapped;
65
+ mat3 tbn = tangentFrame(unmapped, vWorldPos, vUv.xy, vTangent, vHasTangents);
66
+ vec3 a = overlayImage(uOverlay[11], uv).rgb;
67
+ vec3 b = overlayImage(uOverlay[12], uv).rgb;
68
+ float weight = clamp(
69
+ dot(a, uOverlay[13].xyz) + dot(b, vec3(uOverlay[13].w, uOverlay[14].xy)), 0.0, 1.0);
70
+ vec3 wrinkle = overlayImage(uOverlay[10], uv).xyz * 2.0 - 1.0;
71
+ /* z rebuilt where none is stored, as normalMapped does: see normalMap.ts. */
72
+ wrinkle.z = wrinkle.z > 0.0 ? wrinkle.z : sqrt(max(0.0, 1.0 - dot(wrinkle.xy, wrinkle.xy)));
73
+ return normalize(mix(mapped, normalize(tbn * wrinkle), weight));
74
+ }
75
+
76
+ /*
77
+ * The rim's place on the screen, 0 to 1 up its height and its width in the same units: from view
78
+ * space and the projection's tangent, not from gl_FragCoord, whose y runs up on one backend and
79
+ * down on the other (the 2026-08-17 rule), and whose scale is a render target's, not the screen's.
80
+ */
81
+ vec2 overlayScreen() {
82
+ vec4 eye = uView * vec4(vWorldPos, 1.0);
83
+ float depth = max(-eye.z, 1e-4) * uClusterFrustum.z;
84
+ return vec2(eye.x / depth + uClusterFrustum.w, eye.y / depth + 1.0) * 0.5;
85
+ }
86
+
87
+ /* What the overlay adds to the light the surface gives off: the dissolve's band, the colour laid
88
+ over through its noise, and the rim. Zero where the draw sets none of them. */
89
+ vec3 overlayGlow(vec2 uv, vec3 n) {
90
+ vec3 glow = vec3(0.0);
91
+ float noise = overlayDissolveNoise(uv);
92
+ if (noise >= 0.0) {
93
+ float band = 1.0 - clamp((noise - uOverlay[7].z) / uOverlay[7].w, 0.0, 1.0);
94
+ glow += uOverlay[8].rgb * uOverlay[8].w * band + uOverlay[9].rgb * uOverlay[9].w * noise;
95
+ }
96
+ float strength = uOverlay[0].w;
97
+ if (strength > 0.0) {
98
+ vec3 toEye = normalize(uCameraPos - vWorldPos);
99
+ float edge = pow(1.0 - clamp(dot(n, toEye), 0.0, 1.0), max(uOverlay[1].x, 1e-4));
100
+ float up = pow(clamp(n.y * 0.5 + 0.5, 0.0, 1.0), max(uOverlay[1].y, 1e-4));
101
+ float rim = pow(edge * up, max(uOverlay[1].z, 1e-4));
102
+ float time = uSurfaceScene.x;
103
+ if (uOverlay[2].x > 0.0 && overlayImagesBound()) {
104
+ vec2 at = overlayScreen() * uOverlay[3].z + uOverlay[3].xy * time;
105
+ rim *= overlayImage(uOverlay[2], at).r;
106
+ }
107
+ rim = min(rim, 1.0);
108
+ rim *= mix(uOverlay[4].x, uOverlay[4].y, 0.5 + 0.5 * sin(uOverlay[3].w * time));
109
+ if (uOverlay[5].x > 0.0 && overlayImagesBound()) {
110
+ rim *= 1.0 - uOverlay[1].w * overlayImage(uOverlay[5], uv).r;
111
+ }
112
+ glow += uOverlay[0].rgb * strength * rim;
113
+ }
114
+ return glow;
115
+ }
116
+ `;
117
+ }
@@ -13,7 +13,7 @@
13
13
  * picture and is its own change.
14
14
  */
15
15
  import { MAX_SHADOW_FILTER_TAPS } from '../../renderQuality.ts';
16
- import { OUTPUT_TRANSFORM_GLSL } from '../outputTransform.ts';
16
+ import { LIT_OUTPUT_TRANSFORM_GLSL } from '../outputTransform.ts';
17
17
  import { LAMP_GLASS_GLSL } from './lampGlass.ts';
18
18
 
19
19
  export const POINTSHADOW_GLSL = `/**
@@ -342,9 +342,9 @@ float areaShadow(
342
342
  ${LAMP_GLASS_GLSL}
343
343
  #endif
344
344
 
345
- out vec4 outColor;
345
+ layout(location = 0) out vec4 outColor;
346
346
 
347
- ${OUTPUT_TRANSFORM_GLSL}
347
+ ${LIT_OUTPUT_TRANSFORM_GLSL}
348
348
 
349
349
  /**
350
350
  * A fixed Poisson disk avoids the grid-shaped edge left by square 3x3 PCF.
@@ -121,9 +121,15 @@ uniform sampler2D uRefractScene;
121
121
  * gives up, and four separate floats cost half the shadowed lights such a device can have. The tints
122
122
  * stay colours of their own. Zero transmission is not glass — see glass.ts.
123
123
  */
124
- uniform vec4 uSeeThrough;
125
- uniform vec3 uRefractTint;
126
- uniform vec3 uGlassTint;
124
+ uniform vec4 uSeeThrough; // wgsl:material
125
+ /*
126
+ * What a metre of the medium leaves of each channel (rgb), and in w which way this frame's rows run
127
+ * up the screen: +1 where the first row is the bottom (WebGL2), -1 where it is the top (WebGPU). The
128
+ * bend is taken in view space, whose y is up whatever the framebuffer says, so it is turned here to
129
+ * the rows a screen coordinate counts. A vec4 where a vec3 already spent the row.
130
+ */
131
+ uniform vec4 uRefractTint; // wgsl:material
132
+ uniform vec3 uGlassTint; // wgsl:material
127
133
  flat in int vHasTangents;
128
134
 
129
135
  /**
@@ -154,7 +160,7 @@ uniform mediump sampler2DArray uAlbedo;
154
160
  * card. Its draw culls nothing, and a back face is lit as a front, with the shading normal turned
155
161
  * toward the viewer.
156
162
  */
157
- uniform ivec4 uMaterialFlags;
163
+ uniform ivec4 uMaterialFlags; // wgsl:material
158
164
  /**
159
165
  * Alpha below which a textured fragment is thrown away entirely, 0 to disable.
160
166
  *
@@ -168,13 +174,17 @@ uniform ivec4 uMaterialFlags;
168
174
  * else changes.
169
175
  *
170
176
  * **Four numbers in one row**: x is the cutoff, y how this frame resolves the edge (0 the hard test,
171
- * 1 a dither the temporal resolve averages, 2 alpha-to-coverage; see \`cutoutDither.ts\`), z the
172
- * frame the dither's pattern is offset by, w the material's lighting channels — a mask a light
173
- * shades it only where its own shares a bit with (\`SurfaceMaterial.lightChannels\`, 1 unless a
174
- * material names others). One vector rather than a float and three more, because every loose
175
- * scalar is a row of WebGL2's 224 that the light budget gives up.
177
+ * 1 a dither the temporal resolve averages, 2 alpha-to-coverage; see \`cutoutDither.ts\`), z unused,
178
+ * w the material's lighting channels — a mask a light shades it only where its own shares a bit
179
+ * with (\`SurfaceMaterial.lightChannels\`, 1 unless a material names others). One vector rather than
180
+ * a float and three more, because every loose scalar is a row of WebGL2's 224 that the light budget
181
+ * gives up.
182
+ *
183
+ * **z was the frame the dither's pattern is offset by until 4.10.0**, and that made every material
184
+ * new every frame: a material is kept on WebGPU by its numbers, and one of them changed with the
185
+ * clock. The frame is the pass's, in \`uHighlightMin.w\`.
176
186
  */
177
- uniform vec4 uCutout;
187
+ uniform vec4 uCutout; // wgsl:material
178
188
  /**
179
189
  * A draw's own ambient, as nine spherical-harmonic coefficients of incoming radiance, red green blue
180
190
  * in turn, twenty-seven floats, and in the last of the twenty-eight a 1 where they are on — 0 is the
@@ -182,7 +192,7 @@ uniform vec4 uCutout;
182
192
  * and the basis, and its tests hold this to it. Seven rows of the material block, which is per draw
183
193
  * as far as anything here is: \`setAmbientSH\` moves it between two draws as \`setMaterial\` does.
184
194
  */
185
- uniform vec4 uAmbientSH[7];
195
+ uniform vec4 uAmbientSH[7]; // wgsl:material
186
196
 
187
197
  /** The ambient a surface facing \`n\` receives from \`uAmbientSH\`: \`ambientFromSH\`'s arithmetic. */
188
198
  vec3 ambientHarmonics(vec3 n) {
@@ -229,7 +239,7 @@ uniform highp sampler2DArray uNormalMap;
229
239
  * shadow samplers, where a profile with shadows off should declare none of them; it is the wrong
230
240
  * tool for one image on a shader that already declares one.
231
241
  */
232
- uniform float uNormalStrength;
242
+ uniform float uNormalStrength; // wgsl:material
233
243
 
234
244
  /**
235
245
  * Occlusion, roughness and metallic in one image. glTF's packing, because that is what an import
@@ -250,7 +260,7 @@ uniform highp sampler2DArray uOrmMap;
250
260
  * occlusionTexture.strength is: 1 + strength * (texel - 1). A multiply at 0 means fully occluded,
251
261
  * which is the opposite of what a caller asking for no occlusion means.
252
262
  */
253
- uniform vec3 uOrmScale;
263
+ uniform vec3 uOrmScale; // wgsl:material
254
264
  /**
255
265
  * 1 when \`uEnvironment\` holds the GGX-prefiltered cube, 0 when it holds the capture's box chain.
256
266
  *
@@ -266,7 +276,7 @@ uniform vec3 uOrmScale;
266
276
  * (\`uniformVectorBudget.ts\`). y is how much of the environment the material mirrors, z how
267
277
  * bright what it mirrors is.
268
278
  */
269
- uniform vec3 uEnvironmentDials;
279
+ uniform vec3 uEnvironmentDials; // wgsl:material
270
280
 
271
281
  /**
272
282
  * Where a surface glows, and in what colour.
@@ -288,7 +298,7 @@ uniform highp sampler2DArray uEmissiveMap;
288
298
  * The counterpart of \`uOrmScale\`: a factor that multiplies a texture is not a value, and this is
289
299
  * where the multiplier lives once an image supplies the shape.
290
300
  */
291
- uniform vec3 uEmissiveScale;
301
+ uniform vec3 uEmissiveScale; // wgsl:material
292
302
 
293
303
  #if DIRECTIONAL_SHADOWS
294
304
  /*
@@ -375,7 +385,7 @@ uniform vec4 uSurfaceScene;
375
385
  * draw moves it), y the night factor emission is gated on. One row where two floats were two
376
386
  * (\`uniformVectorBudget.ts\`).
377
387
  */
378
- uniform vec2 uEmission;
388
+ uniform vec2 uEmission; // wgsl:material
379
389
  #if NIGHT_EMISSIVE
380
390
  /**
381
391
  * Emission that only shows where the dominant light does not reach. 0 is off and is the default.
@@ -400,7 +410,7 @@ uniform float uNightEmissive;
400
410
  * of that to change one channel is how a renderer ends up with two shaders that
401
411
  * disagree about the sun. The caller owns the blend state; this owns the number.
402
412
  */
403
- uniform float uOpacity;
413
+ uniform float uOpacity; // wgsl:material
404
414
 
405
415
  /**
406
416
  * Two per-draw switches on how a fragment is *written* rather than what colour it is, sharing one
@@ -432,7 +442,7 @@ uniform float uOpacity;
432
442
  * crossfade reads as grain for as long as it lasts, which is why it should be short; and a blended
433
443
  * draw that asks for it is dithered too, since the test is a discard.
434
444
  */
435
- uniform vec2 uWriteMode;
445
+ uniform vec2 uWriteMode; // wgsl:material
436
446
 
437
447
  /** Whether this fragment is one \`uWriteMode.y\` keeps. Integer arithmetic, per the device rule. */
438
448
  bool ditherKeeps(float amount) {
@@ -465,7 +475,7 @@ bool ditherKeeps(float amount) {
465
475
  * one uniform skips the untaken side rather than computing both and discarding one, which is
466
476
  * only true because nothing here reads it through a *varying*-dependent branch.
467
477
  */
468
- uniform int uLightingEnabled;
478
+ uniform int uLightingEnabled; // wgsl:material
469
479
  /**
470
480
  * How this draw meets the medium: the atmospheric haze and the underwater tint both, folded
471
481
  * together because both are the *camera's* medium rather than a property of the surface — see
@@ -487,7 +497,7 @@ uniform int uLightingEnabled;
487
497
  * is what "exactly as its colour says" has to mean for it; the cost is that such a draw will
488
498
  * not tint if the camera goes under water, unlike everything else in the frame.
489
499
  */
490
- uniform int uFogEnabled;
500
+ uniform int uFogEnabled; // wgsl:material
491
501
 
492
502
  /**
493
503
  * A pass-level scale over the grain the geometry declared, 0 to 1.
@@ -497,7 +507,7 @@ uniform int uFogEnabled;
497
507
  * imported model that declares nothing is drawn with the pass's own answer, and a scene
498
508
  * can dial a whole draw down without rebuilding its geometry.
499
509
  */
500
- uniform float uGrain;
510
+ uniform float uGrain; // wgsl:material
501
511
  /*
502
512
  * The material's own relief: how strong, and how many bumps to a metre.
503
513
  *
@@ -506,7 +516,7 @@ uniform float uGrain;
506
516
  * between them, and the geometry carrying them is identical in all three cases. See
507
517
  * Renderer.setSurfaceRelief. x is the strength and y the bumps to a metre, in one row.
508
518
  */
509
- uniform vec2 uRelief;
519
+ uniform vec2 uRelief; // wgsl:material
510
520
  /**
511
521
  * How hard the bound surface texture's own luminance turns the shading normal, 0 for not at all.
512
522
  *
@@ -529,7 +539,7 @@ uniform vec2 uRelief;
529
539
  * 0..1 like its neighbours for the same reason: this is an amplitude against a luminance
530
540
  * gradient, not a fraction of anything.
531
541
  */
532
- uniform float uTextureRelief;
542
+ uniform float uTextureRelief; // wgsl:material
533
543
 
534
544
  /**
535
545
  * How much of the environment this material mirrors, 0 to 1.
@@ -664,8 +674,12 @@ uniform vec3 uProbeGridSets;
664
674
  /**
665
675
  * A world-space box that lights up regardless of time of day: its corners, and in the far corner's
666
676
  * w the gain — one row where a loose float was another (\`uniformVectorBudget.ts\`).
677
+ *
678
+ * **And in the near corner's w the frame the cutout dither's pattern is offset by**, for the same
679
+ * reason: a row the lit stage already pays for, holding a number the pass sets and no material does.
680
+ * See \`uCutout\`.
667
681
  */
668
- uniform vec3 uHighlightMin;
682
+ uniform vec4 uHighlightMin;
669
683
  uniform vec4 uHighlightMax;
670
684
 
671
685
  /*
@@ -0,0 +1,61 @@
1
+ /**
2
+ * What the lit stage leaves for a reflection traced in the frame: how much of the environment each
3
+ * pixel shows, and how a reflection found in the frame would land there instead. Read by the
4
+ * reflection pass (`screenSpaceReflection.ts`), which swaps the one for the other where its ray
5
+ * finds something.
6
+ *
7
+ * **The swap is exact because the lit stage's own blend is a mix**: `lit = mix(lit, environment ·
8
+ * tint, weight)` leaves `environment · tint · weight` of the probe in the frame, and a reflection
9
+ * found in the frame belongs there with the same tint and the same weight. So the frame gains
10
+ * `(found · tint − environment · tint) · weight` and nothing else moves: the diffuse the blend
11
+ * already took its share from keeps it. Both are carried the rest of the way the shaded colour
12
+ * goes — the occlusion, the water and the medium in front of the surface — so the swap lands in the
13
+ * frame's own units.
14
+ *
15
+ * **Two outputs beside the colour, written by every lit draw and kept only where a target is
16
+ * bound.** WebGL2 binds them during opaque lit draws alone; WebGPU's frame pass binds none, and a
17
+ * second pass replays the frame's opaque draws into them with `REFLECTION_SURFACE` on, which leaves
18
+ * before the lamps (`main`). What it gives up is a vector of arithmetic on every lit pixel whether
19
+ * or not anything reads it.
20
+ */
21
+ export function reflectionSurfaceGlsl(maps: boolean): string {
22
+ return /* glsl */ `
23
+ /*
24
+ * Whether this pipeline is the reflection pass's surface half: the frame's opaque draws again,
25
+ * against the depth they wrote, leaving the two outputs below and no light. Off in every other
26
+ * pipeline, and set from the key as skin's halves are. See reflectionSurface.ts.
27
+ */
28
+ const bool REFLECTION_SURFACE = false; // wgsl:override
29
+ /*
30
+ * Whether the frame's own draws write the two outputs as well: WebGL2's arrangement, on where the
31
+ * frame's materials' reflections are, and off in every WebGPU pipeline, which replays the draws
32
+ * instead. A lit switch, so a program that does not write them carries nothing live across the
33
+ * lamps for them.
34
+ */
35
+ const bool REFLECTION_MAPS = ${maps ? 'true' : 'false'}; // wgsl:override
36
+ /* The environment as the frame shows it, and the surface's roughness in w. */
37
+ layout(location = 1) out vec4 outReflectedProbe;
38
+ /* What a reflection found in the frame is multiplied by to land where the environment did. */
39
+ layout(location = 2) out vec4 outReflectedTint;
40
+
41
+ /* How much of the surface the medium in front of it leaves: the fog block below's own measure. */
42
+ float reflectionAir() {
43
+ return uFogEnabled != 0 ? mediumFog(distance(vWorldPos, uCameraPos), vWorldPos.y) : 0.0;
44
+ }
45
+
46
+ /*
47
+ * The two outputs, carried through what the shaded colour meets after the blend: its occlusion,
48
+ * the water, and the air, as \`main\` applies them. \`air\` is the fog the caller has already
49
+ * reckoned, so the frame's own draws pay for it once.
50
+ */
51
+ void reflectionSurfaceOut(vec3 probe, vec3 tint, float roughness, float occlusion, float air) {
52
+ vec3 keep = vec3(occlusion * (1.0 - air));
53
+ if (uFogEnabled != 0) {
54
+ vec3 waterTransmission = vec3(0.42) + uUnderwaterColor * 2.0;
55
+ keep *= mix(vec3(1.0), waterTransmission, uUnderwaterFactor * 0.55);
56
+ }
57
+ outReflectedProbe = vec4(probe * keep, roughness);
58
+ outReflectedTint = vec4(tint * keep, 1.0);
59
+ }
60
+ `;
61
+ }
@@ -85,11 +85,18 @@ float mediumFog(float dist, float pointY) {
85
85
  return mix(ramp, 1.0 - exp2(-wetLinear * wetLinear * 1.442695), uUnderwaterFactor);
86
86
  }
87
87
 
88
+ // Where the medium begins along the ray: uFogNear, the linear mode's slot, which this mode
89
+ // never read before Atmosphere.fogStart. The ray is integrated from there on, at the density
90
+ // of that point; at a start of 0 every term is the one it always was. See render/fog.ts.
91
+ float start = min(uFogNear, dist);
92
+ float before = dist > 0.0 ? start / dist : 0.0;
88
93
  float t = (pointY - uFogEyeY) * uFogHeightFalloff;
94
+ float rest = t * (1.0 - before);
89
95
  // (1 - e^-t)/t, which tends to 1 as the ray levels out. Guarded rather than
90
96
  // branched: at t = 0 the quotient is 0/0, and 1e-4 of a scale height is 8 mm.
91
- float denom = abs(t) < 1e-4 ? 1e-4 : t;
92
- float air = 1.0 - exp(-uFogDensity * dist * (1.0 - exp(-denom)) / denom);
97
+ float denom = abs(rest) < 1e-4 ? 1e-4 : rest;
98
+ float air =
99
+ 1.0 - exp(-uFogDensity * exp(-t * before) * (dist - start) * (1.0 - exp(-denom)) / denom);
93
100
  if (uUnderwaterFactor <= 0.0) return air;
94
101
  // Water is its own medium and keeps its own curve, so crossing the surface
95
102
  // changes nothing about how the water column reads.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Chromatic aberration: a lens bending each colour by its own amount, so red and green land a
3
+ * little nearer the centre than blue toward the frame's edges.
4
+ *
5
+ * **Linear in wavelength, from an offset outward.** A simple lens's dispersion is close to linear
6
+ * in wavelength over the visible range, so red (611 nm) and green (549 nm) are pulled toward the
7
+ * centre by their distance from blue (464 nm), which is drawn where it is. Nothing moves inside
8
+ * `start` — a share of the half-frame, 0 at the centre — and the pull grows linearly past it,
9
+ * scaled so that the frame's edge takes the whole of `intensity`, which is a percentage.
10
+ *
11
+ * **What it gives up**: it re-reads the scene at the composite's first sample, so the camera's
12
+ * motion blur and the depth of field, which re-read the scene themselves, carry less of the fringe
13
+ * where they are strong. A pass of its own after both would carry it whole, at a full-frame read
14
+ * and write a frame. **What would make that wrong** is a game that blurs heavily and fringes
15
+ * heavily at once, where the colour edges would be seen to soften with the blur.
16
+ */
17
+
18
+ /** How many floats `resolveFringe` fills: the red pull, the green pull, and where they begin. */
19
+ export const FRINGE_FLOATS = 3;
20
+
21
+ /** The primaries' wavelengths, nanometres. */
22
+ const RED_NM = 611.3;
23
+ const GREEN_NM = 549.1;
24
+ const BLUE_NM = 464.3;
25
+ /** The lens's dispersion per nanometre, the constant that makes `intensity` a percentage. */
26
+ const PER_NM = 0.007;
27
+
28
+ /**
29
+ * The fringe's three numbers, into `out`: how far red and green are pulled toward the centre at
30
+ * the frame's edge, as a share of the half-frame, and the start offset. `intensity` 0 or below is
31
+ * none; a start of 1 or more is none too, since nothing then lies past it. Not finite is none.
32
+ */
33
+ export function resolveFringe(intensity: number, start: number, out: Float32Array): void {
34
+ const at = Number.isFinite(start) ? Math.min(Math.max(start, 0), 1) : 0;
35
+ const amount = Number.isFinite(intensity) && intensity > 0 && at < 1 ? intensity * 0.01 : 0;
36
+ /* Divided only where there is something to divide: at a start of 1 this is 0 over 0. */
37
+ const reach = amount > 0 ? amount / (1 - at) : 0;
38
+ out[0] = reach * PER_NM * (RED_NM - BLUE_NM);
39
+ out[1] = reach * PER_NM * (GREEN_NM - BLUE_NM);
40
+ out[2] = at;
41
+ }
42
+
43
+ /**
44
+ * `withFringe(scene)`: the scene's colour with red and green read again where the lens put them.
45
+ * Reads `uScene` and `vUv`, which the including stage declares, and `uFringe`, which this declares.
46
+ */
47
+ export const FRINGE_GLSL = `
48
+ /** Red's and green's pull at the frame's edge, and where it begins: see shaders/fringe.ts. */
49
+ uniform vec3 uFringe;
50
+
51
+ vec3 withFringe(vec3 scene) {
52
+ if (uFringe.x <= 0.0) return scene;
53
+ vec2 lens = vUv * 2.0 - 1.0;
54
+ vec2 past = sign(lens) * clamp(abs(lens) - uFringe.z, 0.0, 1.0);
55
+ vec2 red = (lens - past * uFringe.x) * 0.5 + 0.5;
56
+ vec2 green = (lens - past * uFringe.y) * 0.5 + 0.5;
57
+ return vec3(textureLod(uScene, red, 0.0).r, textureLod(uScene, green, 0.0).g, scene.b);
58
+ }
59
+ `;
@@ -5,7 +5,7 @@
5
5
  * the next generation, and `npm run wgsl:check` fails the build when this is stale.
6
6
  */
7
7
 
8
- export const ARCANE_FRAG_WGSL = "struct Uniforms {\n uTime: f32,\n uFogColor: vec3<f32>,\n uFogDensity: f32,\n uFogHeightFalloff: f32,\n uFogEyeY: f32,\n uUnderwaterColor: vec3<f32>,\n uUnderwaterFogDensity: f32,\n uUnderwaterFactor: f32,\n uFogMode: i32,\n uFogNear: f32,\n uFogFar: f32,\n uNoiseOctaves: i32,\n uClipPlane: vec4<f32>,\n uClipEnabled: i32,\n uTint: vec3<f32>,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vWorldPos_1: vec3<f32>;\nvar<private> vUv_1: vec2<f32>;\nvar<private> vSeed_1: f32;\nvar<private> vDistance_1: f32;\nvar<private> outColor: vec4<f32>;\n\nfn mediumColor_u0028_() -> vec3<f32> {\n let _e59 = unnamed.uFogColor;\n let _e61 = unnamed.uUnderwaterColor;\n let _e63 = unnamed.uUnderwaterFactor;\n return mix(_e59, _e61, vec3(_e63));\n}\n\nfn mediumFog_u0028_f1_u003b_f1_u003b(dist: ptr<function, f32>, pointY: ptr<function, f32>) -> f32 {\n var span: f32;\n var ramp: f32;\n var wetLinear: f32;\n var t: f32;\n var denom: f32;\n var air: f32;\n var wet: f32;\n\n let _e68 = unnamed.uFogMode;\n if (_e68 == 1i) {\n let _e71 = unnamed.uFogFar;\n let _e73 = unnamed.uFogNear;\n span = max((_e71 - _e73), 0.0001f);\n let _e76 = (*dist);\n let _e78 = unnamed.uFogNear;\n let _e80 = span;\n ramp = clamp(((_e76 - _e78) / _e80), 0f, 1f);\n let _e84 = unnamed.uUnderwaterFactor;\n if (_e84 <= 0f) {\n let _e86 = ramp;\n return _e86;\n }\n let _e88 = unnamed.uUnderwaterFogDensity;\n let _e89 = (*dist);\n wetLinear = (_e88 * _e89);\n let _e91 = ramp;\n let _e92 = wetLinear;\n let _e94 = wetLinear;\n let _e100 = unnamed.uUnderwaterFactor;\n return mix(_e91, (1f - exp2(((-(_e92) * _e94) * 1.442695f))), _e100);\n }\n let _e102 = (*pointY);\n let _e104 = unnamed.uFogEyeY;\n let _e107 = unnamed.uFogHeightFalloff;\n t = ((_e102 - _e104) * _e107);\n let _e109 = t;\n let _e112 = t;\n denom = select(_e112, 0.0001f, (abs(_e109) < 0.0001f));\n let _e115 = unnamed.uFogDensity;\n let _e117 = (*dist);\n let _e119 = denom;\n let _e124 = denom;\n air = (1f - exp((((-(_e115) * _e117) * (1f - exp(-(_e119)))) / _e124)));\n let _e129 = unnamed.uUnderwaterFactor;\n if (_e129 <= 0f) {\n let _e131 = air;\n return _e131;\n }\n let _e133 = unnamed.uUnderwaterFogDensity;\n let _e134 = (*dist);\n wet = (_e133 * _e134);\n let _e136 = air;\n let _e137 = wet;\n let _e139 = wet;\n let _e145 = unnamed.uUnderwaterFactor;\n return mix(_e136, (1f - exp2(((-(_e137) * _e139) * 1.442695f))), _e145);\n}\n\nfn hash21_u0028_vf2_u003b(p: ptr<function, vec2<f32>>) -> f32 {\n let _e59 = (*p);\n return fract((sin(dot(_e59, vec2<f32>(127.1f, 311.7f))) * 43758.547f));\n}\n\nfn valueNoise_u0028_vf2_u003b(p_1: ptr<function, vec2<f32>>) -> f32 {\n var i: vec2<f32>;\n var f: vec2<f32>;\n var u: vec2<f32>;\n var param: vec2<f32>;\n var param_1: vec2<f32>;\n var param_2: vec2<f32>;\n var param_3: vec2<f32>;\n\n let _e66 = (*p_1);\n i = floor(_e66);\n let _e68 = (*p_1);\n f = fract(_e68);\n let _e70 = f;\n let _e71 = f;\n let _e73 = f;\n u = ((_e70 * _e71) * (vec2(3f) - (_e73 * 2f)));\n let _e78 = i;\n param = _e78;\n let _e79 = hash21_u0028_vf2_u003b((&param));\n let _e80 = i;\n param_1 = (_e80 + vec2<f32>(1f, 0f));\n let _e82 = hash21_u0028_vf2_u003b((&param_1));\n let _e84 = u[0u];\n let _e86 = i;\n param_2 = (_e86 + vec2<f32>(0f, 1f));\n let _e88 = hash21_u0028_vf2_u003b((&param_2));\n let _e89 = i;\n param_3 = (_e89 + vec2<f32>(1f, 1f));\n let _e91 = hash21_u0028_vf2_u003b((&param_3));\n let _e93 = u[0u];\n let _e96 = u[1u];\n return mix(mix(_e79, _e82, _e84), mix(_e88, _e91, _e93), _e96);\n}\n\nfn main_1() {\n var radius: f32;\n var d: vec2<f32>;\n var angle: f32;\n var t_1: f32;\n var inner: f32;\n var param_4: vec2<f32>;\n var outer: f32;\n var param_5: vec2<f32>;\n var swirl: f32;\n var param_6: vec2<f32>;\n var core: f32;\n var corona: f32;\n var body: f32;\n var col: vec3<f32>;\n var alpha: f32;\n var fog: f32;\n var param_7: f32;\n var param_8: f32;\n var phi_237_: bool;\n\n let _e77 = unnamed.uClipEnabled;\n let _e78 = (_e77 != 0i);\n phi_237_ = _e78;\n if _e78 {\n let _e79 = vWorldPos_1;\n let _e85 = unnamed.uClipPlane;\n phi_237_ = (dot(vec4<f32>(_e79.x, _e79.y, _e79.z, 1f), _e85) < 0f);\n }\n let _e89 = phi_237_;\n if _e89 {\n discard;\n }\n let _e90 = vUv_1;\n radius = (length((_e90 - vec2(0.5f))) * 2f);\n let _e95 = radius;\n if (_e95 >= 1f) {\n discard;\n }\n let _e97 = vUv_1;\n d = (_e97 - vec2(0.5f));\n let _e101 = d[1u];\n let _e103 = d[0u];\n angle = atan2(_e101, _e103);\n let _e106 = unnamed.uTime;\n let _e107 = vSeed_1;\n t_1 = (_e106 + (_e107 * 37f));\n let _e110 = angle;\n let _e112 = t_1;\n let _e115 = radius;\n param_4 = vec2<f32>(((_e110 * 1.9f) + (_e112 * 0.55f)), (_e115 * 4.2f));\n let _e118 = valueNoise_u0028_vf2_u003b((&param_4));\n inner = _e118;\n let _e119 = angle;\n let _e121 = t_1;\n let _e124 = radius;\n param_5 = vec2<f32>(((_e119 * 3.1f) - (_e121 * 0.34f)), (_e124 * 2.6f));\n let _e127 = valueNoise_u0028_vf2_u003b((&param_5));\n outer = _e127;\n let _e128 = inner;\n let _e130 = outer;\n swirl = ((_e128 * 0.62f) + (_e130 * 0.38f));\n let _e134 = unnamed.uNoiseOctaves;\n if (_e134 > 1i) {\n let _e136 = swirl;\n let _e137 = swirl;\n let _e138 = angle;\n let _e140 = t_1;\n let _e143 = radius;\n param_6 = vec2<f32>(((_e138 * 6.3f) + (_e140 * 0.9f)), (_e143 * 8f));\n let _e146 = valueNoise_u0028_vf2_u003b((&param_6));\n swirl = mix(_e136, ((_e137 * _e146) * 2f), 0.35f);\n }\n let _e150 = radius;\n core = (1f - smoothstep(0f, 0.28f, _e150));\n let _e153 = radius;\n let _e156 = swirl;\n corona = ((1f - smoothstep(0.18f, 1f, _e153)) * (0.35f + (_e156 * 0.65f)));\n let _e160 = core;\n let _e162 = corona;\n body = ((_e160 * 0.9f) + _e162);\n let _e164 = body;\n if (_e164 <= 0.02f) {\n discard;\n }\n let _e167 = unnamed.uTint;\n let _e170 = unnamed.uTint;\n let _e171 = body;\n col = mix((_e167 * 0.35f), _e170, vec3(smoothstep(0f, 0.55f, _e171)));\n let _e175 = col;\n let _e176 = body;\n col = mix(_e175, vec3<f32>(1f, 1f, 1f), vec3(smoothstep(0.82f, 1.4f, _e176)));\n let _e181 = unnamed.uTint;\n let _e182 = col;\n col = (_e182 * _e181);\n let _e184 = body;\n alpha = clamp((_e184 * 1.6f), 0f, 1f);\n let _e187 = vDistance_1;\n param_7 = _e187;\n let _e189 = vWorldPos_1[1u];\n param_8 = _e189;\n let _e190 = mediumFog_u0028_f1_u003b_f1_u003b((&param_7), (&param_8));\n fog = _e190;\n let _e191 = col;\n let _e192 = mediumColor_u0028_();\n let _e193 = fog;\n col = mix(_e191, _e192, vec3(_e193));\n let _e196 = fog;\n let _e198 = alpha;\n alpha = (_e198 * (1f - _e196));\n let _e200 = col;\n let _e201 = alpha;\n outColor = vec4<f32>(_e200.x, _e200.y, _e200.z, _e201);\n return;\n}\n\n@fragment \nfn main(@location(3) vWorldPos: vec3<f32>, @location(0) vUv: vec2<f32>, @location(1) vSeed: f32, @location(2) vDistance: f32) -> @location(0) vec4<f32> {\n vWorldPos_1 = vWorldPos;\n vUv_1 = vUv;\n vSeed_1 = vSeed;\n vDistance_1 = vDistance;\n main_1();\n let _e9 = outColor;\n return _e9;\n}\n";
8
+ export const ARCANE_FRAG_WGSL = "struct Uniforms {\n uTime: f32,\n uFogColor: vec3<f32>,\n uFogDensity: f32,\n uFogHeightFalloff: f32,\n uFogEyeY: f32,\n uUnderwaterColor: vec3<f32>,\n uUnderwaterFogDensity: f32,\n uUnderwaterFactor: f32,\n uFogMode: i32,\n uFogNear: f32,\n uFogFar: f32,\n uNoiseOctaves: i32,\n uClipPlane: vec4<f32>,\n uClipEnabled: i32,\n uTint: vec3<f32>,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vWorldPos_1: vec3<f32>;\nvar<private> vUv_1: vec2<f32>;\nvar<private> vSeed_1: f32;\nvar<private> vDistance_1: f32;\nvar<private> outColor: vec4<f32>;\n\nfn mediumColor_u0028_() -> vec3<f32> {\n let _e59 = unnamed.uFogColor;\n let _e61 = unnamed.uUnderwaterColor;\n let _e63 = unnamed.uUnderwaterFactor;\n return mix(_e59, _e61, vec3(_e63));\n}\n\nfn mediumFog_u0028_f1_u003b_f1_u003b(dist: ptr<function, f32>, pointY: ptr<function, f32>) -> f32 {\n var span: f32;\n var ramp: f32;\n var wetLinear: f32;\n var start: f32;\n var before: f32;\n var local: f32;\n var t: f32;\n var rest: f32;\n var denom: f32;\n var air: f32;\n var wet: f32;\n\n let _e72 = unnamed.uFogMode;\n if (_e72 == 1i) {\n let _e75 = unnamed.uFogFar;\n let _e77 = unnamed.uFogNear;\n span = max((_e75 - _e77), 0.0001f);\n let _e80 = (*dist);\n let _e82 = unnamed.uFogNear;\n let _e84 = span;\n ramp = clamp(((_e80 - _e82) / _e84), 0f, 1f);\n let _e88 = unnamed.uUnderwaterFactor;\n if (_e88 <= 0f) {\n let _e90 = ramp;\n return _e90;\n }\n let _e92 = unnamed.uUnderwaterFogDensity;\n let _e93 = (*dist);\n wetLinear = (_e92 * _e93);\n let _e95 = ramp;\n let _e96 = wetLinear;\n let _e98 = wetLinear;\n let _e104 = unnamed.uUnderwaterFactor;\n return mix(_e95, (1f - exp2(((-(_e96) * _e98) * 1.442695f))), _e104);\n }\n let _e107 = unnamed.uFogNear;\n let _e108 = (*dist);\n start = min(_e107, _e108);\n let _e110 = (*dist);\n if (_e110 > 0f) {\n let _e112 = start;\n let _e113 = (*dist);\n local = (_e112 / _e113);\n } else {\n local = 0f;\n }\n let _e115 = local;\n before = _e115;\n let _e116 = (*pointY);\n let _e118 = unnamed.uFogEyeY;\n let _e121 = unnamed.uFogHeightFalloff;\n t = ((_e116 - _e118) * _e121);\n let _e123 = t;\n let _e124 = before;\n rest = (_e123 * (1f - _e124));\n let _e127 = rest;\n let _e130 = rest;\n denom = select(_e130, 0.0001f, (abs(_e127) < 0.0001f));\n let _e133 = unnamed.uFogDensity;\n let _e135 = t;\n let _e137 = before;\n let _e141 = (*dist);\n let _e142 = start;\n let _e145 = denom;\n let _e150 = denom;\n air = (1f - exp(((((-(_e133) * exp((-(_e135) * _e137))) * (_e141 - _e142)) * (1f - exp(-(_e145)))) / _e150)));\n let _e155 = unnamed.uUnderwaterFactor;\n if (_e155 <= 0f) {\n let _e157 = air;\n return _e157;\n }\n let _e159 = unnamed.uUnderwaterFogDensity;\n let _e160 = (*dist);\n wet = (_e159 * _e160);\n let _e162 = air;\n let _e163 = wet;\n let _e165 = wet;\n let _e171 = unnamed.uUnderwaterFactor;\n return mix(_e162, (1f - exp2(((-(_e163) * _e165) * 1.442695f))), _e171);\n}\n\nfn hash21_u0028_vf2_u003b(p: ptr<function, vec2<f32>>) -> f32 {\n let _e59 = (*p);\n return fract((sin(dot(_e59, vec2<f32>(127.1f, 311.7f))) * 43758.547f));\n}\n\nfn valueNoise_u0028_vf2_u003b(p_1: ptr<function, vec2<f32>>) -> f32 {\n var i: vec2<f32>;\n var f: vec2<f32>;\n var u: vec2<f32>;\n var param: vec2<f32>;\n var param_1: vec2<f32>;\n var param_2: vec2<f32>;\n var param_3: vec2<f32>;\n\n let _e66 = (*p_1);\n i = floor(_e66);\n let _e68 = (*p_1);\n f = fract(_e68);\n let _e70 = f;\n let _e71 = f;\n let _e73 = f;\n u = ((_e70 * _e71) * (vec2(3f) - (_e73 * 2f)));\n let _e78 = i;\n param = _e78;\n let _e79 = hash21_u0028_vf2_u003b((&param));\n let _e80 = i;\n param_1 = (_e80 + vec2<f32>(1f, 0f));\n let _e82 = hash21_u0028_vf2_u003b((&param_1));\n let _e84 = u[0u];\n let _e86 = i;\n param_2 = (_e86 + vec2<f32>(0f, 1f));\n let _e88 = hash21_u0028_vf2_u003b((&param_2));\n let _e89 = i;\n param_3 = (_e89 + vec2<f32>(1f, 1f));\n let _e91 = hash21_u0028_vf2_u003b((&param_3));\n let _e93 = u[0u];\n let _e96 = u[1u];\n return mix(mix(_e79, _e82, _e84), mix(_e88, _e91, _e93), _e96);\n}\n\nfn main_1() {\n var radius: f32;\n var d: vec2<f32>;\n var angle: f32;\n var t_1: f32;\n var inner: f32;\n var param_4: vec2<f32>;\n var outer: f32;\n var param_5: vec2<f32>;\n var swirl: f32;\n var param_6: vec2<f32>;\n var core: f32;\n var corona: f32;\n var body: f32;\n var col: vec3<f32>;\n var alpha: f32;\n var fog: f32;\n var param_7: f32;\n var param_8: f32;\n var phi_266_: bool;\n\n let _e77 = unnamed.uClipEnabled;\n let _e78 = (_e77 != 0i);\n phi_266_ = _e78;\n if _e78 {\n let _e79 = vWorldPos_1;\n let _e85 = unnamed.uClipPlane;\n phi_266_ = (dot(vec4<f32>(_e79.x, _e79.y, _e79.z, 1f), _e85) < 0f);\n }\n let _e89 = phi_266_;\n if _e89 {\n discard;\n }\n let _e90 = vUv_1;\n radius = (length((_e90 - vec2(0.5f))) * 2f);\n let _e95 = radius;\n if (_e95 >= 1f) {\n discard;\n }\n let _e97 = vUv_1;\n d = (_e97 - vec2(0.5f));\n let _e101 = d[1u];\n let _e103 = d[0u];\n angle = atan2(_e101, _e103);\n let _e106 = unnamed.uTime;\n let _e107 = vSeed_1;\n t_1 = (_e106 + (_e107 * 37f));\n let _e110 = angle;\n let _e112 = t_1;\n let _e115 = radius;\n param_4 = vec2<f32>(((_e110 * 1.9f) + (_e112 * 0.55f)), (_e115 * 4.2f));\n let _e118 = valueNoise_u0028_vf2_u003b((&param_4));\n inner = _e118;\n let _e119 = angle;\n let _e121 = t_1;\n let _e124 = radius;\n param_5 = vec2<f32>(((_e119 * 3.1f) - (_e121 * 0.34f)), (_e124 * 2.6f));\n let _e127 = valueNoise_u0028_vf2_u003b((&param_5));\n outer = _e127;\n let _e128 = inner;\n let _e130 = outer;\n swirl = ((_e128 * 0.62f) + (_e130 * 0.38f));\n let _e134 = unnamed.uNoiseOctaves;\n if (_e134 > 1i) {\n let _e136 = swirl;\n let _e137 = swirl;\n let _e138 = angle;\n let _e140 = t_1;\n let _e143 = radius;\n param_6 = vec2<f32>(((_e138 * 6.3f) + (_e140 * 0.9f)), (_e143 * 8f));\n let _e146 = valueNoise_u0028_vf2_u003b((&param_6));\n swirl = mix(_e136, ((_e137 * _e146) * 2f), 0.35f);\n }\n let _e150 = radius;\n core = (1f - smoothstep(0f, 0.28f, _e150));\n let _e153 = radius;\n let _e156 = swirl;\n corona = ((1f - smoothstep(0.18f, 1f, _e153)) * (0.35f + (_e156 * 0.65f)));\n let _e160 = core;\n let _e162 = corona;\n body = ((_e160 * 0.9f) + _e162);\n let _e164 = body;\n if (_e164 <= 0.02f) {\n discard;\n }\n let _e167 = unnamed.uTint;\n let _e170 = unnamed.uTint;\n let _e171 = body;\n col = mix((_e167 * 0.35f), _e170, vec3(smoothstep(0f, 0.55f, _e171)));\n let _e175 = col;\n let _e176 = body;\n col = mix(_e175, vec3<f32>(1f, 1f, 1f), vec3(smoothstep(0.82f, 1.4f, _e176)));\n let _e181 = unnamed.uTint;\n let _e182 = col;\n col = (_e182 * _e181);\n let _e184 = body;\n alpha = clamp((_e184 * 1.6f), 0f, 1f);\n let _e187 = vDistance_1;\n param_7 = _e187;\n let _e189 = vWorldPos_1[1u];\n param_8 = _e189;\n let _e190 = mediumFog_u0028_f1_u003b_f1_u003b((&param_7), (&param_8));\n fog = _e190;\n let _e191 = col;\n let _e192 = mediumColor_u0028_();\n let _e193 = fog;\n col = mix(_e191, _e192, vec3(_e193));\n let _e196 = fog;\n let _e198 = alpha;\n alpha = (_e198 * (1f - _e196));\n let _e200 = col;\n let _e201 = alpha;\n outColor = vec4<f32>(_e200.x, _e200.y, _e200.z, _e201);\n return;\n}\n\n@fragment \nfn main(@location(3) vWorldPos: vec3<f32>, @location(0) vUv: vec2<f32>, @location(1) vSeed: f32, @location(2) vDistance: f32) -> @location(0) vec4<f32> {\n vWorldPos_1 = vWorldPos;\n vUv_1 = vUv;\n vSeed_1 = vSeed;\n vDistance_1 = vDistance;\n main_1();\n let _e9 = outColor;\n return _e9;\n}\n";
9
9
 
10
10
  /**
11
11
  * What the transform assigned, so the renderer binds the same numbers.