@woosh/meep-engine 3.75.0 → 3.76.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 (216) hide show
  1. package/package.json +1 -1
  2. package/src/engine/asset/GameAssetType.d.ts +1 -0
  3. package/src/engine/asset/GameAssetType.js +5 -1
  4. package/src/engine/asset/loaders/GroomAssetLoader.d.ts +33 -0
  5. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -0
  6. package/src/engine/asset/loaders/GroomAssetLoader.js +99 -0
  7. package/src/engine/graphics/ecs/hair/Hair.d.ts +47 -0
  8. package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -0
  9. package/src/engine/graphics/ecs/hair/Hair.js +61 -0
  10. package/src/engine/graphics/hair/Groom.d.ts +130 -0
  11. package/src/engine/graphics/hair/Groom.d.ts.map +1 -0
  12. package/src/engine/graphics/hair/Groom.js +193 -0
  13. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +24 -0
  14. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -0
  15. package/src/engine/graphics/hair/GroomSerializationAdapter.js +77 -0
  16. package/src/engine/graphics/hair/groom_build_group.d.ts +85 -0
  17. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -0
  18. package/src/engine/graphics/hair/groom_build_group.js +487 -0
  19. package/src/engine/graphics/hair/groom_generate_scalp.d.ts +29 -0
  20. package/src/engine/graphics/hair/groom_generate_scalp.d.ts.map +1 -0
  21. package/src/engine/graphics/hair/groom_generate_scalp.js +184 -0
  22. package/src/engine/graphics/hair/groom_rank_order.d.ts +15 -0
  23. package/src/engine/graphics/hair/groom_rank_order.d.ts.map +1 -0
  24. package/src/engine/graphics/hair/groom_rank_order.js +53 -0
  25. package/src/engine/graphics/hair/groom_root_spacing.d.ts +12 -0
  26. package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -0
  27. package/src/engine/graphics/hair/groom_root_spacing.js +120 -0
  28. package/src/engine/graphics3/HairSystem.d.ts +102 -0
  29. package/src/engine/graphics3/HairSystem.d.ts.map +1 -0
  30. package/src/engine/graphics3/HairSystem.js +456 -0
  31. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  32. package/src/shade/assets/textures/hair_scattering.bin +0 -0
  33. package/src/shade/device/pipeline/PipelineEnquiry.d.ts +11 -0
  34. package/src/shade/device/pipeline/PipelineEnquiry.d.ts.map +1 -1
  35. package/src/shade/device/pipeline/PipelineEnquiry.js +13 -0
  36. package/src/shade/playground/hair/index.html +50 -0
  37. package/src/shade/playground/hair/main.d.ts +2 -0
  38. package/src/shade/playground/hair/main.d.ts.map +1 -0
  39. package/src/shade/playground/hair/main.js +274 -0
  40. package/src/shade/playground/screen_probes/README.md +54 -0
  41. package/src/shade/playground/screen_probes/index.html +271 -0
  42. package/src/shade/playground/screen_probes/main.d.ts +8 -0
  43. package/src/shade/playground/screen_probes/main.d.ts.map +1 -0
  44. package/src/shade/playground/screen_probes/main.js +527 -0
  45. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  46. package/src/shade/renderer/Renderer.js +54 -8
  47. package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts +6 -0
  48. package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts.map +1 -1
  49. package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.js +10 -0
  50. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  51. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
  52. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  53. package/src/shade/renderer/deferred/chunk_read_gBuffer_material.d.ts.map +1 -1
  54. package/src/shade/renderer/deferred/chunk_read_gBuffer_material.js +3 -1
  55. package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts +23 -0
  56. package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts.map +1 -0
  57. package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +111 -0
  58. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +17 -6
  59. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
  60. package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +26 -21
  61. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts +12 -22
  62. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts.map +1 -1
  63. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.js +20 -100
  64. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.d.ts.map +1 -1
  65. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.js +6 -4
  66. package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts +15 -0
  67. package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts.map +1 -0
  68. package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +47 -0
  69. package/src/shade/renderer/extension/ViewLighting.d.ts +101 -0
  70. package/src/shade/renderer/extension/ViewLighting.d.ts.map +1 -0
  71. package/src/shade/renderer/extension/ViewLighting.js +168 -0
  72. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  73. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  74. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  75. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  76. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  77. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.d.ts.map +1 -1
  78. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.js +3 -1
  79. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  80. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
  81. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +3 -1
  82. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +15 -7
  83. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -1
  84. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +40 -9
  85. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +23 -0
  86. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
  87. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +26 -0
  88. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +1 -0
  89. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +6 -0
  90. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +13 -1
  91. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
  92. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +23 -1
  93. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -1
  94. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +2 -0
  95. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +29 -0
  96. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -0
  97. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +102 -0
  98. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +8 -1
  99. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +27 -1
  101. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +4 -1
  102. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
  103. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +4 -1
  104. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +11 -5
  105. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -1
  106. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +28 -10
  107. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +36 -2
  108. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
  109. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +149 -4
  110. package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.d.ts.map +1 -1
  111. package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js +3 -1
  112. package/src/shade/renderer/hair/GPUHairSystem.d.ts +159 -0
  113. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -0
  114. package/src/shade/renderer/hair/GPUHairSystem.js +1132 -0
  115. package/src/shade/renderer/hair/HAIR.d.ts +102 -0
  116. package/src/shade/renderer/hair/HAIR.d.ts.map +1 -0
  117. package/src/shade/renderer/hair/HAIR.js +115 -0
  118. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts +17 -0
  119. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -0
  120. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +71 -0
  121. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +11 -0
  122. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -0
  123. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +48 -0
  124. package/src/shade/renderer/hair/HairFrame.d.ts +41 -0
  125. package/src/shade/renderer/hair/HairFrame.d.ts.map +1 -0
  126. package/src/shade/renderer/hair/HairFrame.js +76 -0
  127. package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +42 -0
  128. package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -0
  129. package/src/shade/renderer/hair/chunk_hair_bsdf.js +170 -0
  130. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +30 -0
  131. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -0
  132. package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +131 -0
  133. package/src/shade/renderer/hair/chunk_hair_pixel.d.ts +32 -0
  134. package/src/shade/renderer/hair/chunk_hair_pixel.d.ts.map +1 -0
  135. package/src/shade/renderer/hair/chunk_hair_pixel.js +116 -0
  136. package/src/shade/renderer/hair/chunk_hair_strand.d.ts +40 -0
  137. package/src/shade/renderer/hair/chunk_hair_strand.d.ts.map +1 -0
  138. package/src/shade/renderer/hair/chunk_hair_strand.js +85 -0
  139. package/src/shade/renderer/hair/chunk_hair_volume.d.ts +31 -0
  140. package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -0
  141. package/src/shade/renderer/hair/chunk_hair_volume.js +106 -0
  142. package/src/shade/renderer/hair/hair_id_draw.d.ts +24 -0
  143. package/src/shade/renderer/hair/hair_id_draw.d.ts.map +1 -0
  144. package/src/shade/renderer/hair/hair_id_draw.js +135 -0
  145. package/src/shade/renderer/hair/hair_lighting.d.ts +53 -0
  146. package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -0
  147. package/src/shade/renderer/hair/hair_lighting.js +270 -0
  148. package/src/shade/renderer/hair/hair_scattering_lut.d.ts +75 -0
  149. package/src/shade/renderer/hair/hair_scattering_lut.d.ts.map +1 -0
  150. package/src/shade/renderer/hair/hair_scattering_lut.js +271 -0
  151. package/src/shade/renderer/hair/hair_stamp.d.ts +33 -0
  152. package/src/shade/renderer/hair/hair_stamp.d.ts.map +1 -0
  153. package/src/shade/renderer/hair/hair_stamp.js +175 -0
  154. package/src/shade/renderer/hair/shader_hair_classes.d.ts +21 -0
  155. package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -0
  156. package/src/shade/renderer/hair/shader_hair_classes.js +86 -0
  157. package/src/shade/renderer/hair/shader_hair_cull.d.ts +31 -0
  158. package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -0
  159. package/src/shade/renderer/hair/shader_hair_cull.js +194 -0
  160. package/src/shade/renderer/hair/shader_hair_lod.d.ts +33 -0
  161. package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -0
  162. package/src/shade/renderer/hair/shader_hair_lod.js +268 -0
  163. package/src/shade/renderer/hair/shader_hair_volume.d.ts +28 -0
  164. package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -0
  165. package/src/shade/renderer/hair/shader_hair_volume.js +167 -0
  166. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  167. package/src/shade/renderer/loader/usd/usd_build_scene.d.ts +31 -0
  168. package/src/shade/renderer/loader/usd/usd_build_scene.d.ts.map +1 -1
  169. package/src/shade/renderer/loader/usd/usd_build_scene.js +36 -21
  170. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +60 -0
  171. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -0
  172. package/src/shade/renderer/loader/usd/usd_groom_extension.js +417 -0
  173. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  174. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +4 -1
  175. package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.d.ts.map +1 -1
  176. package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js +3 -1
  177. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  178. package/src/shade/renderer/postprocess/ssr/SSR.d.ts +4 -1
  179. package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
  180. package/src/shade/renderer/postprocess/ssr/SSR.js +9 -0
  181. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts +16 -1
  182. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts.map +1 -1
  183. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +47 -3
  184. package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.d.ts.map +1 -1
  185. package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.js +5 -3
  186. package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.d.ts.map +1 -1
  187. package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.js +6 -5
  188. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.d.ts.map +1 -1
  189. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.js +5 -2
  190. package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -1
  191. package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +5 -0
  192. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
  193. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +4 -1
  194. package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts.map +1 -1
  195. package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.js +5 -1
  196. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts.map +1 -1
  197. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +7 -4
  198. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +13 -8
  199. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
  200. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +18 -14
  201. package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts +3 -2
  202. package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts.map +1 -1
  203. package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.js +12 -4
  204. package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.d.ts.map +1 -1
  205. package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js +1 -0
  206. package/src/shade/renderer/shader/chunk/material/chunk_compute_indirect_specular.js +1 -1
  207. package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts +16 -0
  208. package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts.map +1 -0
  209. package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.js +25 -0
  210. package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +2 -2
  211. package/src/shade/renderer/shader/compiler/ShaderSwitch.d.ts +1 -1
  212. package/src/shade/renderer/shader/compiler/ShaderSwitchSet.d.ts +1 -1
  213. package/src/shade/renderer/shader/resource/ShaderResourceDescriptor.d.ts +1 -1
  214. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +2 -2
  215. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +2 -2
  216. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
@@ -1,9 +1,15 @@
1
1
  /**
2
- * The screen probes' deferred indirect light in one pass, for SSR off: the diffuse is the screen probes' (the temporal
3
- * filter's output, E at the bent normal), and the specular the world-space probes', picked and resolved as the probe
4
- * clipmap's fused pass takes it (`probe_clipmap_radiance_of`), the environment's where no probe weighs anything. The
5
- * two are resolved as `shader_resolve_indirect_lighting` resolves the IBL pair: AO multiplies the diffuse, the
6
- * specular is occluded along its lobe, and the result is added to the scene's colour.
2
+ * The screen probes' deferred indirect light in one pass, for SSR off:
3
+ * - **The diffuse** is the screen probes' (the temporal filter's output, E at the bent normal).
4
+ * - **The specular** is the screen probes' rough specular (`GPUScreenProbeGI#specular_handle`) and the world-space
5
+ * probes' radiance, each by its share, the world probes' the alpha: theirs picked and resolved as the probe
6
+ * clipmap's fused pass takes it (`probe_clipmap_radiance_of`), the environment's where no probe weighs anything,
7
+ * and not picked where their share is none.
8
+ * - The two are resolved as `shader_resolve_indirect_lighting` resolves the IBL pair: AO multiplies the diffuse, the
9
+ * specular is occluded along its lobe, and the result is added to the scene's colour.
10
+ * - `PROBE_CLIPMAP_INDIRECT_LOBE` decides what is added: both lobes by default; for the mode's indirect specular
11
+ * debug view (`ScreenProbeDebugView.IndirectSpecular`), the specular's light alone, before the surface's material and
12
+ * occlusion, as this pass takes it with SSR off.
7
13
  *
8
14
  * @type {ImageShader}
9
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shader_screen_probe_indirect_lighting.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js"],"names":[],"mappings":"AAmDA;;;;;;;;GAQG;AACH,oDAFU,WAAW,CA8FlB;AAQH;;;;;GAKG;AACH,0CAFU,WAAW,CAyBlB;AAQH;;;;;GAKG;AACH,gDAFU,aAAa,CAiBpB;4BAxMyB,6BAA6B;8BAD3B,+BAA+B"}
1
+ {"version":3,"file":"shader_screen_probe_indirect_lighting.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js"],"names":[],"mappings":"AAsDA;;;;;;;;;;;;;;GAcG;AACH,oDAFU,WAAW,CAuGlB;AAQH;;;;;GAKG;AACH,0CAFU,WAAW,CAyBlB;AAQH;;;;;GAKG;AACH,gDAFU,aAAa,CAiBpB;4BAzNyB,6BAA6B;8BAD3B,+BAA+B"}
@@ -13,6 +13,7 @@ import { chunk_compute_indirect_specular } from "../../shader/chunk/material/chu
13
13
  import { chunk_decode_g_buffer_metalness } from "../../shader/chunk/material/chunk_decode_g_buffer_metalness.js";
14
14
  import { chunk_decode_g_buffer_roughness } from "../../shader/chunk/material/chunk_decode_g_buffer_roughness.js";
15
15
  import { chunk_metalness_to_specular_color } from "../../shader/chunk/material/chunk_metalness_to_specular_color.js";
16
+ import { chunk_metalness_to_specular_F90 } from "../../shader/chunk/material/chunk_metalness_to_specular_F90.js";
16
17
  import { chunk_stbn_sample_vec2 } from "../../shader/chunk/noise/chunk_stbn_sample_vec2.js";
17
18
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
18
19
  import { ComputeShader } from "../../shader/ComputeShader.js";
@@ -22,6 +23,7 @@ import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
22
23
  import { STBN_VEC2_RESOURCE } from "../../STATIC_GRAPHICS_ENGINE_ASSET_RESOURCES.js";
23
24
  import { SAMPLER_LINEAR_UPSCALE } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
24
25
  import { VIEW_UNIFORM_STRUCT } from "../../view/VIEW_UNIFORM_STRUCT.js";
26
+ import { chunk_probe_clipmap_indirect_lobe } from "../probe_clipmap/probe/chunk_probe_clipmap_indirect_lobe.js";
25
27
  import {
26
28
  chunk_probe_clipmap_pick,
27
29
  PROBE_CLIPMAP_SAMPLING_GROUP
@@ -39,6 +41,7 @@ fused_resources.createGroup()
39
41
  .addTexture("tGBufferAlbedo")
40
42
  .addTexture("tGBufferPBR")
41
43
  .addTexture("tScreenProbeDiffuse")
44
+ .addTexture("tScreenProbeSpecular")
42
45
  .add(STBN_VEC2_RESOURCE)
43
46
  .addUniform("view", VIEW_UNIFORM_STRUCT)
44
47
  .addUniform("camera", CAMERA_UNIFORM_STRUCT)
@@ -50,11 +53,17 @@ fused_resources.createGroup()
50
53
  fused_resources.addGroup(PROBE_CLIPMAP_SAMPLING_GROUP);
51
54
 
52
55
  /**
53
- * The screen probes' deferred indirect light in one pass, for SSR off: the diffuse is the screen probes' (the temporal
54
- * filter's output, E at the bent normal), and the specular the world-space probes', picked and resolved as the probe
55
- * clipmap's fused pass takes it (`probe_clipmap_radiance_of`), the environment's where no probe weighs anything. The
56
- * two are resolved as `shader_resolve_indirect_lighting` resolves the IBL pair: AO multiplies the diffuse, the
57
- * specular is occluded along its lobe, and the result is added to the scene's colour.
56
+ * The screen probes' deferred indirect light in one pass, for SSR off:
57
+ * - **The diffuse** is the screen probes' (the temporal filter's output, E at the bent normal).
58
+ * - **The specular** is the screen probes' rough specular (`GPUScreenProbeGI#specular_handle`) and the world-space
59
+ * probes' radiance, each by its share, the world probes' the alpha: theirs picked and resolved as the probe
60
+ * clipmap's fused pass takes it (`probe_clipmap_radiance_of`), the environment's where no probe weighs anything,
61
+ * and not picked where their share is none.
62
+ * - The two are resolved as `shader_resolve_indirect_lighting` resolves the IBL pair: AO multiplies the diffuse, the
63
+ * specular is occluded along its lobe, and the result is added to the scene's colour.
64
+ * - `PROBE_CLIPMAP_INDIRECT_LOBE` decides what is added: both lobes by default; for the mode's indirect specular
65
+ * debug view (`ScreenProbeDebugView.IndirectSpecular`), the specular's light alone, before the surface's material and
66
+ * occlusion, as this pass takes it with SSR off.
58
67
  *
59
68
  * @type {ImageShader}
60
69
  */
@@ -93,10 +102,17 @@ fn main(
93
102
  let bent_normal = decode_g_buffer_normal(textureLoad(tBentNormals, i_coord, 0).x);
94
103
 
95
104
  let irradiance = textureLoad(tScreenProbeDiffuse, i_coord, 0).rgb;
105
+ let rough = textureLoad(tScreenProbeSpecular, i_coord, 0);
96
106
 
97
- let pick = probe_clipmap_pick(position, normal, view_direction, stbn_sample_vec2(vec3<u32>(i_coord, view.frame_index)));
98
- let found = probe_clipmap_radiance_of(pick, position, normal, view_direction, surface_roughness);
99
- let radiance = select(get_ibl_radiance(view_direction, normal, surface_roughness), found.radiance, found.found);
107
+ var radiance = rough.rgb * (1.0 - rough.a);
108
+
109
+ // the world probes' share, picked only where they keep one
110
+ if (rough.a > 0.0) {
111
+ let pick = probe_clipmap_pick(position, normal, view_direction, stbn_sample_vec2(vec3<u32>(i_coord, view.frame_index)));
112
+ let found = probe_clipmap_radiance_of(pick, position, normal, view_direction, surface_roughness);
113
+
114
+ radiance += rough.a * select(get_ibl_radiance(view_direction, normal, surface_roughness), found.radiance, found.found);
115
+ }
100
116
 
101
117
  let indirect = compute_indirect_specular(
102
118
  radiance,
@@ -107,14 +123,14 @@ fn main(
107
123
  metalness_to_specular_color(f_metalness, albedo),
108
124
  vec3(MIN_DIELECTRICS_F0),
109
125
  albedo,
110
- 1.0,
126
+ metalness_to_specular_F90(f_metalness, albedo),
111
127
  roughness,
112
128
  );
113
129
 
114
130
  let spec_direction = normalize(mix(reflect(-view_direction, normal), normal, alpha));
115
131
  let specular_occlusion = compute_specular_occlusion_bn(spec_direction, bent_normal, occlusion, roughness);
116
132
 
117
- return vec4(indirect[0] * specular_occlusion + indirect[1], 1.0);
133
+ return vec4(probe_clipmap_indirect_lobe(indirect[0] * specular_occlusion, indirect[1], radiance, irradiance), 1.0);
118
134
  }
119
135
  `, [
120
136
  chunk_project_position_from_depth,
@@ -123,6 +139,7 @@ fn main(
123
139
  chunk_decode_g_buffer_metalness,
124
140
  chunk_decode_g_buffer_roughness,
125
141
  chunk_metalness_to_specular_color,
142
+ chunk_metalness_to_specular_F90,
126
143
  chunk_MIN_DIELECTRICS_F0,
127
144
  chunk_stbn_sample_vec2,
128
145
  chunk_probe_clipmap_pick,
@@ -130,6 +147,7 @@ fn main(
130
147
  chunk_get_ibl_radiance,
131
148
  chunk_compute_indirect_specular,
132
149
  chunk_compute_specular_occlusion_bn,
150
+ chunk_probe_clipmap_indirect_lobe,
133
151
  ]),
134
152
  }),
135
153
  targets: [
@@ -8,6 +8,21 @@ export const SCREEN_PROBE_INTEGRATED_WRITE_RESOURCE: ShaderResourceDescriptor;
8
8
  export const SCREEN_PROBE_DIFFUSE_HISTORY_RESOURCE: ShaderResourceDescriptor;
9
9
  /** This frame's, the temporal filter's output. @type {ShaderResourceDescriptor} */
10
10
  export const SCREEN_PROBE_DIFFUSE_WRITE_RESOURCE: ShaderResourceDescriptor;
11
+ /**
12
+ * The integration's rough specular, `rgba16float`: the screen probes' radiance along the pixel's specular lobe, and in
13
+ * alpha the share of the pixel's specular the world-space probes keep (`screen_probe_rough_specular_world_share`); the
14
+ * screen probes take the rest, so a reader's specular light is `rgb · (1 − a) + world · a`. The radiance is not scaled
15
+ * by the share, so a share that changes between frames changes no light already filtered; where the screen probes take
16
+ * none of it (alpha 1) it is zero and read by nothing.
17
+ * @type {ShaderResourceDescriptor}
18
+ */
19
+ export const SCREEN_PROBE_INTEGRATED_SPECULAR_READ_RESOURCE: ShaderResourceDescriptor;
20
+ /** @type {ShaderResourceDescriptor} */
21
+ export const SCREEN_PROBE_INTEGRATED_SPECULAR_WRITE_RESOURCE: ShaderResourceDescriptor;
22
+ /** Last frame's filtered rough specular, `rgba16float`. @type {ShaderResourceDescriptor} */
23
+ export const SCREEN_PROBE_SPECULAR_HISTORY_RESOURCE: ShaderResourceDescriptor;
24
+ /** This frame's, the temporal filter's output, as the integration's is laid out. @type {ShaderResourceDescriptor} */
25
+ export const SCREEN_PROBE_SPECULAR_WRITE_RESOURCE: ShaderResourceDescriptor;
11
26
  /** Last frame's frames and fast update a pixel, two unorm16 in `r32uint`. @type {ShaderResourceDescriptor} */
12
27
  export const SCREEN_PROBE_FRAMES_HISTORY_RESOURCE: ShaderResourceDescriptor;
13
28
  /** @type {ShaderResourceDescriptor} */
@@ -15,7 +30,8 @@ export const SCREEN_PROBE_FRAMES_WRITE_RESOURCE: ShaderResourceDescriptor;
15
30
  /** Last frame's reverse-Z depth. @type {ShaderResourceDescriptor} */
16
31
  export const SCREEN_PROBE_DEPTH_PREVIOUS_RESOURCE: ShaderResourceDescriptor;
17
32
  /**
18
- * Each pixel's diffuse light from the probes (Lumen's `ScreenProbeIntegrateCS`, its SH3 diffuse): a thread a pixel.
33
+ * Each pixel's diffuse light from the probes (Lumen's `ScreenProbeIntegrateCS`, its SH3 diffuse), and its rough
34
+ * specular: a thread a pixel.
19
35
  *
20
36
  * - **The lookup's jitter**: by the frame's blue noise at the pixel, up to a tile's width each way, Lumen's
21
37
  * `FullResolutionJitterWidth` of one, kept only where the pixel it lands on is coplanar with this one (plane weight at
@@ -26,9 +42,23 @@ export const SCREEN_PROBE_DEPTH_PREVIOUS_RESOURCE: ShaderResourceDescriptor;
26
42
  * - **The light**: the probes' SH3 blended by the weights (each probe by name), E at the pixel's bent normal
27
43
  * (`sh3_color_get_irradiance_at`), as the probe clipmap's diffuse resolves at it, over the exposure the SH was
28
44
  * pre-exposed by: the scene's units, which the temporal filter and the deferred passes take.
45
+ * - **Known defect, light from below the surface**: three bands cannot hold the clamped cosine's cut at the horizon,
46
+ * so E weighs light from up to about 14° below the pixel's horizon, and negatively further down. A probe's rays that
47
+ * leave below its own surface's plane meet that surface further along, so a pixel on a flat surface takes in light
48
+ * lying on the same surface, seen at a grazing angle: beside a sunlit patch on a floor, the floor's irradiance
49
+ * brightens in the patch's shape, the sharper the finer the octahedron. The rays are right, since a probe also
50
+ * lights pixels on other planes (a wall at the floor's edge, the face under a ledge) for which those directions are
51
+ * open; the fault is the lobe the light is resolved with. The composite's dithered landing adds to it
52
+ * (`shader_screen_probe_composite`).
29
53
  * - **Alpha**: the probes' moving shares by the same weights, held to 0.001 from below; negative where the weights do
30
54
  * not cover the pixel (`screen_probe_covers`), whose light is then zero and the temporal filter's to fill.
31
- * - A pixel of the sky is zero.
55
+ * - **The rough specular** (`chunk_screen_probe_rough_specular`), with `rough_specular` on: the probes' irradiance over
56
+ * π, as Lumen's default takes it, mixed by the sampled share into the radiance along the pixel's GGX lobe at its
57
+ * shading normal, read from one of its probes picked by the weights with the frame's blue noise at the pixel (16 past
58
+ * the frame), as Lumen's stochastic interpolation picks one; both over the exposure; with the world probes' share in
59
+ * alpha. A smooth surface (world share 1) and a pixel no probe covers sample nothing; the latter's light is zero, the
60
+ * temporal filter's to fill. Off, every pixel is the world probes' whole: (0, 0, 0, 1).
61
+ * - A pixel of the sky is zero, its specular the world probes'.
32
62
  *
33
63
  * @type {ComputeShader}
34
64
  */
@@ -50,6 +80,10 @@ export const shader_screen_probe_integrate: ComputeShader;
50
80
  * - **A pixel the probes did not cover** takes the mean of its covered neighbours in a 3 × 3 this frame; with none,
51
81
  * its history alone.
52
82
  * - The blend is 1 / (1 + frames); a pixel with no history to keep takes its new light whole.
83
+ * - **The rough specular** goes through the same reprojection, weights and frames, counting only what holds the screen
84
+ * probes' light: a history tap or fill neighbour of which they took a share (alpha below 1). A pixel of which they
85
+ * take none this frame writes (0, 0, 0, 1), whatever its history; one with no such tap takes its new light whole, and
86
+ * an uncovered one with no such neighbour keeps its history alone. Its alpha is this frame's share.
53
87
  *
54
88
  * @type {ComputeShader}
55
89
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shader_screen_probe_resolve.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js"],"names":[],"mappings":"AA+CA,6HAA6H;AAC7H,gDADiG,wBAAwB,CACf;AAE1G,gLAAgL;AAChL,oDADoJ,wBAAwB,CACrC;AACvI,uCAAuC;AACvC,qDADW,wBAAwB,CACyH;AAE5J,qFAAqF;AACrF,oDADyD,wBAAwB,CAC2D;AAC5I,mFAAmF;AACnF,kDADuD,wBAAwB,CACuE;AAEtJ,8GAA8G;AAC9G,mDADkF,wBAAwB,CACkB;AAC5H,uCAAuC;AACvC,iDADW,wBAAwB,CAC6G;AAEhJ,qEAAqE;AACrE,mDADyC,wBAAwB,CACsC;AAmBvG;;;;;;;;;;;;;;;;;GAiBG;AACH,4CAFU,aAAa,CA2FpB;AAmBH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2CAFU,aAAa,CAsIpB;yCA5VsC,mDAAmD;8BAD9D,+BAA+B"}
1
+ {"version":3,"file":"shader_screen_probe_resolve.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js"],"names":[],"mappings":"AAoDA,6HAA6H;AAC7H,gDADiG,wBAAwB,CACf;AAE1G,gLAAgL;AAChL,oDADoJ,wBAAwB,CACrC;AACvI,uCAAuC;AACvC,qDADW,wBAAwB,CACyH;AAE5J,qFAAqF;AACrF,oDADyD,wBAAwB,CAC2D;AAC5I,mFAAmF;AACnF,kDADuD,wBAAwB,CACuE;AAEtJ;;;;;;;GAOG;AACH,6DAFU,wBAAwB,CAEuH;AACzJ,uCAAuC;AACvC,8DADW,wBAAwB,CAC2I;AAE9K,4FAA4F;AAC5F,qDADgE,wBAAwB,CACsD;AAC9I,qHAAqH;AACrH,mDADyF,wBAAwB,CACuC;AAExJ,8GAA8G;AAC9G,mDADkF,wBAAwB,CACkB;AAC5H,uCAAuC;AACvC,iDADW,wBAAwB,CAC6G;AAEhJ,qEAAqE;AACrE,mDADyC,wBAAwB,CACsC;AAsBvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,4CAFU,aAAa,CA4IpB;AAsBH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,2CAFU,aAAa,CAuLpB;yCA3esC,mDAAmD;8BAD9D,+BAA+B"}
@@ -6,6 +6,8 @@ import {
6
6
  chunk_decode_g_buffer_face_normal
7
7
  } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_face_normal.js";
8
8
  import { chunk_decode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js";
9
+ import { chunk_decode_g_buffer_roughness } from "../../shader/chunk/material/chunk_decode_g_buffer_roughness.js";
10
+ import { RECIPROCAL_PI_DECLARATION } from "../../shader/chunk/math/RECIPROCAL_PI_DECLARATION.js";
9
11
  import { chunk_stbn_sample_vec2 } from "../../shader/chunk/noise/chunk_stbn_sample_vec2.js";
10
12
  import { chunk_sh3_color_add_scaled } from "../../shader/chunk/spherical_harmonics/chunk_sh3_color_add_scaled.js";
11
13
  import {
@@ -22,12 +24,14 @@ import {
22
24
  SCREEN_PROBE_EXPOSURE_RESOURCE,
23
25
  SCREEN_PROBE_FRAME_RESOURCE,
24
26
  SCREEN_PROBE_MOVING_READ_RESOURCE,
27
+ SCREEN_PROBE_RADIANCE_READ_RESOURCE,
25
28
  SCREEN_PROBE_SH_READ_RESOURCE,
26
29
  SCREEN_PROBE_TILE_COUNTS_READ_RESOURCE,
27
30
  SCREEN_PROBE_TILE_PROBES_READ_RESOURCE,
28
31
  SCREEN_PROBES_READ_RESOURCE
29
32
  } from "./chunk_screen_probe.js";
30
33
  import { chunk_screen_probe_interpolate } from "./chunk_screen_probe_interpolate.js";
34
+ import { chunk_screen_probe_rough_specular } from "./chunk_screen_probe_rough_specular.js";
31
35
  import {
32
36
  SCREEN_PROBE_CAMERA_PREVIOUS_RESOURCE,
33
37
  SCREEN_PROBE_CAMERA_RESOURCE,
@@ -35,6 +39,7 @@ import {
35
39
  SCREEN_PROBE_PBR_RESOURCE,
36
40
  SCREEN_PROBE_VELOCITY_RESOURCE
37
41
  } from "./chunk_screen_probe_surface.js";
42
+ import { SCREEN_PROBE_NORMAL_RESOURCE } from "./shader_screen_probe_importance.js";
38
43
  import { chunk_screen_probe_covers } from "./shader_screen_probe_place.js";
39
44
  import {
40
45
  SCREEN_PROBE_FAST_UPDATE_LIMIT,
@@ -58,6 +63,23 @@ export const SCREEN_PROBE_DIFFUSE_HISTORY_RESOURCE = ShaderResourceDescriptor.te
58
63
  /** This frame's, the temporal filter's output. @type {ShaderResourceDescriptor} */
59
64
  export const SCREEN_PROBE_DIFFUSE_WRITE_RESOURCE = ShaderResourceDescriptor.storageTexture("screen_probe_diffuse", "rgba16float", "2d", "write-only");
60
65
 
66
+ /**
67
+ * The integration's rough specular, `rgba16float`: the screen probes' radiance along the pixel's specular lobe, and in
68
+ * alpha the share of the pixel's specular the world-space probes keep (`screen_probe_rough_specular_world_share`); the
69
+ * screen probes take the rest, so a reader's specular light is `rgb · (1 − a) + world · a`. The radiance is not scaled
70
+ * by the share, so a share that changes between frames changes no light already filtered; where the screen probes take
71
+ * none of it (alpha 1) it is zero and read by nothing.
72
+ * @type {ShaderResourceDescriptor}
73
+ */
74
+ export const SCREEN_PROBE_INTEGRATED_SPECULAR_READ_RESOURCE = ShaderResourceDescriptor.texture("screen_probe_integrated_specular", "unfilterable-float");
75
+ /** @type {ShaderResourceDescriptor} */
76
+ export const SCREEN_PROBE_INTEGRATED_SPECULAR_WRITE_RESOURCE = ShaderResourceDescriptor.storageTexture("screen_probe_integrated_specular", "rgba16float", "2d", "write-only");
77
+
78
+ /** Last frame's filtered rough specular, `rgba16float`. @type {ShaderResourceDescriptor} */
79
+ export const SCREEN_PROBE_SPECULAR_HISTORY_RESOURCE = ShaderResourceDescriptor.texture("screen_probe_specular_history", "unfilterable-float");
80
+ /** This frame's, the temporal filter's output, as the integration's is laid out. @type {ShaderResourceDescriptor} */
81
+ export const SCREEN_PROBE_SPECULAR_WRITE_RESOURCE = ShaderResourceDescriptor.storageTexture("screen_probe_specular", "rgba16float", "2d", "write-only");
82
+
61
83
  /** Last frame's frames and fast update a pixel, two unorm16 in `r32uint`. @type {ShaderResourceDescriptor} */
62
84
  export const SCREEN_PROBE_FRAMES_HISTORY_RESOURCE = ShaderResourceDescriptor.texture("screen_probe_frames_history", "uint");
63
85
  /** @type {ShaderResourceDescriptor} */
@@ -81,10 +103,14 @@ integrate_resources.createGroup()
81
103
  .add(SCREEN_PROBE_DEPTH_RESOURCE)
82
104
  .add(SCREEN_PROBE_PBR_RESOURCE)
83
105
  .add(SCREEN_PROBE_BENT_NORMAL_RESOURCE)
84
- .add(SCREEN_PROBE_INTEGRATED_WRITE_RESOURCE);
106
+ .add(SCREEN_PROBE_NORMAL_RESOURCE)
107
+ .add(SCREEN_PROBE_RADIANCE_READ_RESOURCE)
108
+ .add(SCREEN_PROBE_INTEGRATED_WRITE_RESOURCE)
109
+ .add(SCREEN_PROBE_INTEGRATED_SPECULAR_WRITE_RESOURCE);
85
110
 
86
111
  /**
87
- * Each pixel's diffuse light from the probes (Lumen's `ScreenProbeIntegrateCS`, its SH3 diffuse): a thread a pixel.
112
+ * Each pixel's diffuse light from the probes (Lumen's `ScreenProbeIntegrateCS`, its SH3 diffuse), and its rough
113
+ * specular: a thread a pixel.
88
114
  *
89
115
  * - **The lookup's jitter**: by the frame's blue noise at the pixel, up to a tile's width each way, Lumen's
90
116
  * `FullResolutionJitterWidth` of one, kept only where the pixel it lands on is coplanar with this one (plane weight at
@@ -95,9 +121,23 @@ integrate_resources.createGroup()
95
121
  * - **The light**: the probes' SH3 blended by the weights (each probe by name), E at the pixel's bent normal
96
122
  * (`sh3_color_get_irradiance_at`), as the probe clipmap's diffuse resolves at it, over the exposure the SH was
97
123
  * pre-exposed by: the scene's units, which the temporal filter and the deferred passes take.
124
+ * - **Known defect, light from below the surface**: three bands cannot hold the clamped cosine's cut at the horizon,
125
+ * so E weighs light from up to about 14° below the pixel's horizon, and negatively further down. A probe's rays that
126
+ * leave below its own surface's plane meet that surface further along, so a pixel on a flat surface takes in light
127
+ * lying on the same surface, seen at a grazing angle: beside a sunlit patch on a floor, the floor's irradiance
128
+ * brightens in the patch's shape, the sharper the finer the octahedron. The rays are right, since a probe also
129
+ * lights pixels on other planes (a wall at the floor's edge, the face under a ledge) for which those directions are
130
+ * open; the fault is the lobe the light is resolved with. The composite's dithered landing adds to it
131
+ * (`shader_screen_probe_composite`).
98
132
  * - **Alpha**: the probes' moving shares by the same weights, held to 0.001 from below; negative where the weights do
99
133
  * not cover the pixel (`screen_probe_covers`), whose light is then zero and the temporal filter's to fill.
100
- * - A pixel of the sky is zero.
134
+ * - **The rough specular** (`chunk_screen_probe_rough_specular`), with `rough_specular` on: the probes' irradiance over
135
+ * π, as Lumen's default takes it, mixed by the sampled share into the radiance along the pixel's GGX lobe at its
136
+ * shading normal, read from one of its probes picked by the weights with the frame's blue noise at the pixel (16 past
137
+ * the frame), as Lumen's stochastic interpolation picks one; both over the exposure; with the world probes' share in
138
+ * alpha. A smooth surface (world share 1) and a pixel no probe covers sample nothing; the latter's light is zero, the
139
+ * temporal filter's to fill. Off, every pixel is the world probes' whole: (0, 0, 0, 1).
140
+ * - A pixel of the sky is zero, its specular the world probes'.
101
141
  *
102
142
  * @type {ComputeShader}
103
143
  */
@@ -134,12 +174,14 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
134
174
 
135
175
  if (is_background(device_depth)) {
136
176
  textureStore(screen_probe_integrated, pixel, vec4<f32>(0.0));
177
+ textureStore(screen_probe_integrated_specular, pixel, vec4<f32>(0.0, 0.0, 0.0, 1.0));
137
178
  return;
138
179
  }
139
180
 
140
181
  let position = project_position_from_depth((vec2<f32>(pixel) + 0.5) / size, device_depth, camera.view_projection_matrix_inverse);
141
182
  let depth = get_view_space_depth(device_depth, camera);
142
- let face = decode_g_buffer_face_normal(textureLoad(tPBR, pixel, 0));
183
+ let pbr = textureLoad(tPBR, pixel, 0);
184
+ let face = decode_g_buffer_face_normal(pbr);
143
185
 
144
186
  // the lookup moves up to a tile each way, onto a pixel coplanar with this one
145
187
  let span = f32(1u << frame.downsample_shift);
@@ -175,6 +217,49 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
175
217
  let irradiance = select(vec3<f32>(0.0), sh3_color_get_irradiance_at(bent_normal, sh) / max(screen_probe_exposure.value, 1e-20), covered);
176
218
 
177
219
  textureStore(screen_probe_integrated, pixel, vec4<f32>(irradiance, select(-1.0, 1.0, covered) * max(moving, 0.001)));
220
+
221
+ var specular = vec4<f32>(0.0, 0.0, 0.0, 1.0);
222
+
223
+ if (frame.rough_specular != 0u) {
224
+ let roughness = decode_g_buffer_roughness(pbr);
225
+ let world = screen_probe_rough_specular_world_share(roughness);
226
+
227
+ var rough = vec3<f32>(0.0);
228
+
229
+ if (world < 1.0 && covered) {
230
+ let sampled = screen_probe_rough_specular_sampled_share(roughness);
231
+
232
+ rough = irradiance * RECIPROCAL_PI;
233
+
234
+ if (sampled > 0.0) {
235
+ // one probe by the weights: the last corner of any weight whose span starts at or before the pick, so a
236
+ // corner of no weight is never picked
237
+ let pick = stbn_sample_vec2(vec3<u32>(pixel, frame.frame_index + 16u)).x * dot(weights, vec4<f32>(1.0));
238
+
239
+ var probe = sample.probes.x;
240
+ var start = 0.0;
241
+
242
+ for (var corner = 0u; corner < 4u; corner++) {
243
+ if (weights[corner] > 0.0 && pick >= start) {
244
+ probe = sample.probes[corner];
245
+ }
246
+
247
+ start += weights[corner];
248
+ }
249
+
250
+ let normal = decode_g_buffer_normal(textureLoad(tNormal, pixel, 0).x);
251
+ let view_direction = normalize(mat4_extract_position(camera.transform) - position);
252
+ let alpha = roughness * roughness;
253
+ let lobe = screen_probe_lobe_radiance(probe, normal, view_direction, alpha, pixel, frame.frame_index) / max(screen_probe_exposure.value, 1e-20);
254
+
255
+ rough = mix(rough, lobe, sampled);
256
+ }
257
+ }
258
+
259
+ specular = vec4<f32>(rough, world);
260
+ }
261
+
262
+ textureStore(screen_probe_integrated_specular, pixel, specular);
178
263
  }
179
264
  `, [
180
265
  chunk_screen_probe,
@@ -189,6 +274,10 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
189
274
  chunk_sh3_color_add_scaled,
190
275
  chunk_sh3_color_get_irradiance_at,
191
276
  chunk_probe_clipmap,
277
+ chunk_decode_g_buffer_roughness,
278
+ chunk_mat4_extract_position,
279
+ chunk_screen_probe_rough_specular,
280
+ RECIPROCAL_PI_DECLARATION,
192
281
  ]),
193
282
  });
194
283
 
@@ -204,9 +293,12 @@ temporal_resources.createGroup()
204
293
  .add(SCREEN_PROBE_PBR_RESOURCE)
205
294
  .add(SCREEN_PROBE_VELOCITY_RESOURCE)
206
295
  .add(SCREEN_PROBE_INTEGRATED_READ_RESOURCE)
296
+ .add(SCREEN_PROBE_INTEGRATED_SPECULAR_READ_RESOURCE)
207
297
  .add(SCREEN_PROBE_DIFFUSE_HISTORY_RESOURCE)
298
+ .add(SCREEN_PROBE_SPECULAR_HISTORY_RESOURCE)
208
299
  .add(SCREEN_PROBE_FRAMES_HISTORY_RESOURCE)
209
300
  .add(SCREEN_PROBE_DIFFUSE_WRITE_RESOURCE)
301
+ .add(SCREEN_PROBE_SPECULAR_WRITE_RESOURCE)
210
302
  .add(SCREEN_PROBE_FRAMES_WRITE_RESOURCE);
211
303
 
212
304
  /**
@@ -226,6 +318,10 @@ temporal_resources.createGroup()
226
318
  * - **A pixel the probes did not cover** takes the mean of its covered neighbours in a 3 × 3 this frame; with none,
227
319
  * its history alone.
228
320
  * - The blend is 1 / (1 + frames); a pixel with no history to keep takes its new light whole.
321
+ * - **The rough specular** goes through the same reprojection, weights and frames, counting only what holds the screen
322
+ * probes' light: a history tap or fill neighbour of which they took a share (alpha below 1). A pixel of which they
323
+ * take none this frame writes (0, 0, 0, 1), whatever its history; one with no such tap takes its new light whole, and
324
+ * an uncovered one with no such neighbour keeps its history alone. Its alpha is this frame's share.
229
325
  *
230
326
  * @type {ComputeShader}
231
327
  */
@@ -248,6 +344,20 @@ fn screen_probe_neighbour_light(pixel: vec2<i32>, offset: vec2<i32>) -> vec4<f32
248
344
  return select(vec4<f32>(0.0), vec4<f32>(value.rgb, 1.0), value.a > 0.0);
249
345
  }
250
346
 
347
+ // a covered neighbour's rough specular this frame, and one if it was covered and the screen probes took a share of it
348
+ fn screen_probe_neighbour_specular(pixel: vec2<i32>, offset: vec2<i32>) -> vec4<f32> {
349
+ let at = pixel + offset;
350
+
351
+ if (any(at < vec2<i32>(0)) || any(at >= vec2<i32>(screen_probe_frame.view_size))) {
352
+ return vec4<f32>(0.0);
353
+ }
354
+
355
+ let covered = textureLoad(screen_probe_integrated, vec2<u32>(at), 0).a > 0.0;
356
+ let value = textureLoad(screen_probe_integrated_specular, vec2<u32>(at), 0);
357
+
358
+ return select(vec4<f32>(0.0), vec4<f32>(value.rgb, 1.0), covered && value.a < 1.0);
359
+ }
360
+
251
361
  @compute @workgroup_size(${SCREEN_PROBE_TILE_WORKGROUP_SIZE}, ${SCREEN_PROBE_TILE_WORKGROUP_SIZE}, 1)
252
362
  fn main(@builtin(global_invocation_id) id: vec3<u32>) {
253
363
  let frame = screen_probe_frame;
@@ -262,17 +372,21 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
262
372
 
263
373
  if (is_background(device_depth)) {
264
374
  textureStore(screen_probe_diffuse, pixel, vec4<f32>(0.0));
375
+ textureStore(screen_probe_specular, pixel, vec4<f32>(0.0, 0.0, 0.0, 1.0));
265
376
  textureStore(screen_probe_frames, pixel, vec4<u32>(0u));
266
377
  return;
267
378
  }
268
379
 
269
380
  let position = project_position_from_depth((vec2<f32>(pixel) + 0.5) / size, device_depth, camera.view_projection_matrix_inverse);
270
381
  let fresh = textureLoad(screen_probe_integrated, pixel, 0);
382
+ let fresh_specular = textureLoad(screen_probe_integrated_specular, pixel, 0);
271
383
  let covered = fresh.a > 0.0;
272
384
  let moving = abs(fresh.a);
273
385
 
274
386
  var light = fresh.rgb;
387
+ var light_specular = fresh_specular.rgb;
275
388
  var force_history = false;
389
+ var force_history_specular = false;
276
390
 
277
391
  if (!covered) {
278
392
  let p = vec2<i32>(pixel);
@@ -282,9 +396,18 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
282
396
 
283
397
  light = select(vec3<f32>(0.0), s.rgb / s.a, s.a > 0.0);
284
398
  force_history = s.a <= 0.0;
399
+
400
+ let r = screen_probe_neighbour_specular(p, vec2<i32>(-1, -1)) + screen_probe_neighbour_specular(p, vec2<i32>(0, -1)) + screen_probe_neighbour_specular(p, vec2<i32>(1, -1))
401
+ + screen_probe_neighbour_specular(p, vec2<i32>(-1, 0)) + screen_probe_neighbour_specular(p, vec2<i32>(1, 0))
402
+ + screen_probe_neighbour_specular(p, vec2<i32>(-1, 1)) + screen_probe_neighbour_specular(p, vec2<i32>(0, 1)) + screen_probe_neighbour_specular(p, vec2<i32>(1, 1));
403
+
404
+ light_specular = select(vec3<f32>(0.0), r.rgb / r.a, r.a > 0.0);
405
+ force_history_specular = r.a <= 0.0;
285
406
  }
286
407
 
287
408
  var history = vec3<f32>(0.0);
409
+ var history_specular = vec3<f32>(0.0);
410
+ var kept_specular = 0.0;
288
411
  var frames = 0.0;
289
412
  var fast_history = 0.0;
290
413
  var kept = 0.0;
@@ -323,6 +446,14 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
323
446
  let packed = unpack2x16unorm(textureLoad(screen_probe_frames_history, vec2<u32>(tap), 0).r);
324
447
 
325
448
  history += bilinear * textureLoad(screen_probe_diffuse_history, vec2<u32>(tap), 0).rgb;
449
+
450
+ // the screen probes' light, where they took a share of the tap's
451
+ let tap_specular = textureLoad(screen_probe_specular_history, vec2<u32>(tap), 0);
452
+
453
+ if (tap_specular.a < 1.0) {
454
+ history_specular += bilinear * tap_specular.rgb;
455
+ kept_specular += bilinear;
456
+ }
326
457
  frames += bilinear * min(packed.x * frame.temporal_frames + 1.0, frame.temporal_frames);
327
458
  fast_history += bilinear * packed.y;
328
459
  kept += bilinear;
@@ -349,7 +480,21 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
349
480
  out = select(mix(history, light, 1.0 / (1.0 + accumulated)), history, force_history);
350
481
  }
351
482
 
483
+ // with nothing new to take and no history of it, nothing
484
+ var out_specular = select(light_specular, vec3<f32>(0.0), force_history_specular);
485
+
486
+ if (kept_specular > 0.0) {
487
+ history_specular /= kept_specular;
488
+
489
+ out_specular = select(mix(history_specular, light_specular, 1.0 / (1.0 + accumulated)), history_specular, force_history_specular);
490
+ }
491
+
352
492
  textureStore(screen_probe_diffuse, pixel, vec4<f32>(max(out, vec3<f32>(0.0)), 1.0));
493
+
494
+ // a pixel the world probes light whole holds none of the screen probes' light
495
+ let world = fresh_specular.a;
496
+
497
+ textureStore(screen_probe_specular, pixel, select(vec4<f32>(max(out_specular, vec3<f32>(0.0)), world), vec4<f32>(0.0, 0.0, 0.0, 1.0), world >= 1.0));
353
498
  textureStore(screen_probe_frames, pixel, vec4<u32>(pack2x16unorm(vec2<f32>(accumulated / frame.temporal_frames, fast_own)), 0u, 0u, 0u));
354
499
  }
355
500
  `, [
@@ -1 +1 @@
1
- {"version":3,"file":"shader_resolve_indirect_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js"],"names":[],"mappings":"AAkHA,2DAyBE;4BA9H0B,0BAA0B"}
1
+ {"version":3,"file":"shader_resolve_indirect_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js"],"names":[],"mappings":"AAoHA,2DAyBE;4BA/H0B,0BAA0B"}
@@ -10,6 +10,7 @@ import { chunk_compute_indirect_specular } from "../shader/chunk/material/chunk_
10
10
  import { chunk_decode_g_buffer_metalness } from "../shader/chunk/material/chunk_decode_g_buffer_metalness.js";
11
11
  import { chunk_decode_g_buffer_roughness } from "../shader/chunk/material/chunk_decode_g_buffer_roughness.js";
12
12
  import { chunk_metalness_to_specular_color } from "../shader/chunk/material/chunk_metalness_to_specular_color.js";
13
+ import { chunk_metalness_to_specular_F90 } from "../shader/chunk/material/chunk_metalness_to_specular_F90.js";
13
14
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
14
15
  import { ImageShader } from "../shader/ImageShader.js";
15
16
  import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
@@ -59,7 +60,7 @@ fn main(
59
60
  let alpha = roughness * roughness;
60
61
 
61
62
  let material_specularF0 = metalness_to_specular_color(f_metalness, albedo);
62
- let material_specularF90 = 1.0;
63
+ let material_specularF90 = metalness_to_specular_F90(f_metalness, albedo);
63
64
 
64
65
  //
65
66
  let position_ws = project_position_from_depth(uv, texel_depth, camera.view_projection_matrix_inverse );
@@ -107,6 +108,7 @@ fn main(
107
108
  chunk_decode_g_buffer_metalness,
108
109
  chunk_decode_g_buffer_roughness,
109
110
  chunk_metalness_to_specular_color,
111
+ chunk_metalness_to_specular_F90,
110
112
  chunk_MIN_DIELECTRICS_F0,
111
113
  chunk_compute_specular_occlusion_bn,
112
114
  ]