@woosh/meep-engine 3.53.0 → 3.55.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.
- package/package.json +1 -1
- package/src/core/math/noise/worley_noise_2d.d.ts +14 -0
- package/src/core/math/noise/worley_noise_2d.d.ts.map +1 -0
- package/src/core/math/noise/worley_noise_2d.js +74 -0
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.d.ts +6 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +363 -325
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.d.ts +93 -14
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +322 -183
- package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.d.ts +9 -0
- package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.js +110 -83
- package/src/engine/graphics/texture/atlas/SpriteAtlas.d.ts +42 -0
- package/src/engine/graphics/texture/atlas/SpriteAtlas.d.ts.map +1 -0
- package/src/engine/{graphics3/decal/DecalAtlas.js → graphics/texture/atlas/SpriteAtlas.js} +202 -194
- package/src/engine/{graphics3/decal/DecalAtlasFill.d.ts → graphics/texture/atlas/SpriteAtlasFill.d.ts} +4 -4
- package/src/engine/graphics/texture/atlas/SpriteAtlasFill.d.ts.map +1 -0
- package/src/engine/graphics/texture/atlas/SpriteAtlasFill.js +30 -0
- package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts +7 -0
- package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/TextureAtlas.js +11 -1
- package/src/engine/{graphics3/decal/decal_atlas_border.d.ts → graphics/texture/atlas/sprite_atlas_border.d.ts} +12 -12
- package/src/engine/graphics/texture/atlas/sprite_atlas_border.d.ts.map +1 -0
- package/src/engine/{graphics3/decal/decal_atlas_border.js → graphics/texture/atlas/sprite_atlas_border.js} +69 -69
- package/src/engine/graphics3/DecalSystem.d.ts.map +1 -1
- package/src/engine/graphics3/DecalSystem.js +447 -450
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +9 -22
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUParticleEmitterSystem.js +892 -951
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/generation/foliage/FOLIAGE_DESIGN.md +2 -1
- package/src/generation/foliage/config/BarkMaterialConfig.d.ts +4 -3
- package/src/generation/foliage/config/BarkMaterialConfig.d.ts.map +1 -1
- package/src/generation/foliage/config/BarkMaterialConfig.js +6 -6
- package/src/generation/foliage/config/FoliageBarkType.d.ts +11 -0
- package/src/generation/foliage/config/FoliageBarkType.d.ts.map +1 -0
- package/src/generation/foliage/config/FoliageBarkType.js +16 -0
- package/src/generation/foliage/config/FoliageMaterialConfig.d.ts +58 -5
- package/src/generation/foliage/config/FoliageMaterialConfig.d.ts.map +1 -1
- package/src/generation/foliage/config/FoliageMaterialConfig.js +279 -181
- package/src/generation/foliage/index.d.ts +2 -1
- package/src/generation/foliage/index.js +44 -43
- package/src/generation/foliage/material/make_bark_material.d.ts.map +1 -1
- package/src/generation/foliage/material/make_bark_material.js +23 -95
- package/src/generation/foliage/material/make_foliage_material.d.ts +29 -3
- package/src/generation/foliage/material/make_foliage_material.d.ts.map +1 -1
- package/src/generation/foliage/material/make_foliage_material.js +605 -359
- package/src/generation/foliage/mesh/branch_collar_project.d.ts.map +1 -1
- package/src/generation/foliage/mesh/branch_collar_project.js +205 -203
- package/src/generation/foliage/mesh/foliage_collect_attachments.d.ts +15 -0
- package/src/generation/foliage/mesh/foliage_collect_attachments.d.ts.map +1 -1
- package/src/generation/foliage/mesh/foliage_collect_attachments.js +569 -502
- package/src/generation/foliage/mesh/tree_mesh_build_bark.d.ts.map +1 -1
- package/src/generation/foliage/mesh/tree_mesh_build_bark.js +1049 -1047
- package/src/generation/foliage/mesh/tree_mesh_build_foliage.d.ts +2 -1
- package/src/generation/foliage/mesh/tree_mesh_build_foliage.d.ts.map +1 -1
- package/src/generation/foliage/mesh/tree_mesh_build_foliage.js +454 -415
- package/src/generation/foliage/presets/make_tree_species_preset.d.ts.map +1 -1
- package/src/generation/foliage/presets/make_tree_species_preset.js +870 -837
- package/src/generation/foliage/skeleton/crown_envelope_evaluate.js +121 -121
- package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.d.ts +10 -7
- package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.d.ts.map +1 -1
- package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.js +206 -179
- package/src/generation/foliage/skeleton/tree_skeleton_grow.d.ts.map +1 -1
- package/src/generation/foliage/skeleton/tree_skeleton_grow.js +1871 -1104
- package/src/shade/RENDERER_CONTRACT.md +5 -2
- package/src/shade/device/SHADE_DEVICE_FLOOR.d.ts.map +1 -1
- package/src/shade/device/SHADE_DEVICE_FLOOR.js +2 -0
- package/src/shade/playground/foliage_wind/foliage_world.d.ts +6 -0
- package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
- package/src/shade/playground/foliage_wind/foliage_world.js +602 -593
- package/src/shade/playground/foliage_wind/index.html +260 -254
- package/src/shade/playground/foliage_wind/main.js +275 -263
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +1 -1
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +1 -1
- package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts +3 -3
- package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts.map +1 -1
- package/src/shade/renderer/hiz/HierarchicalZBuffer.js +350 -294
- package/src/shade/renderer/hiz/generate_downsampler_code.d.ts +0 -2
- package/src/shade/renderer/hiz/generate_downsampler_code.d.ts.map +1 -1
- package/src/shade/renderer/hiz/generate_downsampler_code.js +99 -100
- package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts +15 -0
- package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -0
- package/src/shade/renderer/hiz/hzb_pick_alignment.js +148 -0
- package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts +28 -0
- package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts.map +1 -0
- package/src/shade/renderer/hiz/hzb_plan_reduction_steps.js +58 -0
- package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts +5 -5
- package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts.map +1 -1
- package/src/shade/renderer/hiz/shader_hzb_reduce_any.js +57 -67
- package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts +3 -3
- package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts.map +1 -1
- package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.js +111 -112
- package/src/shade/renderer/hiz/shader_hzb_spd.d.ts +5 -0
- package/src/shade/renderer/hiz/shader_hzb_spd.d.ts.map +1 -0
- package/src/shade/renderer/hiz/shader_hzb_spd.js +160 -0
- package/src/shade/renderer/light/GPULightCollection.d.ts +8 -0
- package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
- package/src/shade/renderer/light/GPULightCollection.js +67 -0
- package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts +7 -0
- package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts.map +1 -0
- package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.js +13 -0
- package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts +10 -0
- package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts.map +1 -0
- package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.js +72 -0
- package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +39 -0
- package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -0
- package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +90 -0
- package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts +12 -0
- package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts.map +1 -0
- package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.js +56 -0
- package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +31 -0
- package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -0
- package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +196 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts +10 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +163 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts +4 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts.map +1 -0
- package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.js +137 -0
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.js +4 -3
- package/src/shade/renderer/particles/graph_particles_avboit.d.ts +4 -3
- package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles_avboit.js +28 -11
- package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +9 -13
- package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +25 -20
- package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +21 -38
- package/src/shade/renderer/postprocess/denoise/fragment_shader_denoise_ao.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/denoise/fragment_shader_denoise_ao.js +154 -147
- package/src/shade/renderer/postprocess/gtao/GTAO.d.ts +2 -1
- package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/GTAO.js +5 -1
- package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts +8 -0
- package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.js +10 -1
- package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +5 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.d.ts +22 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.js +33 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.d.ts +22 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.js +56 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.d.ts +13 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.js +42 -0
- package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts +2 -1
- package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.js +382 -357
- package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +414 -410
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/ssr/prefilter/NOTES.md +0 -7
- package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.js +62 -62
- package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts +6 -0
- package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.js +19 -0
- package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.js +16 -10
- package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.js +118 -117
- package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts +41 -7
- package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts.map +1 -1
- package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.js +162 -58
- package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.js +1 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +10 -12
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +583 -606
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +1 -1
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +640 -640
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts +113 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +484 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +50 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +60 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +25 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +47 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts +74 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.js +173 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts +26 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +83 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts +36 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.js +129 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts +121 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +370 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts +16 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.js +191 -0
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.js +1 -1
- package/src/engine/graphics3/decal/DecalAtlas.d.ts +0 -43
- package/src/engine/graphics3/decal/DecalAtlas.d.ts.map +0 -1
- package/src/engine/graphics3/decal/DecalAtlasFill.d.ts.map +0 -1
- package/src/engine/graphics3/decal/DecalAtlasFill.js +0 -32
- package/src/engine/graphics3/decal/decal_atlas_border.d.ts.map +0 -1
- package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.d.ts +0 -26
- package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.d.ts.map +0 -1
- package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.js +0 -268
- package/src/shade/renderer/postprocess/ssr/copy_shader_f32.d.ts +0 -3
- package/src/shade/renderer/postprocess/ssr/copy_shader_f32.d.ts.map +0 -1
- package/src/shade/renderer/postprocess/ssr/copy_shader_f32.js +0 -32
- package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts +0 -17
- package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts.map +0 -1
- package/src/shade/renderer/postprocess/ssr/depth_max_shader.js +0 -98
- package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts +0 -23
- package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts.map +0 -1
- package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.js +0 -118
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts +0 -15
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.js +0 -49
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts +0 -17
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +0 -50
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts +0 -35
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.js +0 -105
- package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts +0 -35
- package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +0 -80
- package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.d.ts +0 -10
- package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.js +0 -51
- package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts +0 -28
- package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.js +0 -39
- package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts +0 -48
- package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +0 -121
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts +0 -28
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +0 -237
|
@@ -1,357 +1,382 @@
|
|
|
1
|
-
import { BlendState } from "../../../descriptor/blend/BlendState.js";
|
|
2
|
-
import { CAMERA_UNIFORM_STRUCT } from "../../camera/CAMERA_UNIFORM_STRUCT.js";
|
|
3
|
-
import { DEPTH_STENCIL_FOREGROUND_ONLY } from "../../depth/DEPTH_STENCIL_FOREGROUND_ONLY.js";
|
|
4
|
-
import { chunk_project_position_from_depth } from "../../shader/chunk/camera/chunk_project_position_from_depth.js";
|
|
5
|
-
import { chunk_project_view_position_from_depth } from "../../shader/chunk/camera/chunk_project_view_position_from_depth.js";
|
|
6
|
-
import { chunk_get_view_space_depth } from "../../shader/chunk/depth/chunk_get_view_space_depth.js";
|
|
7
|
-
import { chunk_mat4_extract_position } from "../../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
|
|
8
|
-
import { chunk_decode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js";
|
|
9
|
-
import { chunk_encode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_encode_g_buffer_normal.js";
|
|
10
|
-
import { chunk_v3_matrix4_rotate } from "../../shader/chunk/geometry/vec3/chunk_v3_matrix4_rotate.js";
|
|
11
|
-
import { chunk_fast_acos } from "../../shader/chunk/math/fast/chunk_fast_acos.js";
|
|
12
|
-
import { PI_DECLARATION } from "../../shader/chunk/math/PI_DECLARATION.js";
|
|
13
|
-
import { PI_HALF_DECLARATION } from "../../shader/chunk/math/PI_HALF_DECLARATION.js";
|
|
14
|
-
import { chunk_spatio_temporal_noise_r2_64 } from "../../shader/chunk/noise/chunk_spatio_temporal_noise_r2_64.js";
|
|
15
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
16
|
-
import { ImageShader } from "../../shader/ImageShader.js";
|
|
17
|
-
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
18
|
-
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
19
|
-
import { HILBERT_R2_INDEX_TEXTURE } from "../../texture/noise/HILBERT_R2_INDEX_TEXTURE.js";
|
|
20
|
-
import { SAMPLER_NEAREST } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
.addTexture("
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
let
|
|
137
|
-
let
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
// line
|
|
184
|
-
let
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
//
|
|
239
|
-
let
|
|
240
|
-
let
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
let
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
1
|
+
import { BlendState } from "../../../descriptor/blend/BlendState.js";
|
|
2
|
+
import { CAMERA_UNIFORM_STRUCT } from "../../camera/CAMERA_UNIFORM_STRUCT.js";
|
|
3
|
+
import { DEPTH_STENCIL_FOREGROUND_ONLY } from "../../depth/DEPTH_STENCIL_FOREGROUND_ONLY.js";
|
|
4
|
+
import { chunk_project_position_from_depth } from "../../shader/chunk/camera/chunk_project_position_from_depth.js";
|
|
5
|
+
import { chunk_project_view_position_from_depth } from "../../shader/chunk/camera/chunk_project_view_position_from_depth.js";
|
|
6
|
+
import { chunk_get_view_space_depth } from "../../shader/chunk/depth/chunk_get_view_space_depth.js";
|
|
7
|
+
import { chunk_mat4_extract_position } from "../../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
|
|
8
|
+
import { chunk_decode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js";
|
|
9
|
+
import { chunk_encode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_encode_g_buffer_normal.js";
|
|
10
|
+
import { chunk_v3_matrix4_rotate } from "../../shader/chunk/geometry/vec3/chunk_v3_matrix4_rotate.js";
|
|
11
|
+
import { chunk_fast_acos } from "../../shader/chunk/math/fast/chunk_fast_acos.js";
|
|
12
|
+
import { PI_DECLARATION } from "../../shader/chunk/math/PI_DECLARATION.js";
|
|
13
|
+
import { PI_HALF_DECLARATION } from "../../shader/chunk/math/PI_HALF_DECLARATION.js";
|
|
14
|
+
import { chunk_spatio_temporal_noise_r2_64 } from "../../shader/chunk/noise/chunk_spatio_temporal_noise_r2_64.js";
|
|
15
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
16
|
+
import { ImageShader } from "../../shader/ImageShader.js";
|
|
17
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
18
|
+
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
19
|
+
import { HILBERT_R2_INDEX_TEXTURE } from "../../texture/noise/HILBERT_R2_INDEX_TEXTURE.js";
|
|
20
|
+
import { SAMPLER_NEAREST } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
|
|
21
|
+
import { chunk_gtao_compute_mip_level } from "./chunk_gtao_compute_mip_level.js";
|
|
22
|
+
import { chunk_gtao_sample_depth } from "./chunk_gtao_sample_depth.js";
|
|
23
|
+
import { chunk_integrate_bent_normal_fast } from "./chunk_integrate_bent_normal_fast.js";
|
|
24
|
+
import {
|
|
25
|
+
GTAO_DEPTH_MIP_LEVELS,
|
|
26
|
+
GTAO_DEPTH_MIP_SAMPLING_OFFSET,
|
|
27
|
+
GTAO_EFFECT_FALLOFF_RANGE,
|
|
28
|
+
GTAO_EFFECT_RADIUS,
|
|
29
|
+
GTAO_QUALITY_PROFILES,
|
|
30
|
+
GTAO_QUALITY_TYPE
|
|
31
|
+
} from "./GTAO_CONSTANTS.js";
|
|
32
|
+
import { GTAO_RENDER_SETTINGS } from "./GTAO_RENDER_SETTINGS.js";
|
|
33
|
+
|
|
34
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
35
|
+
|
|
36
|
+
// per-pass, four bytes, read-only: immediate data rather than a uniform buffer.
|
|
37
|
+
//
|
|
38
|
+
// The uniform carried a `frame_index: 0` default, which does not travel: immediate data has no
|
|
39
|
+
// default, and a dispatch that never wrote its slots is refused rather than reading zero. GTAO
|
|
40
|
+
// passes frame_index on every dispatch, so nothing relied on it.
|
|
41
|
+
resources.setImmediate("settings", GTAO_RENDER_SETTINGS);
|
|
42
|
+
resources.createGroup()
|
|
43
|
+
.addTexture("tDepth")
|
|
44
|
+
.addTexture("tHZB")
|
|
45
|
+
.addSampler("sPoint", "non-filtering", SAMPLER_NEAREST)
|
|
46
|
+
.addTexture("tNormal", "uint")
|
|
47
|
+
.addTexture("tNoise", "uint", "2d", false, HILBERT_R2_INDEX_TEXTURE)
|
|
48
|
+
.addUniform("camera", CAMERA_UNIFORM_STRUCT)
|
|
49
|
+
;
|
|
50
|
+
|
|
51
|
+
const QUALITY_SETTINGS = GTAO_QUALITY_PROFILES[GTAO_QUALITY_TYPE.Medium];
|
|
52
|
+
|
|
53
|
+
// the import paths these already had, kept working
|
|
54
|
+
export { GTAO_DEPTH_MIP_LEVELS, GTAO_DEPTH_MIP_SAMPLING_OFFSET, GTAO_EFFECT_FALLOFF_RANGE, GTAO_EFFECT_RADIUS };
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
based on https://github.com/GameTechDev/XeGTAO/tree/e7698f874e90f2516fca26c696ec3cd2c70e505a
|
|
58
|
+
|
|
59
|
+
The horizon search reconstructs its samples in view space (2026-10-16). Measured on an RTX 4090 (Chrome,
|
|
60
|
+
D3D12), the VSM playground's courtyard, Medium quality, TAA on. Arms swapped by pipeline every 4 frames
|
|
61
|
+
inside one capture, 3 captures of 6 s each. GTAO's time, and the old world-space path against the new:
|
|
62
|
+
|
|
63
|
+
near view (walls close) overview (geometry far)
|
|
64
|
+
1898 x 982 185 µs, old/new 1.00 84 µs, old/new 1.055 (p10 1.049)
|
|
65
|
+
2538 x 1342 364 µs, old/new 1.00 179 µs, old/new 1.041 (p10 1.048-1.055)
|
|
66
|
+
|
|
67
|
+
Up close a 1 m radius spreads the 16 samples over hundreds of pixels and the pass waits on depth fetches:
|
|
68
|
+
deleting the reconstruction outright bought nothing there (1.008, 1.010). At a distance the fetches hit
|
|
69
|
+
cache and the arithmetic shows: deleting it bought 9.4% and 6.6%, and the view-space path recovers half.
|
|
70
|
+
The same frame replayed through both: visibility differs in 0.1-0.18% of pixels, by one f16 step
|
|
71
|
+
(0.00098); bent normals in 3-7% of pixels, by at most 0.014 degrees.
|
|
72
|
+
|
|
73
|
+
HZB depth mipmap sampling (2026-10-23, `chunk_gtao_compute_mip_level` + `chunk_gtao_sample_depth`), same
|
|
74
|
+
courtyard setup, 3 captures of 60 frames each, arms swapped by pipeline every 4 frames. `mip0` (all taps
|
|
75
|
+
from `tDepth` mip 0) against `hzb_slope` (`gtao_resolve_hzb_depth` slope-aware filter) and `hzb_max`
|
|
76
|
+
(`tHZB.y` only):
|
|
77
|
+
|
|
78
|
+
near view (walls close) overview (geometry far)
|
|
79
|
+
1898 x 982 mip0 192.5 µs -> hzb_slope 72.7 µs (2.65x) mip0 91.1 µs -> hzb_slope 88.1 µs (1.03x)
|
|
80
|
+
-> hzb_max 66.6 µs (2.89x) -> hzb_max 79.9 µs (1.14x)
|
|
81
|
+
2538 x 1342 mip0 362.5 µs -> hzb_slope 142.3 µs (2.55x) mip0 180.2 µs -> hzb_slope 151.6 µs (1.19x)
|
|
82
|
+
-> hzb_max 123.9 µs (2.93x) -> hzb_max 135.2 µs (1.33x)
|
|
83
|
+
|
|
84
|
+
Same-frame quality replay against `mip0` (1898 x 982 / 2538 x 1342):
|
|
85
|
+
- overview: `hzb_slope` PSNR 52.74 / 48.78 dB (mean |dv| 0.00016 / 0.00027, bent normal mean 0.012° / 0.021°),
|
|
86
|
+
beating `hzb_max` (50.50 / 47.15 dB, 3.5x larger mean |dv| and 10x stronger darkening bias on slopes) and
|
|
87
|
+
unfiltered `0.5*(hzb.x+hzb.y)` (46.92 / 42.96 dB, 2.0x higher RMSE from silhouette shrink-wrap).
|
|
88
|
+
- near: `hzb_slope` PSNR 26.04 / 26.25 dB (mean |dv| 0.0107 / 0.0102, bent normal mean 0.91° / 0.87°),
|
|
89
|
+
vs `hzb_max` (25.52 / 25.65 dB, 1.6x stronger darkening bias) and unfiltered avg (20.66 / 20.79 dB).
|
|
90
|
+
*/
|
|
91
|
+
const body = CodeChunk.from(
|
|
92
|
+
//language=WGSL
|
|
93
|
+
`
|
|
94
|
+
const scale = 1.0;
|
|
95
|
+
|
|
96
|
+
// small crevices more important than big surfaces
|
|
97
|
+
const sampleDistributionPower = 2.0;
|
|
98
|
+
|
|
99
|
+
const SLICE_COUNT = ${QUALITY_SETTINGS.slices};
|
|
100
|
+
|
|
101
|
+
const STEPS = ${QUALITY_SETTINGS.steps};
|
|
102
|
+
|
|
103
|
+
struct Output{
|
|
104
|
+
@location(0) visibility: vec2<f32>, // first 2 moment
|
|
105
|
+
@location(1) bent_normal: vec2<u32>, // octahedral encoding
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@fragment
|
|
109
|
+
fn main(
|
|
110
|
+
@builtin(position) coord: vec4<f32>,
|
|
111
|
+
@location(0) uv: vec2<f32>,
|
|
112
|
+
) -> Output {
|
|
113
|
+
|
|
114
|
+
// fadeout precompute optimisation
|
|
115
|
+
const falloffRange = ${GTAO_EFFECT_FALLOFF_RANGE} * ${GTAO_EFFECT_RADIUS};
|
|
116
|
+
|
|
117
|
+
const falloffFrom = ${GTAO_EFFECT_RADIUS} * (1.0 - ${GTAO_EFFECT_FALLOFF_RANGE});
|
|
118
|
+
const falloffMul = -1.0 / ( falloffRange );
|
|
119
|
+
const falloffAdd = falloffFrom / ( falloffRange ) + 1.0;
|
|
120
|
+
|
|
121
|
+
let texel_position_u32 = vec2<u32>(coord.xy);
|
|
122
|
+
|
|
123
|
+
let ViewportSize = textureDimensions(tDepth);
|
|
124
|
+
let ViewportPixelSize = 1. / vec2<f32>(ViewportSize);
|
|
125
|
+
|
|
126
|
+
var device_depth = textureLoad(tDepth, texel_position_u32, 0).r;
|
|
127
|
+
|
|
128
|
+
// NOTE: no need to reject based on depth, already handled via depthStencil
|
|
129
|
+
|
|
130
|
+
var viewspaceZ = get_view_space_depth(device_depth, camera);
|
|
131
|
+
|
|
132
|
+
// Move center pixel slightly towards camera to avoid imprecision artifacts due to depth buffer imprecision; offset depends on depth texture format used
|
|
133
|
+
viewspaceZ *= 0.99999; // this is good for FP32 depth buffer
|
|
134
|
+
|
|
135
|
+
let position_ws = project_position_from_depth(uv, device_depth, camera.view_projection_matrix_inverse );
|
|
136
|
+
let view_position_ws = mat4_extract_position(camera.view_matrix_inverse);
|
|
137
|
+
let view_direction_ws = normalize(view_position_ws - position_ws);
|
|
138
|
+
|
|
139
|
+
// The horizon search below only measures distances and angles, which the view rotation preserves, so it
|
|
140
|
+
// runs in view space: a sample there is 4 multiply-adds from the projection's inverse instead of 16
|
|
141
|
+
// from the view-projection's. Slices and the bent normal stay in world space.
|
|
142
|
+
let position_vs = project_view_position_from_depth(uv, device_depth, camera.projection_matrix_inverse);
|
|
143
|
+
let view_direction_vs = normalize(-position_vs);
|
|
144
|
+
|
|
145
|
+
let view_normal_ws = decode_g_buffer_normal(textureLoad(tNormal, texel_position_u32, 0).xy); // shading normal
|
|
146
|
+
|
|
147
|
+
let noiseTexel = spatio_temporal_noise_r2_64(texel_position_u32, settings.frame_index, tNoise);
|
|
148
|
+
|
|
149
|
+
let noiseSample = noiseTexel.x;
|
|
150
|
+
let noiseSlice = noiseTexel.y;
|
|
151
|
+
|
|
152
|
+
// quality settings / tweaks / hacks
|
|
153
|
+
const pixelTooCloseThreshold = 1.3; // if the offset is under approx pixel size (pixelTooCloseThreshold), push it out to the minimum distance
|
|
154
|
+
|
|
155
|
+
// approx viewspace pixel size at pixCoord; approximation of NDCToViewspace( normalizedScreenPos.xy + consts.ViewportPixelSize.xy, pixCenterPos.z ).xy - pixCenterPos.xy;
|
|
156
|
+
// device_depth_to_view_space.z = 1/a = aspect * tan(fovY/2) = tan(fovX/2), pairs with horizontal pixel size.
|
|
157
|
+
// factor of 2 converts a single uv-step (= 1 pixel) into the matching ndc-step (range 2 wide).
|
|
158
|
+
let NDCToViewMul_x_PixelSize = 2.0 * camera.device_depth_to_view_space.z * ViewportPixelSize.x;
|
|
159
|
+
let pixelDirRBViewspaceSizeAtCenterZ = viewspaceZ * NDCToViewMul_x_PixelSize;
|
|
160
|
+
|
|
161
|
+
let screenspaceRadius = abs( ${GTAO_EFFECT_RADIUS} / pixelDirRBViewspaceSizeAtCenterZ);
|
|
162
|
+
|
|
163
|
+
var visibility = 0.0;
|
|
164
|
+
var bent_normal:vec3<f32>;
|
|
165
|
+
|
|
166
|
+
// this is the min distance to start sampling from to avoid sampling from the center pixel (no useful data obtained from sampling center pixel)
|
|
167
|
+
let minS = pixelTooCloseThreshold / screenspaceRadius;
|
|
168
|
+
|
|
169
|
+
const INV_SLICE_COUNT = 1.0 / f32(SLICE_COUNT);
|
|
170
|
+
|
|
171
|
+
for (var slice = 0; slice < SLICE_COUNT; slice++) {
|
|
172
|
+
|
|
173
|
+
let sliceK = ( f32(slice) + noiseSlice ) * INV_SLICE_COUNT;
|
|
174
|
+
|
|
175
|
+
// lines 5,6 from the paper
|
|
176
|
+
let phi = sliceK * PI; // slice angle
|
|
177
|
+
|
|
178
|
+
let cosPhi = cos(phi);
|
|
179
|
+
let sinPhi = sin(phi);
|
|
180
|
+
|
|
181
|
+
let omega = vec2(cosPhi, -sinPhi) * screenspaceRadius;
|
|
182
|
+
|
|
183
|
+
// line 8 from the paper
|
|
184
|
+
let sliceViewDir = vec3(cosPhi, sinPhi, 0.0);
|
|
185
|
+
let sliceWorldDir = v3_matrix4_rotate(sliceViewDir, camera.view_matrix_inverse);
|
|
186
|
+
|
|
187
|
+
// line 9 from the paper
|
|
188
|
+
// NOTE: optimized with FMA, readability suffers
|
|
189
|
+
let orthoWorldDir = fma( vec3( -dot(sliceWorldDir, view_direction_ws) ), view_direction_ws, sliceWorldDir );
|
|
190
|
+
|
|
191
|
+
// line 10 from the paper
|
|
192
|
+
// axisVec is orthogonal to sliceViewDir and viewVec, used to define projectedNormal
|
|
193
|
+
let axisVec = normalize( cross(orthoWorldDir, view_direction_ws) );
|
|
194
|
+
|
|
195
|
+
// line 11 from paper
|
|
196
|
+
let projectedWorldNormal = fma( -axisVec, vec3( dot(view_normal_ws, axisVec) ), view_normal_ws );
|
|
197
|
+
|
|
198
|
+
// line 13 from the paper
|
|
199
|
+
let signNorm = sign( dot( orthoWorldDir, projectedWorldNormal ) );
|
|
200
|
+
|
|
201
|
+
// line 14 from the paper
|
|
202
|
+
var projectedNormalVecLength = length(projectedWorldNormal);
|
|
203
|
+
let norm_cos = saturate( dot( projectedWorldNormal, view_direction_ws ) / projectedNormalVecLength );
|
|
204
|
+
|
|
205
|
+
// line 15 from the paper
|
|
206
|
+
let n = signNorm * fast_acos(norm_cos);
|
|
207
|
+
|
|
208
|
+
// this is a lower weight target; not using -1 as in the original paper because it is under horizon, so a 'weight' has different meaning based on the normal
|
|
209
|
+
let lowHorizonCos0 = cos(n + PI_HALF);
|
|
210
|
+
let lowHorizonCos1 = -lowHorizonCos0; // cos(n - PI_HALF);
|
|
211
|
+
|
|
212
|
+
// lines 17, 18 from the paper, manually unrolled the 'side' loop
|
|
213
|
+
var horizonCos0 = lowHorizonCos0; // -1
|
|
214
|
+
var horizonCos1 = lowHorizonCos1; // -1
|
|
215
|
+
|
|
216
|
+
const INV_STEPS = 1.0 / f32(STEPS);
|
|
217
|
+
|
|
218
|
+
for (var step_index = 0; step_index < STEPS; step_index++) {
|
|
219
|
+
|
|
220
|
+
// R1 sequence (http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/)
|
|
221
|
+
// Standard multiplier is 0.6180339887498948482 = ( 1 / GOLDEN_RATION )
|
|
222
|
+
let stepBaseNoise = f32(slice + step_index * STEPS) * 0.6180339887498948482;
|
|
223
|
+
|
|
224
|
+
let stepNoise = fract(noiseSample + stepBaseNoise);
|
|
225
|
+
|
|
226
|
+
// approx line 20 from the paper, with added noise
|
|
227
|
+
var s = ( f32(step_index) + stepNoise ) * INV_STEPS;
|
|
228
|
+
|
|
229
|
+
// additional distribution modifier
|
|
230
|
+
s = pow( s, sampleDistributionPower );
|
|
231
|
+
|
|
232
|
+
// avoid sampling center pixel
|
|
233
|
+
s += minS;
|
|
234
|
+
|
|
235
|
+
// approx lines 21-22 from the paper, unrolled
|
|
236
|
+
var sampleOffset = s * omega;
|
|
237
|
+
|
|
238
|
+
// omega = vec2(cosPhi, -sinPhi) * screenspaceRadius has length screenspaceRadius
|
|
239
|
+
let sampleOffsetLength = s * screenspaceRadius;
|
|
240
|
+
let mipLevel = gtao_compute_mip_level(sampleOffsetLength);
|
|
241
|
+
|
|
242
|
+
// Snap to pixel center (more correct direction math, avoids artifacts due to sampling pos not matching depth texel center - messes up slope - but adds other
|
|
243
|
+
// artifacts due to them being pushed off the slice). Also use full precision for high res cases.
|
|
244
|
+
sampleOffset = round( sampleOffset ) * ViewportPixelSize;
|
|
245
|
+
|
|
246
|
+
let sampleScreenPos0 = uv + sampleOffset;
|
|
247
|
+
|
|
248
|
+
let SZ0 = gtao_sample_depth(sampleScreenPos0, mipLevel, camera);
|
|
249
|
+
let samplePos0 = project_view_position_from_depth(sampleScreenPos0, SZ0, camera.projection_matrix_inverse);
|
|
250
|
+
|
|
251
|
+
let sampleScreenPos1 = uv - sampleOffset;
|
|
252
|
+
let SZ1 = gtao_sample_depth(sampleScreenPos1, mipLevel, camera);
|
|
253
|
+
let samplePos1 = project_view_position_from_depth(sampleScreenPos1, SZ1, camera.projection_matrix_inverse);
|
|
254
|
+
|
|
255
|
+
let sampleDelta0 = (samplePos0 - position_vs); // using lpfloat for sampleDelta causes precision issues
|
|
256
|
+
let sampleDelta1 = (samplePos1 - position_vs); // using lpfloat for sampleDelta causes precision issues
|
|
257
|
+
|
|
258
|
+
let sampleDist0 = length( sampleDelta0 );
|
|
259
|
+
let sampleDist1 = length( sampleDelta1 );
|
|
260
|
+
|
|
261
|
+
// approx lines 23, 24 from the paper, unrolled
|
|
262
|
+
let sampleHorizonVec0 = sampleDelta0 / sampleDist0;
|
|
263
|
+
let sampleHorizonVec1 = sampleDelta1 / sampleDist1;
|
|
264
|
+
|
|
265
|
+
let weight0 = saturate( fma(sampleDist0, falloffMul, falloffAdd) );
|
|
266
|
+
let weight1 = saturate( fma(sampleDist1, falloffMul, falloffAdd) );
|
|
267
|
+
|
|
268
|
+
// sample horizon cos
|
|
269
|
+
var shc0 = dot( sampleHorizonVec0, view_direction_vs );
|
|
270
|
+
var shc1 = dot( sampleHorizonVec1, view_direction_vs );
|
|
271
|
+
|
|
272
|
+
// discard unwanted samples
|
|
273
|
+
shc0 = mix( lowHorizonCos0, shc0, weight0 ); // this would be more correct but too expensive: cos(lerp( acos(lowHorizonCos0), acos(shc0), weight0 ));
|
|
274
|
+
shc1 = mix( lowHorizonCos1, shc1, weight1 ); // this would be more correct but too expensive: cos(lerp( acos(lowHorizonCos1), acos(shc1), weight1 ));
|
|
275
|
+
|
|
276
|
+
// this is a version where thicknessHeuristic is completely disabled
|
|
277
|
+
horizonCos0 = max( horizonCos0, shc0 );
|
|
278
|
+
horizonCos1 = max( horizonCos1, shc1 );
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// line ~27, unrolled
|
|
283
|
+
let h0 = -fast_acos(horizonCos1);
|
|
284
|
+
let h1 = fast_acos(horizonCos0);
|
|
285
|
+
|
|
286
|
+
let norm_sin = sin(n);
|
|
287
|
+
let norm_sin2 = 2.0 * norm_sin;
|
|
288
|
+
|
|
289
|
+
let iarc0 = ( fma( h0 , norm_sin2, norm_cos ) - cos( fma( 2.0, h0, - n)) ) * 0.25;
|
|
290
|
+
let iarc1 = ( fma( h1 , norm_sin2, norm_cos ) - cos( fma( 2.0, h1, - n)) ) * 0.25;
|
|
291
|
+
|
|
292
|
+
// Slight overdarkening on high slopes is compensated by tilting projected length toward 1.
|
|
293
|
+
// In the training set, 0.05 is close (PSNR 21.34) to disabled (PSNR 21.45).
|
|
294
|
+
// Scoped to the visibility branch so bent normals keep their unfudged slice weighting.
|
|
295
|
+
let visibilityProjLength = mix( projectedNormalVecLength, 1, 0.05 );
|
|
296
|
+
let localVisibility = visibilityProjLength * ( iarc0 + iarc1 );
|
|
297
|
+
|
|
298
|
+
visibility += localVisibility;
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
// see "Algorithm 2 Extension that computes bent normals b."
|
|
302
|
+
let slice_tangent_ws = normalize(orthoWorldDir);
|
|
303
|
+
let local_bent_ts = integrate_bent_normal(
|
|
304
|
+
horizonCos1,
|
|
305
|
+
horizonCos0,
|
|
306
|
+
norm_cos,
|
|
307
|
+
norm_sin,
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
let t0 = local_bent_ts.x;
|
|
311
|
+
let t1 = local_bent_ts.y;
|
|
312
|
+
|
|
313
|
+
var slice_bent_normal_ws = slice_tangent_ws * t0 + view_direction_ws * t1;
|
|
314
|
+
|
|
315
|
+
bent_normal = fma(slice_bent_normal_ws, vec3(projectedNormalVecLength), bent_normal);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
visibility *= INV_SLICE_COUNT;
|
|
319
|
+
|
|
320
|
+
visibility = pow(visibility, scale);
|
|
321
|
+
|
|
322
|
+
// disallow total occlusion (which wouldn't make any sense anyhow since pixel is visible but also helps with packing bent normals)
|
|
323
|
+
visibility = max(0.03, visibility);
|
|
324
|
+
|
|
325
|
+
bent_normal = normalize(bent_normal);
|
|
326
|
+
|
|
327
|
+
var out: Output;
|
|
328
|
+
out.visibility = vec2(visibility, visibility * visibility);
|
|
329
|
+
out.bent_normal = encode_g_buffer_normal( bent_normal );
|
|
330
|
+
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
`, [
|
|
334
|
+
chunk_get_view_space_depth,
|
|
335
|
+
PI_DECLARATION,
|
|
336
|
+
PI_HALF_DECLARATION,
|
|
337
|
+
|
|
338
|
+
chunk_decode_g_buffer_normal,
|
|
339
|
+
chunk_encode_g_buffer_normal,
|
|
340
|
+
chunk_spatio_temporal_noise_r2_64,
|
|
341
|
+
|
|
342
|
+
chunk_fast_acos,
|
|
343
|
+
|
|
344
|
+
chunk_mat4_extract_position,
|
|
345
|
+
chunk_project_position_from_depth,
|
|
346
|
+
chunk_project_view_position_from_depth,
|
|
347
|
+
chunk_v3_matrix4_rotate,
|
|
348
|
+
chunk_integrate_bent_normal_fast,
|
|
349
|
+
chunk_gtao_compute_mip_level,
|
|
350
|
+
chunk_gtao_sample_depth,
|
|
351
|
+
]);
|
|
352
|
+
|
|
353
|
+
export const fragment_shader_gtao = new ImageShader({
|
|
354
|
+
descriptor: ShaderDescriptor.from(
|
|
355
|
+
{
|
|
356
|
+
label: "GTAO",
|
|
357
|
+
resources,
|
|
358
|
+
body
|
|
359
|
+
},
|
|
360
|
+
),
|
|
361
|
+
depthStencil: DEPTH_STENCIL_FOREGROUND_ONLY,
|
|
362
|
+
targets: [
|
|
363
|
+
{
|
|
364
|
+
label: "Occlusion",
|
|
365
|
+
// first 2 moments of visibility
|
|
366
|
+
format: "rg16float",
|
|
367
|
+
clearValue: [1, 1], // Stores visibility, so 1 == not occluded
|
|
368
|
+
blend: BlendState.from({
|
|
369
|
+
color: {
|
|
370
|
+
operation: "add",
|
|
371
|
+
srcFactor: "one",
|
|
372
|
+
dstFactor: "zero",
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
label: "Bent Normals",
|
|
378
|
+
// Direction is encoded with octahedral
|
|
379
|
+
format: "rg16uint",
|
|
380
|
+
},
|
|
381
|
+
]
|
|
382
|
+
});
|