@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
@@ -0,0 +1,274 @@
1
+ import { Color } from "../../../core/color/Color.js";
2
+ import Quaternion from "../../../core/geom/Quaternion.js";
3
+ import Vector3 from "../../../core/geom/Vector3.js";
4
+ import { DEG_TO_RAD } from "../../../core/math/DEG_TO_RAD.js";
5
+ import { Entity } from "../../../engine/ecs/Entity.js";
6
+ import { EntityComponentDataset } from "../../../engine/ecs/EntityComponentDataset.js";
7
+ import { EntityManager } from "../../../engine/ecs/EntityManager.js";
8
+ import { Transform64 } from "../../../engine/ecs/transform/Transform64.js";
9
+ import { Hair } from "../../../engine/graphics/ecs/hair/Hair.js";
10
+ import { Light } from "../../../engine/graphics/ecs/light/Light.js";
11
+ import { LightType } from "../../../engine/graphics/ecs/light/LightType.js";
12
+ import { ShadedGeometry } from "../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
13
+ import { groom_generate_scalp } from "../../../engine/graphics/hair/groom_generate_scalp.js";
14
+ import { GraphicsEngine } from "../../../engine/graphics3/GraphicsEngine.js";
15
+ import { HairSystem } from "../../../engine/graphics3/HairSystem.js";
16
+ import { LightSystem } from "../../../engine/graphics3/LightSystem.js";
17
+ import { ShadedGeometrySystem } from "../../../engine/graphics3/ShadedGeometrySystem.js";
18
+ import { OrbitalCameraController } from "../../renderer/camera/orbital/OrbitalCameraController.js";
19
+ import { create_frame_loop } from "../../renderer/create_frame_loop.js";
20
+ import { MeshletGeometry } from "../../renderer/geometry/MeshletGeometry.js";
21
+ import { MeshoptClusterizer } from "../../renderer/geometry/meshlet/build/meshoptimizer/meshopt_clusterizer.js";
22
+ import { meshlet_geometry_build_from_geometry } from "../../renderer/geometry/meshlet_geometry_build_from_geometry.js";
23
+ import { make_plane_geometry } from "../../renderer/geometry/primitives/make_plane_geometry.js";
24
+ import { make_uv_sphere_geometry } from "../../renderer/geometry/primitives/make_uv_sphere_geometry.js";
25
+ import { StandardShadeMaterial } from "../../renderer/material/StandardShadeMaterial.js";
26
+ import { TransparencyMode } from "../../renderer/material/TransparencyMode.js";
27
+ import { Scene } from "../../renderer/scene/Scene.js";
28
+ import { load_default_environment } from "../load_default_environment.js";
29
+
30
+ /**
31
+ * Strand hair on test heads: `groom_generate_scalp` grooms worn through `Hair` components and drawn by
32
+ * `HairSystem` — thinned and widened with distance, drawn as ids into the G-buffer and lit by the hair BSDF.
33
+ *
34
+ * Query: `n` strands a head (20000), `points` a strand (33), `heads` along a row (1), `spacing` between them in
35
+ * metres (0.6), `melanin` (0.35), `redness` (0.15), `roughness` (0.3), `taper` how much width a strand loses over its last third (0.8), `noshadow` for a sun casting none, `debug` to drive
36
+ * frames by hand through
37
+ * `__step(n, dt)` instead of the frame loop.
38
+ *
39
+ * Serve the workspace with `npm run dev --workspace @woosh/meep-engine` and open
40
+ * `/src/shade/playground/hair/index.html`.
41
+ */
42
+
43
+ const query = new URLSearchParams(location.search);
44
+
45
+ const number = (name, fallback) => {
46
+ const value = Number(query.get(name));
47
+
48
+ return query.has(name) && Number.isFinite(value) ? value : fallback;
49
+ };
50
+
51
+ const STRANDS = Math.max(1, Math.floor(number("n", 20000)));
52
+ const POINTS = Math.floor(number("points", 33));
53
+ const HEADS = Math.max(1, Math.floor(number("heads", 1)));
54
+ const SPACING = number("spacing", 0.6);
55
+
56
+ const RADIUS = 0.09;
57
+
58
+ const element = id => document.getElementById(id);
59
+
60
+ const view_size = () => [Math.max(1, window.innerWidth), Math.max(1, window.innerHeight)];
61
+
62
+ /**
63
+ * @param {number} x
64
+ * @param {number} y
65
+ * @param {number} z
66
+ * @param {Quaternion} [rotation]
67
+ * @returns {Transform64}
68
+ */
69
+ function placed(x, y, z, rotation = new Quaternion()) {
70
+ const transform = new Transform64();
71
+
72
+ transform.setTranslation(x, y, z);
73
+ transform.setRotation(rotation.x, rotation.y, rotation.z, rotation.w);
74
+ transform.updateMatrix();
75
+
76
+ return transform;
77
+ }
78
+
79
+ /**
80
+ * @param {object} geometry
81
+ * @param {Color} color
82
+ * @param {number} roughness
83
+ * @returns {ShadedGeometry}
84
+ */
85
+ function shaded(geometry, color, roughness) {
86
+ const built = new MeshletGeometry();
87
+
88
+ meshlet_geometry_build_from_geometry(geometry, built);
89
+
90
+ const material = new StandardShadeMaterial();
91
+
92
+ material.diffuse_color.copy(color);
93
+ material.roughness_factor = roughness;
94
+ material.metallic_factor = 0;
95
+ material.transparency_mode = TransparencyMode.Opaque;
96
+
97
+ const component = new ShadedGeometry();
98
+
99
+ component.geometry = built;
100
+ component.material = material;
101
+
102
+ return component;
103
+ }
104
+
105
+ function show_message(text) {
106
+ const node = element("message");
107
+
108
+ if (node !== null) {
109
+ node.textContent = text;
110
+ }
111
+ }
112
+
113
+ async function main() {
114
+ await MeshoptClusterizer.ready;
115
+
116
+ const graphics = new GraphicsEngine();
117
+ const scene = new Scene();
118
+
119
+ graphics.set_scene(scene);
120
+
121
+ element("viewport").appendChild(graphics.viewport.el);
122
+
123
+ const [width, height] = view_size();
124
+
125
+ graphics.viewport.size.set(width, height);
126
+
127
+ const dataset = new EntityComponentDataset();
128
+ const entities = new EntityManager();
129
+
130
+ const hair_system = new HairSystem(graphics, scene);
131
+
132
+ entities.addSystem(new ShadedGeometrySystem(graphics, scene));
133
+ entities.addSystem(new LightSystem(graphics, scene));
134
+ entities.addSystem(hair_system);
135
+ entities.attachDataset(dataset);
136
+
137
+ await new Promise((resolve, reject) => entities.startup(resolve, reject));
138
+
139
+ const t0 = performance.now();
140
+ const groom = groom_generate_scalp({ strand_count: STRANDS, point_count: POINTS, radius: RADIUS, taper: number("taper", 0.8) });
141
+ const groom_ms = performance.now() - t0;
142
+
143
+ const skin = new Color(0.55, 0.38, 0.30, 1);
144
+ const head_geometry = make_uv_sphere_geometry(RADIUS * 0.995, 48, 32);
145
+
146
+ const heads = [];
147
+
148
+ for (let i = 0; i < HEADS; i++) {
149
+ const hair = new Hair();
150
+
151
+ hair.groom = groom;
152
+ hair.melanin = number("melanin", 0.35);
153
+ hair.redness = number("redness", 0.15);
154
+ hair.roughness = number("roughness", 0.3);
155
+
156
+ const x = (i - (HEADS - 1) * 0.5) * SPACING;
157
+
158
+ const entity = new Entity()
159
+ .add(placed(x, 1.6, 0))
160
+ .add(shaded(head_geometry, skin, 0.6))
161
+ .add(hair)
162
+ .build(dataset);
163
+
164
+ heads.push({ entity, hair });
165
+ }
166
+
167
+ new Entity()
168
+ .add(placed(0, 0, 0, Quaternion.fromAxisAngle(Vector3.right, -Math.PI / 2)))
169
+ .add(shaded(make_plane_geometry(20, 20, 1, 1), new Color(0.3, 0.3, 0.3, 1), 0.9))
170
+ .build(dataset);
171
+
172
+ const sun = new Light();
173
+
174
+ sun.type.set(LightType.DIRECTION);
175
+ sun.color.setRGB(1, 0.96, 0.9);
176
+ sun.intensity.set(3);
177
+ sun.castShadow.set(!query.has("noshadow"));
178
+
179
+ const sun_rotation = new Quaternion();
180
+
181
+ sun_rotation.fromUnitVectors(Vector3.forward, new Vector3(-0.5, -0.8, -0.35).normalize());
182
+ sun_rotation.normalize();
183
+
184
+ new Entity().add(placed(0, 10, 0, sun_rotation)).add(sun).build(dataset);
185
+
186
+ const camera = graphics.camera.camera;
187
+
188
+ camera.near = 0.02;
189
+ camera.far = 200;
190
+ camera.fov = 45 * DEG_TO_RAD;
191
+
192
+ const controller = new OrbitalCameraController(camera, document.body);
193
+
194
+ controller.look(new Vector3(0.0, 1.75, 0.55), new Vector3(0, 1.6, 0));
195
+
196
+ document.body.focus();
197
+
198
+ graphics.on.contextFailed.add(failure => show_message("There will be no rendering.\n\n" + failure.message));
199
+
200
+ try {
201
+ await graphics.start();
202
+ } catch (e) {
203
+ console.error(e);
204
+ return;
205
+ }
206
+
207
+ const renderer = graphics.renderer;
208
+
209
+ renderer.feature_automatic_exposure_enabled = false;
210
+ renderer.exposure_compensation = 0;
211
+
212
+ load_default_environment(scene).then(() => renderer.indicate_view_change());
213
+
214
+ /** What the device reported on its own: validation failures and the like. */
215
+ const gpu_errors = [];
216
+
217
+ renderer.graphics.device.addEventListener("uncapturederror", event => {
218
+ gpu_errors.push(event.error.message);
219
+ console.error(event.error.message);
220
+ });
221
+
222
+ let frame_index = 0;
223
+
224
+ function frame(dt) {
225
+ const [w, h] = view_size();
226
+
227
+ if (w !== graphics.viewport.size.x || h !== graphics.viewport.size.y) {
228
+ graphics.viewport.size.set(w, h);
229
+ }
230
+
231
+ controller.update();
232
+
233
+ entities.update(dt);
234
+ graphics.render(dt);
235
+
236
+ frame_index++;
237
+
238
+ if (frame_index % 30 === 0) {
239
+ const runtime = hair_system.runtime;
240
+
241
+ element("hud").textContent = `${HEADS} × ${STRANDS} strands · ${POINTS} points · groom built in ${groom_ms.toFixed(0)} ms`
242
+ + (runtime === null ? "" : ` · asked ${runtime.strands_asked} strands, ${runtime.points_asked} points`);
243
+ }
244
+ }
245
+
246
+ Object.assign(globalThis, {
247
+ graphics, renderer, scene, dataset, entities, hair_system, groom, heads, sun, camera, controller, Vector3,
248
+ __gpu_errors: gpu_errors,
249
+ __frame_index: () => frame_index,
250
+ });
251
+
252
+ if (query.has("debug")) {
253
+ globalThis.__step = (n = 1, dt = 1 / 60) => {
254
+ for (let i = 0; i < n; i++) {
255
+ frame(dt);
256
+ }
257
+
258
+ return frame_index;
259
+ };
260
+
261
+ globalThis.__ready = true;
262
+
263
+ return;
264
+ }
265
+
266
+ globalThis.__ready = true;
267
+
268
+ create_frame_loop(dt => frame(Math.min(dt, 0.05)));
269
+ }
270
+
271
+ main().catch(e => {
272
+ console.error(e);
273
+ show_message("The hair playground failed to start — see the console.\n\n" + e.message);
274
+ });
@@ -0,0 +1,54 @@
1
+ # Screen probe GI
2
+
3
+ A page to drive `ShadeIndirectLightingMode.ScreenProbes` by hand on Sponza: Lumen's Screen Probe Gather over the
4
+ probe clipmap's world (`src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js`), against the
5
+ probe clipmap alone and IBL, with the mode's debug views, the world's, and every field of `ScreenProbeSettings`.
6
+
7
+ ## Running it
8
+
9
+ ```bash
10
+ npm install
11
+ npm run dev
12
+ ```
13
+
14
+ then open <http://localhost:5173/src/shade/playground/screen_probes/index.html>.
15
+
16
+ The scene comes from `test_assets/Sponza/glTF/Sponza.gltf`, which is gitignored; `test_assets/README.md`
17
+ has the two lines that put it there. Another scene loads with `?scene=/some/other/scene.gltf`, and another mode
18
+ with `?mode=ProbeClipmap` or `?mode=IBL`.
19
+
20
+ ## The controls
21
+
22
+ | control | what it does |
23
+ |---|---|
24
+ | Indirect light | the screen probes; the probe clipmap, whose world probes are the screen probes' radiance cache and their specular; IBL |
25
+ | Debug view | under the screen probes (the world's views under the probe clipmap too, none under IBL): the screen probes' indirect diffuse (irradiance / π, after the temporal filter, before the material), where the probes stand (uniform green, adaptive red, uncovered blue), how their rays ended (screen red, bricks green, world probes blue), and the indirect specular (the probes' rough specular plus the world probes' share, before the material); the world the rays trace: the brick clipmap, the mesh SDFs, the surface caches, the brick material; the world probes' diffuse and specular |
26
+ | Path tracer (P) | the accumulating path tracer's image in place of the rasterized one, as ground truth; TAA is off while it is on and comes back after |
27
+ | Downsample | pixels between the uniform probes (`downsample_factor`); remakes the probes |
28
+ | Adaptive | the finest spacing adaptive probes are placed at (`adaptive_min_downsample_factor`); at or above the downsample none are; remakes the probes |
29
+ | Octahedron | rays a probe casts, n × n (`octahedron_resolution`); remakes the probes |
30
+ | Importance sampling (I) | rays follow the pixels' BRDF and the probe's last light (`importance_sampling`) |
31
+ | Screen traces (K) | rays go through the depth buffer before the SDF bricks (`screen_traces`) |
32
+ | Rough specular (R) | the probes light the specular of surfaces rougher than 0.3–0.4, as Lumen's do; off, the world probes light every surface's specular (`rough_specular`) |
33
+ | Spatial filter | passes between neighbouring probes (`spatial_filter_passes`); 0 runs none |
34
+ | Temporal | the most frames a pixel's diffuse and rough specular average (`temporal_frames`) |
35
+ | Sun (L), Sun height, Sun turn | the directional light, and where it stands |
36
+ | Point lights | eight shadowed point lights along the scene's long axis, which the probes' hits take as local lights |
37
+ | TAA | the resolve the integration's jitter is meant for |
38
+ | Auto exposure | the exposure metered from the frame and adapted to it; off, the factor is 2^compensation, 1 on this page |
39
+ | Bake budget | mesh SDF bricks baked a frame while the caches fill; the page starts above the engine's default so Sponza bakes in seconds |
40
+
41
+ Drag to orbit, wheel to zoom, WASD to move; G records a GPU profile capture and G again saves it, with the panel's
42
+ settings in its note. The stats line reads the frame time and the mesh SDF bake's progress; until every mesh is
43
+ resident, what is missing from the caches is missing from the rays' world.
44
+
45
+ The path tracer traces one tile a frame and reads out the least-converged tile's sample count. It keeps
46
+ its accumulation while it is off, so P flips between the two images for free on a still camera; moving
47
+ the camera, the sun or the point lights restarts it. It stops at three bounces.
48
+
49
+ ## What to expect
50
+
51
+ The diffuse is the screen probes'. The specular is theirs on rough surfaces and the world probes' on smooth ones,
52
+ blended between roughness 0.3 and 0.4 (Lumen's split between its screen probes and its traced reflections). Rays
53
+ that leave the screen and the bricks' reach take the world probes' radiance, which converge over tens of seconds after the
54
+ page loads whichever mode runs, so compare against the path tracer once the world has settled.
@@ -0,0 +1,271 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>meep — screen probe GI</title>
6
+ <style>
7
+ :root {
8
+ color-scheme: dark;
9
+ --panel: rgba(20, 22, 26, 0.88);
10
+ --line: #2b3038;
11
+ --text: #d6dae0;
12
+ --muted: #8b939f;
13
+ --pass: #55c46a;
14
+ --fail: #ff6b6b;
15
+ --warn: #e5b54a;
16
+ }
17
+
18
+ * { box-sizing: border-box; }
19
+
20
+ html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0f12; }
21
+
22
+ /* body carries tabindex so the camera controller's keyboard device has something focusable
23
+ to listen on; the focus ring around the whole viewport is not wanted */
24
+ body:focus { outline: none; }
25
+
26
+ #view { display: block; width: 100vw; height: 100vh; }
27
+
28
+ #panel {
29
+ position: fixed;
30
+ top: 12px;
31
+ left: 12px;
32
+ width: 320px;
33
+ max-height: calc(100vh - 24px);
34
+ overflow-y: auto;
35
+ padding: 12px 14px;
36
+ background: var(--panel);
37
+ border: 1px solid var(--line);
38
+ border-radius: 8px;
39
+ backdrop-filter: blur(6px);
40
+ color: var(--text);
41
+ font: 13px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
42
+ }
43
+
44
+ #panel h1 { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
45
+ #panel h2 { font-size: 12px; font-weight: 600; margin: 0 0 4px; color: var(--muted); }
46
+
47
+ label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
48
+ label input[type="checkbox"] { margin: 0; }
49
+ label .hint { color: var(--muted); font-size: 11.5px; }
50
+ label > span:first-child { flex: 0 0 96px; }
51
+
52
+ select, input[type="number"] {
53
+ flex: 1 1 auto;
54
+ min-width: 0;
55
+ font: 12px system-ui, -apple-system, Segoe UI, sans-serif;
56
+ padding: 3px 6px;
57
+ border-radius: 5px;
58
+ border: 1px solid var(--line);
59
+ background: #14161a;
60
+ color: var(--text);
61
+ }
62
+
63
+ input[type="range"] { flex: 1 1 auto; min-width: 0; }
64
+
65
+ output { flex: 0 0 34px; text-align: right; color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
66
+
67
+ hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
68
+
69
+ #status { font-size: 12px; color: var(--muted); word-break: break-word; }
70
+ #status.pass { color: var(--pass); }
71
+ #status.fail { color: var(--fail); }
72
+ #status.warn { color: var(--warn); }
73
+ #status.recording { color: var(--fail); }
74
+
75
+ #stats {
76
+ margin-top: 6px;
77
+ font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
78
+ color: var(--text);
79
+ white-space: pre;
80
+ }
81
+
82
+ p.note { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
83
+ </style>
84
+ </head>
85
+ <body tabindex="0">
86
+
87
+ <canvas id="view"></canvas>
88
+
89
+ <div id="panel">
90
+ <h1>Screen probe GI</h1>
91
+
92
+ <label>
93
+ <span>Indirect light</span>
94
+ <select id="indirect">
95
+ <option value="ScreenProbes" selected>Screen probes</option>
96
+ <option value="ProbeClipmap">Probe clipmap — the world probes alone</option>
97
+ <option value="IBL">IBL</option>
98
+ </select>
99
+ </label>
100
+
101
+ <label>
102
+ <span>Debug view</span>
103
+ <select id="debug_view">
104
+ <option value="none" selected>None</option>
105
+ <optgroup label="Screen probes">
106
+ <option value="screen:IndirectDiffuse">Indirect diffuse — irradiance / π, before the material</option>
107
+ <option value="screen:ProbePlacement">Probe placement — uniform green, adaptive red, uncovered blue</option>
108
+ <option value="screen:TraceKinds">Trace kinds — screen red, bricks green, world probes blue</option>
109
+ <option value="screen:IndirectSpecular">Indirect specular — rough from the probes, smooth from the world probes, before the material</option>
110
+ </optgroup>
111
+ <optgroup label="The world the rays trace">
112
+ <option value="world:BrickClipmap">Brick clipmap — what the brick traces see</option>
113
+ <option value="world:MeshSDF">Mesh SDF — the geometry caches</option>
114
+ <option value="world:MeshSurfaces">Mesh surfaces — each mesh's surface cache</option>
115
+ <option value="world:BrickMaterial">Brick material — the hits' albedo</option>
116
+ <option value="world:BrickMetalRough">Brick material — the hits' metal (R) and rough (G)</option>
117
+ </optgroup>
118
+ <optgroup label="World probes">
119
+ <option value="world:IndirectDiffuse">Indirect diffuse — the world probes' irradiance / π</option>
120
+ <option value="world:IndirectSpecular">Indirect specular — the world probes' radiance</option>
121
+ </optgroup>
122
+ </select>
123
+ </label>
124
+
125
+ <label>
126
+ <input type="checkbox" id="path_tracing">
127
+ <span>Path tracer <span class="hint">— ground truth; P flips it</span></span>
128
+ </label>
129
+
130
+ <hr>
131
+
132
+ <h2>Probes</h2>
133
+
134
+ <label>
135
+ <span>Downsample</span>
136
+ <select id="downsample_factor">
137
+ <option value="2">1 probe / 2×2 pixels</option>
138
+ <option value="4">1 probe / 4×4 pixels</option>
139
+ <option value="8">1 probe / 8×8 pixels</option>
140
+ <option value="16" selected>1 probe / 16×16 pixels</option>
141
+ <option value="32">1 probe / 32×32 pixels</option>
142
+ </select>
143
+ </label>
144
+
145
+ <label>
146
+ <span>Adaptive</span>
147
+ <select id="adaptive_min_downsample_factor">
148
+ <option value="1">down to 1×1 pixels</option>
149
+ <option value="2">down to 2×2 pixels</option>
150
+ <option value="4" selected>down to 4×4 pixels</option>
151
+ <option value="8">down to 8×8 pixels</option>
152
+ <option value="16">down to 16×16 pixels</option>
153
+ <option value="32">down to 32×32 pixels</option>
154
+ </select>
155
+ </label>
156
+
157
+ <label>
158
+ <span>Octahedron</span>
159
+ <select id="octahedron_resolution">
160
+ <option value="4">4×4 rays a probe</option>
161
+ <option value="8" selected>8×8 rays a probe</option>
162
+ <option value="16">16×16 rays a probe</option>
163
+ </select>
164
+ </label>
165
+
166
+ <label>
167
+ <input type="checkbox" id="importance_sampling">
168
+ <span>Importance sampling <span class="hint">— rays follow the BRDF and last frame's light; I flips it</span></span>
169
+ </label>
170
+
171
+ <label>
172
+ <input type="checkbox" id="screen_traces">
173
+ <span>Screen traces <span class="hint">— the depth buffer before the SDF bricks; K flips it</span></span>
174
+ </label>
175
+
176
+ <label>
177
+ <input type="checkbox" id="rough_specular">
178
+ <span>Rough specular <span class="hint">— the probes light rough surfaces' specular; R flips it</span></span>
179
+ </label>
180
+
181
+ <label>
182
+ <span>Spatial filter</span>
183
+ <input type="number" id="spatial_filter_passes" min="0" step="1">
184
+ <span class="hint">passes</span>
185
+ </label>
186
+
187
+ <label>
188
+ <span>Temporal</span>
189
+ <input type="number" id="temporal_frames" min="1" step="1">
190
+ <span class="hint">frames at most</span>
191
+ </label>
192
+
193
+ <p class="note">
194
+ Downsample, adaptive and octahedron make the probes again, and their history starts from
195
+ nothing; the rest take the next frame. Adaptive probes stop at the finest spacing given;
196
+ at or above the downsample, none are placed.
197
+ </p>
198
+
199
+ <hr>
200
+
201
+ <h2>Lights</h2>
202
+
203
+ <label>
204
+ <input type="checkbox" id="sun" checked>
205
+ <span>Sun <span class="hint">— the directional light; L flips it</span></span>
206
+ </label>
207
+
208
+ <label>
209
+ <span>Sun height</span>
210
+ <input type="range" id="sun_elevation" min="2" max="88" value="62">
211
+ <output id="sun_elevation_value"></output>
212
+ </label>
213
+
214
+ <label>
215
+ <span>Sun turn</span>
216
+ <input type="range" id="sun_azimuth" min="0" max="359" value="80">
217
+ <output id="sun_azimuth_value"></output>
218
+ </label>
219
+
220
+ <label>
221
+ <input type="checkbox" id="point_lights">
222
+ <span>Point lights <span class="hint">— eight along the nave, shadowed</span></span>
223
+ </label>
224
+
225
+ <hr>
226
+
227
+ <label>
228
+ <input type="checkbox" id="taa" checked>
229
+ <span>TAA <span class="hint">— resolves the integration's jitter</span></span>
230
+ </label>
231
+
232
+ <label>
233
+ <input type="checkbox" id="auto_exposure" checked>
234
+ <span>Auto exposure <span class="hint">— off, the exposure is 1</span></span>
235
+ </label>
236
+
237
+ <label>
238
+ <span>Bake budget</span>
239
+ <input type="number" id="bake_budget" min="1" step="1">
240
+ </label>
241
+ <p class="note">
242
+ Mesh SDF bricks baked a frame while the geometry caches fill. The engine's default is a
243
+ frame-time knob; this page starts higher so Sponza is whole in seconds, not minutes.
244
+ </p>
245
+
246
+ <hr>
247
+
248
+ <div id="status"></div>
249
+ <div id="stats"></div>
250
+
251
+ <p class="note">
252
+ Drag to orbit, wheel to zoom, WASD to move; G records a GPU profile and G again saves it.
253
+ Turn the camera to watch what the screen traces lose at the edges go to the bricks.
254
+ </p>
255
+ </div>
256
+
257
+ <script type="module">
258
+ import { start } from './main.js';
259
+
260
+ start().catch(error => {
261
+ const status = document.getElementById('status');
262
+
263
+ status.className = 'fail';
264
+ status.textContent = String(error?.message ?? error);
265
+
266
+ console.error(error);
267
+ });
268
+ </script>
269
+
270
+ </body>
271
+ </html>
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Stand the page up. Called by the page rather than run on import, so that nothing here touches the DOM
3
+ * until there is one.
4
+ *
5
+ * @returns {Promise<void>}
6
+ */
7
+ export function start(): Promise<void>;
8
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../src/shade/playground/screen_probes/main.js"],"names":[],"mappings":"AA2DA;;;;;GAKG;AACH,yBAFa,QAAQ,IAAI,CAAC,CA+czB"}