@woosh/meep-engine 3.78.3 → 3.78.4
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/CHANGELOG.md +46 -13
- package/editor/view/node-graph/NodeGraphView.d.ts +1 -1
- package/editor/view/node-graph/NodeGraphView.js +1 -1
- package/package.json +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +2 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +2 -1
- package/src/core/math/snap_to_integer.d.ts +13 -0
- package/src/core/math/snap_to_integer.d.ts.map +1 -0
- package/src/core/math/snap_to_integer.js +20 -0
- package/src/core/model/node-graph/NodeGraph.d.ts +0 -1
- package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
- package/src/core/model/node-graph/NodeGraph.js +0 -1
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +1 -1
- package/src/engine/graphics/hair/groom_bind_to_mesh.js +1 -1
- package/src/engine/graphics/hair/groom_build_guides.d.ts +1 -1
- package/src/engine/graphics/hair/groom_build_guides.js +1 -1
- package/src/engine/graphics/impostors/voxel/README.md +11 -11
- package/src/engine/physics/cloth/collider/ClothColliderKind.js +1 -1
- package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts +1 -1
- package/src/engine/physics/cloth/ecs/cloth_geodesic.js +1 -1
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts +2 -3
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts.map +1 -1
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.js +2 -3
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts +0 -2
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +0 -5
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +5 -3
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +5 -3
- package/src/generation/grid/coords/grid_to_texel.d.ts +7 -1
- package/src/generation/grid/coords/grid_to_texel.d.ts.map +1 -1
- package/src/generation/grid/coords/grid_to_texel.js +11 -1
- package/src/generation/grid/coords/grid_to_texel_span.d.ts +15 -0
- package/src/generation/grid/coords/grid_to_texel_span.d.ts.map +1 -0
- package/src/generation/grid/coords/grid_to_texel_span.js +38 -0
- package/src/generation/grid/coords/texel_to_grid.d.ts +2 -1
- package/src/generation/grid/coords/texel_to_grid.d.ts.map +1 -1
- package/src/generation/grid/coords/texel_to_grid.js +6 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts +32 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js +114 -9
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts +8 -0
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +91 -29
- package/src/generation/grid/layers/GridDataLayer.d.ts +21 -2
- package/src/generation/grid/layers/GridDataLayer.d.ts.map +1 -1
- package/src/generation/grid/layers/GridDataLayer.js +43 -4
- package/src/generation/placement/action/GridCellActionPlaceTags.d.ts +7 -1
- package/src/generation/placement/action/GridCellActionPlaceTags.d.ts.map +1 -1
- package/src/generation/placement/action/GridCellActionPlaceTags.js +42 -16
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts +5 -0
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts.map +1 -1
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +32 -9
- package/src/generation/rules/CellMatcherLayerBitMaskTest.d.ts.map +1 -1
- package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -2
- package/src/generation/wfc/GridWFCCompiledTileSet.d.ts +4 -2
- package/src/generation/wfc/GridWFCCompiledTileSet.d.ts.map +1 -1
- package/src/generation/wfc/GridWFCCompiledTileSet.js +2 -2
- package/src/generation/wfc/GridWFCTileSet.d.ts +16 -7
- package/src/generation/wfc/GridWFCTileSet.d.ts.map +1 -1
- package/src/generation/wfc/GridWFCTileSet.js +32 -8
- package/src/shade/playground/contact_shadows/shader_contact_lab_composite.js +2 -2
- package/src/shade/playground/particle_editor/README.md +2 -2
- package/src/shade/playground/probe_clipmap/index.html +1 -1
- package/src/shade/playground/screen_probes/README.md +5 -5
- package/src/shade/playground/screen_probes/main.js +1 -1
- package/src/shade/playground/tonemap_sdr/README.md +3 -2
- package/src/shade/playground/vgeo_scene/README.md +1 -3
- package/src/shade/playground/vgeo_scene/main.js +3 -3
- package/src/shade/renderer/Renderer.d.ts +3 -3
- package/src/shade/renderer/Renderer.js +4 -4
- package/src/shade/renderer/ShadeIndirectLightingMode.js +1 -1
- package/src/shade/renderer/camera/PerspectiveCamera.js +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +11 -13
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.js +11 -13
- package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +6 -7
- package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +1 -1
- package/src/shade/renderer/deferred/tonemap/ToneMapper.js +1 -1
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +6 -8
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +7 -10
- package/src/shade/renderer/geometry/sdf/MESH_SDF.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/MESH_SDF.js +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.js +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.js +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts +1 -2
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.js +1 -2
- package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.js +2 -1
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.js +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster_graph.js +1 -1
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.js +2 -2
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.js +4 -4
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.d.ts +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.js +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/cut/shader_vgeo_cut_collect.js +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.d.ts +3 -3
- package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.js +3 -3
- package/src/shade/renderer/global_illumination/brick4/README.md +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.js +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +28 -35
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +28 -35
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +21 -24
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +21 -24
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +8 -8
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +8 -8
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +3 -5
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +3 -5
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +2 -3
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +2 -3
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +13 -17
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +13 -17
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +11 -14
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +11 -14
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +2 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +2 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +9 -9
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +9 -9
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +15 -18
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +16 -19
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +10 -11
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +11 -12
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +9 -8
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_bsdf.js +10 -9
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +5 -6
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +5 -6
- package/src/shade/renderer/hair/hair_lighting.d.ts +3 -3
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_lighting.js +4 -5
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts +5 -5
- package/src/shade/renderer/hair/hair_scattering_lut.js +5 -5
- package/src/shade/renderer/hair/shader_hair_roots.d.ts +2 -2
- package/src/shade/renderer/hair/shader_hair_roots.js +2 -2
- package/src/shade/renderer/light/environment/DEFINES.d.ts +1 -1
- package/src/shade/renderer/light/environment/DEFINES.js +1 -1
- package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_blurred.js +2 -2
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts +1 -2
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts.map +1 -1
- package/src/shade/renderer/material/dispatch/MaterialDispatch.js +1 -2
- package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
- package/src/shade/renderer/material/standard/fragment_gbuffer.js +2 -1
- package/src/shade/renderer/material/util/dielectric_specular_color.d.ts +1 -1
- package/src/shade/renderer/material/util/dielectric_specular_color.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_PRESETS.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts +3 -4
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.js +3 -4
- package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.js +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +1 -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 +2 -3
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts +1 -2
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.js +1 -2
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +2 -3
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +2 -3
- package/src/shade/renderer/postprocess/taa/filter_blackman_harris.d.ts +1 -1
- package/src/shade/renderer/postprocess/taa/filter_blackman_harris.js +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +1 -1
- package/src/shade/renderer/restir/di/ReSTIRDI.d.ts +3 -3
- package/src/shade/renderer/restir/di/ReSTIRDI.js +3 -3
- package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.d.ts +1 -1
- package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.js +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.js +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +1 -2
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +1 -2
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +4 -5
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +4 -5
- package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.d.ts +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.js +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts +14 -17
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.js +18 -21
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.js +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.js +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +3 -4
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +3 -4
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +1 -1
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +3 -3
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +6 -8
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +8 -10
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +5 -7
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +5 -7
- package/src/shade/renderer/texture/virtual/README.md +257 -257
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +2 -2
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
# Virtual Textures
|
|
2
|
-
|
|
3
|
-
Opt-in software virtual texturing for the deferred (visibility-buffer)
|
|
4
|
-
renderer: materials sample from streamed pages of arbitrarily large
|
|
5
|
-
textures, with GPU memory bounded by what is visible instead of what is
|
|
6
|
-
loaded. Built for **hundreds of simultaneous virtual textures** sharing one
|
|
7
|
-
page table, one physical cache and one feedback pass.
|
|
8
|
-
|
|
9
|
-
This README is the design document: adopting the system, configuration and
|
|
10
|
-
how it works. It used to defer the extended treatment — literature survey,
|
|
11
|
-
decision log, scale math, future work — to a `VIRTUAL_TEXTURES.md` in the
|
|
12
|
-
repo root, but that file belonged to the repository Shade was vendored from
|
|
13
|
-
and never came across. The decision log is under "How it works" below; the
|
|
14
|
-
scale numbers are in the configuration table.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Exercising it
|
|
19
|
-
|
|
20
|
-
There is no demo page. `prototype_virtual_texture.js` used to be one, but it
|
|
21
|
-
booted from a harness in a repo that is no longer around and imported
|
|
22
|
-
`lil-gui`/`stats.js`, neither of which is installed here; it was deleted along
|
|
23
|
-
with the rest of the unreachable playground entries. For the record, the scene
|
|
24
|
-
it stood up was four objects chosen to exercise every path:
|
|
25
|
-
|
|
26
|
-
| Object | Stack | Source | Demonstrated |
|
|
27
|
-
|---|---|---|---|
|
|
28
|
-
| Ground plane (100 m) | 8192² | `VTSourceProcedural`, instant | mip selection & residency, visually |
|
|
29
|
-
| Back wall | 4096² | `VTSourceProcedural`, 250 ms latency | streaming: pinned root first, refinement blending in |
|
|
30
|
-
| Box | 2048² | `VTSourceImage` (runtime-tiled canvas) | zero-pipeline adoption of ordinary images |
|
|
31
|
-
| Plain orange box | — | regular material | mixed standard/VT pipelines in one material pass |
|
|
32
|
-
|
|
33
|
-
The procedural tiles used the classic VT debug pattern: **color = mip level,
|
|
34
|
-
label = `mip:x,y` page address**, white page frames.
|
|
35
|
-
|
|
36
|
-
What exercises the system now is its spec coverage, each `.spec.js` sitting
|
|
37
|
-
beside the module it tests: `VTPageTable`, `VTPhysicalCache`,
|
|
38
|
-
`PageTableQuadAllocator`, `VirtualTextureManager`, `VT_CONSTANTS`,
|
|
39
|
-
`vt_pipeline_compat` and `vt_shaders`.
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Using it
|
|
44
|
-
|
|
45
|
-
### Opt a material in
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
import { VirtualTextureStack } from "./texture/virtual/VirtualTextureStack.js";
|
|
49
|
-
import { VTSourceTiled } from "./texture/virtual/source/VTSourceTiled.js";
|
|
50
|
-
|
|
51
|
-
material.vt_stack = VirtualTextureStack.from({
|
|
52
|
-
label: 'rock',
|
|
53
|
-
size: 8192, // texels; square, power of two
|
|
54
|
-
source: new VTSourceTiled({
|
|
55
|
-
layers: [ // URL template per cache layer
|
|
56
|
-
'tiles/rock/albedo/{mip}/{x}_{y}.webp',
|
|
57
|
-
'tiles/rock/normal/{mip}/{x}_{y}.webp',
|
|
58
|
-
'tiles/rock/orm/{mip}/{x}_{y}.webp',
|
|
59
|
-
],
|
|
60
|
-
}),
|
|
61
|
-
wrap: true, // repeat (false = clamp), applied in-shader
|
|
62
|
-
uv_set: 0, // 0 or 1
|
|
63
|
-
average_color: [0.4, 0.35, 0.3, 1], // linear premultiplied; shown before the root arrives
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
That is the entire opt-in. Registration happens automatically when the
|
|
68
|
-
material is first built; a stack may be shared by any number of materials.
|
|
69
|
-
Everything else in the engine renders exactly as before, and the system
|
|
70
|
-
allocates nothing until the first stack registers.
|
|
71
|
-
|
|
72
|
-
A **stack** is the unit of virtualization: a set of texture layers
|
|
73
|
-
(albedo / normal / ORM in the standard cache group) sharing one UV set and
|
|
74
|
-
one resolution. The whole set streams, resides and is addressed as one —
|
|
75
|
-
one feedback value, one page-table entry, one residency decision, and in the
|
|
76
|
-
material shader one page-table fetch feeds all three layer samples. This is
|
|
77
|
-
the "do the work once for matching UV sets" design,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
### Tile sources
|
|
81
|
-
|
|
82
|
-
A source implements:
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
prepare(geometry)? // called on registration: {page_size, border,
|
|
86
|
-
// slot_size, layer_count, size, mip_count}
|
|
87
|
-
load_page(mip, x, y, signal) // → Promise<payload[]>, one per layer;
|
|
88
|
-
// payloads are slot_size² (border baked in);
|
|
89
|
-
// reject with AbortError on signal abort
|
|
90
|
-
layer_mask // bitmask of layers provided (bit0 = albedo…)
|
|
91
|
-
destroy()? // called on last unregistration
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Included:
|
|
95
|
-
|
|
96
|
-
- **`VTSourceTiled`** — pre-tiled page files over HTTP, decoded with
|
|
97
|
-
`createImageBitmap` (WebP/AVIF/PNG/JPEG — browser-native, no WASM).
|
|
98
|
-
`legacy_meep_mips: true` consumes the original meep VT converter's output
|
|
99
|
-
(`${mip}-${x}-${y}.png`, coarsest-is-zero naming) unchanged. Serve
|
|
100
|
-
normal/ORM tiles lossless or 4:4:4 — chroma subsampling mangles them.
|
|
101
|
-
- **`VTSourceImage`** — runtime tiler: hand it ordinary decoded images and it
|
|
102
|
-
builds a canvas mip pyramid once and blits padded tiles on demand. The
|
|
103
|
-
adoption path — wins GPU memory and bandwidth, not host memory.
|
|
104
|
-
- **`VTSourceProcedural`** — instant labeled debug tiles, optional artificial
|
|
105
|
-
latency. Also the reference source implementation.
|
|
106
|
-
|
|
107
|
-
Missing layers (e.g. albedo-only stacks) fall back per layer in the shader:
|
|
108
|
-
albedo → the stack's `average_color`, normal → flat +Z, ORM → neutral.
|
|
109
|
-
|
|
110
|
-
### Constraints (v1)
|
|
111
|
-
|
|
112
|
-
- **Opaque materials only** (asserted). The alpha-tested visibility pass and
|
|
113
|
-
OIT sample the *regular* albedo texture, where VT residency isn't
|
|
114
|
-
guaranteed.
|
|
115
|
-
- `size` is square, power-of-two, a multiple of `page_size`, ≤ 512 pages per
|
|
116
|
-
axis (64k texels at the default page size).
|
|
117
|
-
- Emissive stays a regular texture; a `uv_set: 1` stack re-interpolates uv1
|
|
118
|
-
for all of that material's samples, emissive included.
|
|
119
|
-
- Feedback covers the primary view. Path tracer / lightmap baker see
|
|
120
|
-
fallback colors (no VT sampling there yet).
|
|
121
|
-
- Filtering is bilinear + per-pixel nearest mip (id Tech's shipped baseline);
|
|
122
|
-
anisotropy and trilinear are documented follow-ups — the 4-texel borders
|
|
123
|
-
already budget for aniso ~4×.
|
|
124
|
-
|
|
125
|
-
### Configuration
|
|
126
|
-
|
|
127
|
-
`graphics.virtual_textures.configure({...})` **before the first stack
|
|
128
|
-
registers** (geometry freezes at first use):
|
|
129
|
-
|
|
130
|
-
| Key | Default | Meaning |
|
|
131
|
-
|---|---|---|
|
|
132
|
-
| `page_size` | 128 | payload texels per page side |
|
|
133
|
-
| `border` | 4 | border texels per side, baked into tiles (slot = 136²) |
|
|
134
|
-
| `atlas_size` | 4096 | physical cache side → 30×30 = 900 pages, ~64 MB/layer |
|
|
135
|
-
| `table_size` | 1024 | shared page table side (texels = pages), mip-mapped r32uint |
|
|
136
|
-
| `layers` | albedo/normal/orm | cache group: name, format, premultiply |
|
|
137
|
-
| `feedback_stride` | 4 | sample 1 px per stride² block, jittered (runtime-adjustable) |
|
|
138
|
-
| `max_uploads_per_frame` | 8 | page-upload budget |
|
|
139
|
-
| `max_concurrent_loads` | 32 | in-flight source loads |
|
|
140
|
-
| `request_cap_fraction` | ⅓ | pending requests ≤ cap × cache capacity |
|
|
141
|
-
| `eviction_protect_window` | 4 | frames a touched page is unevictable (covers readback latency) |
|
|
142
|
-
| `queue_stale_window` | 30 | untouched queued requests dropped after N frames |
|
|
143
|
-
| `pressure_high/low_watermark` | 0.9 / 0.75 | residency bias hysteresis |
|
|
144
|
-
|
|
145
|
-
Runtime switch: `renderer.feature_virtual_textures` (default true) stops
|
|
146
|
-
feedback and streaming; already-resident pages keep rendering.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## How it works
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
viz buffer (mesh+triangle ids)
|
|
154
|
-
│
|
|
155
|
-
▼
|
|
156
|
-
vt_feedback (compute, 1 px per stride², jittered) [GPU]
|
|
157
|
-
pixel → mesh → material → stack; UV + analytic gradients
|
|
158
|
-
(same chunks as the material pass); mip select; insert
|
|
159
|
-
packed key into a hash set of unique requests
|
|
160
|
-
│ ~64 KB raw hash buffer
|
|
161
|
-
▼
|
|
162
|
-
async readback (pooled staging, mapAsync, ≤3 in flight) [GPU→CPU, 1–2 frames]
|
|
163
|
-
│
|
|
164
|
-
▼
|
|
165
|
-
VirtualTextureManager.process_feedback [CPU]
|
|
166
|
-
resident → LRU touch (incl. the ancestor actually serving
|
|
167
|
-
a missing cell); miss → request + missing-ancestor chain
|
|
168
|
-
│
|
|
169
|
-
update() per frame: apply arrivals (budgeted uploads),
|
|
170
|
-
evict (LRU + protection window + finest-first ties),
|
|
171
|
-
flush page-table dirty rects + stack info rows,
|
|
172
|
-
issue loads coarse-first with backoff on failures
|
|
173
|
-
│
|
|
174
|
-
▼
|
|
175
|
-
VTPageTable (shared r32uint, mips) VTPhysicalCache (atlas per layer,
|
|
176
|
-
quadtree regions per stack; lockstep slots, page+border)
|
|
177
|
-
every texel = nearest RESIDENT │
|
|
178
|
-
ancestor-or-self entry │
|
|
179
|
-
└───────────────┬───────────────────────────┘
|
|
180
|
-
▼
|
|
181
|
-
material pass (VT variant): ONE textureLoad into the
|
|
182
|
-
table → physical UV → N bilinear layer fetches
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Design points worth knowing before modifying:
|
|
186
|
-
|
|
187
|
-
- **Shared page table.** Every stack owns a buddy-allocated square region of
|
|
188
|
-
one mip-mapped `r32uint` texture. Buddy alignment makes `origin >> mip`
|
|
189
|
-
exact at every mip the region supports, so hundreds of stacks need no
|
|
190
|
-
per-mip metadata and never collide. Entries are **pre-filled with the
|
|
191
|
-
nearest resident ancestor** (maintained incrementally on load/evict by
|
|
192
|
-
`VTPageTable`'s match-and-prune DFS), which is what keeps sampling a
|
|
193
|
-
single fetch with automatic coarse fallback — no shader mip-walk.
|
|
194
|
-
- **Feedback ↔ sampler parity.** Both compile the same
|
|
195
|
-
`build_chunk_vt_lookup` chunk and the same derivative-bias constants; if
|
|
196
|
-
the mip formulas ever diverge, the system requests pages it doesn't sample.
|
|
197
|
-
Change the chunk, never one side.
|
|
198
|
-
- **Key formats** (single source: `VT_CONSTANTS.js`, WGSL mirrors tested for
|
|
199
|
-
parity): request key `stack:10 | mip:4 | x:9 | y:9`, stored `key+1` so a
|
|
200
|
-
zero-cleared buffer reads empty; page-table entry
|
|
201
|
-
`phys_x:8 | phys_y:8 | mip:5 | valid:1`. **Stack ids 0 and 1023 are
|
|
202
|
-
reserved** — 1023 is the "no stack" sentinel, and 0 is never assigned so
|
|
203
|
-
zero-initialized / not-yet-flushed GPU rows decode to a harmless
|
|
204
|
-
"unknown stack" instead of junk requests.
|
|
205
|
-
- **Residency policy.** LRU with a protection window covering readback
|
|
206
|
-
latency; each stack's root page is pinned at registration (a fallback is
|
|
207
|
-
always resident once it arrives — held and retried, never dropped, even
|
|
208
|
-
under lock saturation); eviction ties shed the finest mip first; requests
|
|
209
|
-
are capped per cycle and canceled when stale; failed loads back off
|
|
210
|
-
exponentially in a negative cache; cache pressure raises a feedback mip
|
|
211
|
-
bias so oversubscription degrades to blur instead of thrash.
|
|
212
|
-
- **Frame protocol.** `update()` runs in `Renderer.#begin_frame`
|
|
213
|
-
(queue-ordered before the frame's submits). Stacks registered mid-frame
|
|
214
|
-
(materials build during scene update) are published by an idempotent
|
|
215
|
-
`flush_gpu_state()` re-run from `graph_feedback`, so first frames render
|
|
216
|
-
correctly.
|
|
217
|
-
- **Struct packing hazard.** `WebGPUStruct.pack()` reorders fields — never
|
|
218
|
-
construct packed structs positionally in WGSL (tests included); use
|
|
219
|
-
member-wise assignment. Inline chunk structs (`VTPhysical`,
|
|
220
|
-
`VTPageTableEntry`) are unpacked and safe.
|
|
221
|
-
|
|
222
|
-
## Files
|
|
223
|
-
|
|
224
|
-
| File | Role |
|
|
225
|
-
|---|---|
|
|
226
|
-
| `VirtualTextureManager.js` | orchestrator: registry, residency, streaming, FrameGraph wiring |
|
|
227
|
-
| `VirtualTextureStack.js` | scene-side stack description (`material.vt_stack`) |
|
|
228
|
-
| `VTPageTable.js` | shared table texture + CPU mirror + ancestor-closure propagation |
|
|
229
|
-
| `PageTableQuadAllocator.js` | buddy allocator (the `origin >> mip` guarantee) |
|
|
230
|
-
| `VTPhysicalCache.js` | per-layer atlases, lockstep slots, LRU metadata, uploads |
|
|
231
|
-
| `VT_CONSTANTS.js` | bit layouts, sentinels, JS pack/unpack |
|
|
232
|
-
| `VT_STACK_INFO_STRUCT.js` | per-stack GPU record |
|
|
233
|
-
| `build_chunk_vt_lookup.js` | shared WGSL: wrap, mip select, table load, physical UV |
|
|
234
|
-
| `chunk_vt_request_key.js` | WGSL request-key packing |
|
|
235
|
-
| `build_shader_vt_feedback.js` | the feedback compute shader |
|
|
236
|
-
| `source/VTSource{Procedural,Image,Tiled}.js` | tile providers |
|
|
237
|
-
| `../../material/standard/fragment_gbuffer_vt.js` | VT material shader variant |
|
|
238
|
-
|
|
239
|
-
## Tests
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
npx vitest run src/shade/renderer/texture/virtual
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
~60 tests: allocator properties; page-table nearest-ancestor invariant
|
|
246
|
-
against a brute-force reference model (randomized, including physical-slot
|
|
247
|
-
recycling); cache LRU/pinning/tie-breaks; manager end-to-end with a mocked
|
|
248
|
-
GPU (register → pin → feedback → stream → evict → unregister) plus the
|
|
249
|
-
policy set (request cap, stale aging, coarse-first order, serving-ancestor
|
|
250
|
-
protection, failure backoff, locked-root retry, teardown flush, stale-key
|
|
251
|
-
rejection); WGSL validity for both shaders (tree-sitter); WGSL↔JS packing
|
|
252
|
-
and physical-UV parity through the in-repo emulator, under default and
|
|
253
|
-
non-default geometry; and standard↔VT pipeline bind-group-layout equality.
|
|
254
|
-
|
|
255
|
-
Known untestable-here: the GPU hash-set insert loop (the emulator has no
|
|
256
|
-
atomics) and the canvas-based sources (no OffscreenCanvas under Node) — both
|
|
257
|
-
are covered by the demo instead.
|
|
1
|
+
# Virtual Textures
|
|
2
|
+
|
|
3
|
+
Opt-in software virtual texturing for the deferred (visibility-buffer)
|
|
4
|
+
renderer: materials sample from streamed pages of arbitrarily large
|
|
5
|
+
textures, with GPU memory bounded by what is visible instead of what is
|
|
6
|
+
loaded. Built for **hundreds of simultaneous virtual textures** sharing one
|
|
7
|
+
page table, one physical cache and one feedback pass.
|
|
8
|
+
|
|
9
|
+
This README is the design document: adopting the system, configuration and
|
|
10
|
+
how it works. It used to defer the extended treatment — literature survey,
|
|
11
|
+
decision log, scale math, future work — to a `VIRTUAL_TEXTURES.md` in the
|
|
12
|
+
repo root, but that file belonged to the repository Shade was vendored from
|
|
13
|
+
and never came across. The decision log is under "How it works" below; the
|
|
14
|
+
scale numbers are in the configuration table.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Exercising it
|
|
19
|
+
|
|
20
|
+
There is no demo page. `prototype_virtual_texture.js` used to be one, but it
|
|
21
|
+
booted from a harness in a repo that is no longer around and imported
|
|
22
|
+
`lil-gui`/`stats.js`, neither of which is installed here; it was deleted along
|
|
23
|
+
with the rest of the unreachable playground entries. For the record, the scene
|
|
24
|
+
it stood up was four objects chosen to exercise every path:
|
|
25
|
+
|
|
26
|
+
| Object | Stack | Source | Demonstrated |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| Ground plane (100 m) | 8192² | `VTSourceProcedural`, instant | mip selection & residency, visually |
|
|
29
|
+
| Back wall | 4096² | `VTSourceProcedural`, 250 ms latency | streaming: pinned root first, refinement blending in |
|
|
30
|
+
| Box | 2048² | `VTSourceImage` (runtime-tiled canvas) | zero-pipeline adoption of ordinary images |
|
|
31
|
+
| Plain orange box | — | regular material | mixed standard/VT pipelines in one material pass |
|
|
32
|
+
|
|
33
|
+
The procedural tiles used the classic VT debug pattern: **color = mip level,
|
|
34
|
+
label = `mip:x,y` page address**, white page frames.
|
|
35
|
+
|
|
36
|
+
What exercises the system now is its spec coverage, each `.spec.js` sitting
|
|
37
|
+
beside the module it tests: `VTPageTable`, `VTPhysicalCache`,
|
|
38
|
+
`PageTableQuadAllocator`, `VirtualTextureManager`, `VT_CONSTANTS`,
|
|
39
|
+
`vt_pipeline_compat` and `vt_shaders`.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Using it
|
|
44
|
+
|
|
45
|
+
### Opt a material in
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { VirtualTextureStack } from "./texture/virtual/VirtualTextureStack.js";
|
|
49
|
+
import { VTSourceTiled } from "./texture/virtual/source/VTSourceTiled.js";
|
|
50
|
+
|
|
51
|
+
material.vt_stack = VirtualTextureStack.from({
|
|
52
|
+
label: 'rock',
|
|
53
|
+
size: 8192, // texels; square, power of two
|
|
54
|
+
source: new VTSourceTiled({
|
|
55
|
+
layers: [ // URL template per cache layer
|
|
56
|
+
'tiles/rock/albedo/{mip}/{x}_{y}.webp',
|
|
57
|
+
'tiles/rock/normal/{mip}/{x}_{y}.webp',
|
|
58
|
+
'tiles/rock/orm/{mip}/{x}_{y}.webp',
|
|
59
|
+
],
|
|
60
|
+
}),
|
|
61
|
+
wrap: true, // repeat (false = clamp), applied in-shader
|
|
62
|
+
uv_set: 0, // 0 or 1
|
|
63
|
+
average_color: [0.4, 0.35, 0.3, 1], // linear premultiplied; shown before the root arrives
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
That is the entire opt-in. Registration happens automatically when the
|
|
68
|
+
material is first built; a stack may be shared by any number of materials.
|
|
69
|
+
Everything else in the engine renders exactly as before, and the system
|
|
70
|
+
allocates nothing until the first stack registers.
|
|
71
|
+
|
|
72
|
+
A **stack** is the unit of virtualization: a set of texture layers
|
|
73
|
+
(albedo / normal / ORM in the standard cache group) sharing one UV set and
|
|
74
|
+
one resolution. The whole set streams, resides and is addressed as one —
|
|
75
|
+
one feedback value, one page-table entry, one residency decision, and in the
|
|
76
|
+
material shader one page-table fetch feeds all three layer samples. This is
|
|
77
|
+
the "do the work once for matching UV sets" design, as in Granite's stacked
|
|
78
|
+
textures.
|
|
79
|
+
|
|
80
|
+
### Tile sources
|
|
81
|
+
|
|
82
|
+
A source implements:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
prepare(geometry)? // called on registration: {page_size, border,
|
|
86
|
+
// slot_size, layer_count, size, mip_count}
|
|
87
|
+
load_page(mip, x, y, signal) // → Promise<payload[]>, one per layer;
|
|
88
|
+
// payloads are slot_size² (border baked in);
|
|
89
|
+
// reject with AbortError on signal abort
|
|
90
|
+
layer_mask // bitmask of layers provided (bit0 = albedo…)
|
|
91
|
+
destroy()? // called on last unregistration
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Included:
|
|
95
|
+
|
|
96
|
+
- **`VTSourceTiled`** — pre-tiled page files over HTTP, decoded with
|
|
97
|
+
`createImageBitmap` (WebP/AVIF/PNG/JPEG — browser-native, no WASM).
|
|
98
|
+
`legacy_meep_mips: true` consumes the original meep VT converter's output
|
|
99
|
+
(`${mip}-${x}-${y}.png`, coarsest-is-zero naming) unchanged. Serve
|
|
100
|
+
normal/ORM tiles lossless or 4:4:4 — chroma subsampling mangles them.
|
|
101
|
+
- **`VTSourceImage`** — runtime tiler: hand it ordinary decoded images and it
|
|
102
|
+
builds a canvas mip pyramid once and blits padded tiles on demand. The
|
|
103
|
+
adoption path — wins GPU memory and bandwidth, not host memory.
|
|
104
|
+
- **`VTSourceProcedural`** — instant labeled debug tiles, optional artificial
|
|
105
|
+
latency. Also the reference source implementation.
|
|
106
|
+
|
|
107
|
+
Missing layers (e.g. albedo-only stacks) fall back per layer in the shader:
|
|
108
|
+
albedo → the stack's `average_color`, normal → flat +Z, ORM → neutral.
|
|
109
|
+
|
|
110
|
+
### Constraints (v1)
|
|
111
|
+
|
|
112
|
+
- **Opaque materials only** (asserted). The alpha-tested visibility pass and
|
|
113
|
+
OIT sample the *regular* albedo texture, where VT residency isn't
|
|
114
|
+
guaranteed.
|
|
115
|
+
- `size` is square, power-of-two, a multiple of `page_size`, ≤ 512 pages per
|
|
116
|
+
axis (64k texels at the default page size).
|
|
117
|
+
- Emissive stays a regular texture; a `uv_set: 1` stack re-interpolates uv1
|
|
118
|
+
for all of that material's samples, emissive included.
|
|
119
|
+
- Feedback covers the primary view. Path tracer / lightmap baker see
|
|
120
|
+
fallback colors (no VT sampling there yet).
|
|
121
|
+
- Filtering is bilinear + per-pixel nearest mip (id Tech's shipped baseline);
|
|
122
|
+
anisotropy and trilinear are documented follow-ups — the 4-texel borders
|
|
123
|
+
already budget for aniso ~4×.
|
|
124
|
+
|
|
125
|
+
### Configuration
|
|
126
|
+
|
|
127
|
+
`graphics.virtual_textures.configure({...})` **before the first stack
|
|
128
|
+
registers** (geometry freezes at first use):
|
|
129
|
+
|
|
130
|
+
| Key | Default | Meaning |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| `page_size` | 128 | payload texels per page side |
|
|
133
|
+
| `border` | 4 | border texels per side, baked into tiles (slot = 136²) |
|
|
134
|
+
| `atlas_size` | 4096 | physical cache side → 30×30 = 900 pages, ~64 MB/layer |
|
|
135
|
+
| `table_size` | 1024 | shared page table side (texels = pages), mip-mapped r32uint |
|
|
136
|
+
| `layers` | albedo/normal/orm | cache group: name, format, premultiply |
|
|
137
|
+
| `feedback_stride` | 4 | sample 1 px per stride² block, jittered (runtime-adjustable) |
|
|
138
|
+
| `max_uploads_per_frame` | 8 | page-upload budget |
|
|
139
|
+
| `max_concurrent_loads` | 32 | in-flight source loads |
|
|
140
|
+
| `request_cap_fraction` | ⅓ | pending requests ≤ cap × cache capacity |
|
|
141
|
+
| `eviction_protect_window` | 4 | frames a touched page is unevictable (covers readback latency) |
|
|
142
|
+
| `queue_stale_window` | 30 | untouched queued requests dropped after N frames |
|
|
143
|
+
| `pressure_high/low_watermark` | 0.9 / 0.75 | residency bias hysteresis |
|
|
144
|
+
|
|
145
|
+
Runtime switch: `renderer.feature_virtual_textures` (default true) stops
|
|
146
|
+
feedback and streaming; already-resident pages keep rendering.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## How it works
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
viz buffer (mesh+triangle ids)
|
|
154
|
+
│
|
|
155
|
+
▼
|
|
156
|
+
vt_feedback (compute, 1 px per stride², jittered) [GPU]
|
|
157
|
+
pixel → mesh → material → stack; UV + analytic gradients
|
|
158
|
+
(same chunks as the material pass); mip select; insert
|
|
159
|
+
packed key into a hash set of unique requests
|
|
160
|
+
│ ~64 KB raw hash buffer
|
|
161
|
+
▼
|
|
162
|
+
async readback (pooled staging, mapAsync, ≤3 in flight) [GPU→CPU, 1–2 frames]
|
|
163
|
+
│
|
|
164
|
+
▼
|
|
165
|
+
VirtualTextureManager.process_feedback [CPU]
|
|
166
|
+
resident → LRU touch (incl. the ancestor actually serving
|
|
167
|
+
a missing cell); miss → request + missing-ancestor chain
|
|
168
|
+
│
|
|
169
|
+
update() per frame: apply arrivals (budgeted uploads),
|
|
170
|
+
evict (LRU + protection window + finest-first ties),
|
|
171
|
+
flush page-table dirty rects + stack info rows,
|
|
172
|
+
issue loads coarse-first with backoff on failures
|
|
173
|
+
│
|
|
174
|
+
▼
|
|
175
|
+
VTPageTable (shared r32uint, mips) VTPhysicalCache (atlas per layer,
|
|
176
|
+
quadtree regions per stack; lockstep slots, page+border)
|
|
177
|
+
every texel = nearest RESIDENT │
|
|
178
|
+
ancestor-or-self entry │
|
|
179
|
+
└───────────────┬───────────────────────────┘
|
|
180
|
+
▼
|
|
181
|
+
material pass (VT variant): ONE textureLoad into the
|
|
182
|
+
table → physical UV → N bilinear layer fetches
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Design points worth knowing before modifying:
|
|
186
|
+
|
|
187
|
+
- **Shared page table.** Every stack owns a buddy-allocated square region of
|
|
188
|
+
one mip-mapped `r32uint` texture. Buddy alignment makes `origin >> mip`
|
|
189
|
+
exact at every mip the region supports, so hundreds of stacks need no
|
|
190
|
+
per-mip metadata and never collide. Entries are **pre-filled with the
|
|
191
|
+
nearest resident ancestor** (maintained incrementally on load/evict by
|
|
192
|
+
`VTPageTable`'s match-and-prune DFS), which is what keeps sampling a
|
|
193
|
+
single fetch with automatic coarse fallback — no shader mip-walk.
|
|
194
|
+
- **Feedback ↔ sampler parity.** Both compile the same
|
|
195
|
+
`build_chunk_vt_lookup` chunk and the same derivative-bias constants; if
|
|
196
|
+
the mip formulas ever diverge, the system requests pages it doesn't sample.
|
|
197
|
+
Change the chunk, never one side.
|
|
198
|
+
- **Key formats** (single source: `VT_CONSTANTS.js`, WGSL mirrors tested for
|
|
199
|
+
parity): request key `stack:10 | mip:4 | x:9 | y:9`, stored `key+1` so a
|
|
200
|
+
zero-cleared buffer reads empty; page-table entry
|
|
201
|
+
`phys_x:8 | phys_y:8 | mip:5 | valid:1`. **Stack ids 0 and 1023 are
|
|
202
|
+
reserved** — 1023 is the "no stack" sentinel, and 0 is never assigned so
|
|
203
|
+
zero-initialized / not-yet-flushed GPU rows decode to a harmless
|
|
204
|
+
"unknown stack" instead of junk requests.
|
|
205
|
+
- **Residency policy.** LRU with a protection window covering readback
|
|
206
|
+
latency; each stack's root page is pinned at registration (a fallback is
|
|
207
|
+
always resident once it arrives — held and retried, never dropped, even
|
|
208
|
+
under lock saturation); eviction ties shed the finest mip first; requests
|
|
209
|
+
are capped per cycle and canceled when stale; failed loads back off
|
|
210
|
+
exponentially in a negative cache; cache pressure raises a feedback mip
|
|
211
|
+
bias so oversubscription degrades to blur instead of thrash.
|
|
212
|
+
- **Frame protocol.** `update()` runs in `Renderer.#begin_frame`
|
|
213
|
+
(queue-ordered before the frame's submits). Stacks registered mid-frame
|
|
214
|
+
(materials build during scene update) are published by an idempotent
|
|
215
|
+
`flush_gpu_state()` re-run from `graph_feedback`, so first frames render
|
|
216
|
+
correctly.
|
|
217
|
+
- **Struct packing hazard.** `WebGPUStruct.pack()` reorders fields — never
|
|
218
|
+
construct packed structs positionally in WGSL (tests included); use
|
|
219
|
+
member-wise assignment. Inline chunk structs (`VTPhysical`,
|
|
220
|
+
`VTPageTableEntry`) are unpacked and safe.
|
|
221
|
+
|
|
222
|
+
## Files
|
|
223
|
+
|
|
224
|
+
| File | Role |
|
|
225
|
+
|---|---|
|
|
226
|
+
| `VirtualTextureManager.js` | orchestrator: registry, residency, streaming, FrameGraph wiring |
|
|
227
|
+
| `VirtualTextureStack.js` | scene-side stack description (`material.vt_stack`) |
|
|
228
|
+
| `VTPageTable.js` | shared table texture + CPU mirror + ancestor-closure propagation |
|
|
229
|
+
| `PageTableQuadAllocator.js` | buddy allocator (the `origin >> mip` guarantee) |
|
|
230
|
+
| `VTPhysicalCache.js` | per-layer atlases, lockstep slots, LRU metadata, uploads |
|
|
231
|
+
| `VT_CONSTANTS.js` | bit layouts, sentinels, JS pack/unpack |
|
|
232
|
+
| `VT_STACK_INFO_STRUCT.js` | per-stack GPU record |
|
|
233
|
+
| `build_chunk_vt_lookup.js` | shared WGSL: wrap, mip select, table load, physical UV |
|
|
234
|
+
| `chunk_vt_request_key.js` | WGSL request-key packing |
|
|
235
|
+
| `build_shader_vt_feedback.js` | the feedback compute shader |
|
|
236
|
+
| `source/VTSource{Procedural,Image,Tiled}.js` | tile providers |
|
|
237
|
+
| `../../material/standard/fragment_gbuffer_vt.js` | VT material shader variant |
|
|
238
|
+
|
|
239
|
+
## Tests
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
npx vitest run src/shade/renderer/texture/virtual
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
~60 tests: allocator properties; page-table nearest-ancestor invariant
|
|
246
|
+
against a brute-force reference model (randomized, including physical-slot
|
|
247
|
+
recycling); cache LRU/pinning/tie-breaks; manager end-to-end with a mocked
|
|
248
|
+
GPU (register → pin → feedback → stream → evict → unregister) plus the
|
|
249
|
+
policy set (request cap, stale aging, coarse-first order, serving-ancestor
|
|
250
|
+
protection, failure backoff, locked-root retry, teardown flush, stale-key
|
|
251
|
+
rejection); WGSL validity for both shaders (tree-sitter); WGSL↔JS packing
|
|
252
|
+
and physical-UV parity through the in-repo emulator, under default and
|
|
253
|
+
non-default geometry; and standard↔VT pipeline bind-group-layout equality.
|
|
254
|
+
|
|
255
|
+
Known untestable-here: the GPU hash-set insert loop (the emulator has no
|
|
256
|
+
atomics) and the canvas-based sources (no OffscreenCanvas under Node) — both
|
|
257
|
+
are covered by the demo instead.
|
|
@@ -379,8 +379,8 @@ fn main(
|
|
|
379
379
|
// the medium shadowed itself and geometry did not shadow it at all, so a torch behind a
|
|
380
380
|
// wall lit the fog through the wall and a light through a window cast no shaft. The
|
|
381
381
|
// directional loop above has always multiplied its shadow map in; this is the same
|
|
382
|
-
// operation for the clustered lights,
|
|
383
|
-
//
|
|
382
|
+
// operation for the clustered lights, in the froxel pass. One nearest atlas tap rather
|
|
383
|
+
// than the deferred path's filter kernel —
|
|
384
384
|
// see the chunk for why that is not a compromise here.
|
|
385
385
|
let shadow_term = volumetrics_point_light_shadow(&light_data, light_index, position_ws);
|
|
386
386
|
|