@woosh/meep-engine 3.53.0 → 3.54.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/graphics/texture/atlas/SpriteAtlasFill.d.ts +12 -0
- 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/graphics/texture/atlas/sprite_atlas_border.d.ts +52 -0
- 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/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/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/nss/NSS.d.ts +1 -1
- 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/chunk_volumetrics_froxel_sample.d.ts +24 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_froxel_sample.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts.map +1 -1
- 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 +31 -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 +113 -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 +356 -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/volumetrics/shader_volumetrics_classify_froxels.d.ts +16 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_classify_froxels.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_lighting_regimes.d.ts +23 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_lighting_regimes.d.ts.map +1 -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/DecalAtlasFill.js +0 -32
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.js +0 -49
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +0 -50
- package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.js +0 -105
- package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +0 -80
- package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.js +0 -51
- package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.js +0 -39
- package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +0 -121
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +0 -237
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { CAMERA_UNIFORM_STRUCT } from "../../camera/CAMERA_UNIFORM_STRUCT.js";
|
|
2
|
+
import { INDIRECT_LIGHT_INTENSITY } from "../../deferred/INDIRECT_LIGHT_INTENSITY.js";
|
|
3
|
+
import { BRICK4_DATA_STRUCT } from "../../global_illumination/brick4/gpu/BRICK4_DATA_STRUCT.js";
|
|
4
|
+
import { LPV_SHADER_RESOURCE_GROUP_WITH_DEFAULTS } from "../../global_illumination/probe/octahedral/LPV_SHADER_RESOURCE_GROUP.js";
|
|
5
|
+
import { chunk_light_cluster_counts } from "../../light/cluster/chunk_light_cluster_counts.js";
|
|
6
|
+
import { LIGHT_CLUSTER_LOOKUP_STRUCT } from "../../light/cluster/shader_cluster_assign_lights.js";
|
|
7
|
+
import { ENVIRONMENT_SH_TYPE } from "../../light/environment/shader_project_environment_sh.js";
|
|
8
|
+
import { chunk_world_light_cluster_lookup } from "../../light/world_cluster/chunk_world_light_cluster_lookup.js";
|
|
9
|
+
import { chunk_mat4_extract_position } from "../../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
|
|
10
|
+
import {
|
|
11
|
+
chunk_directional_lights_iteration_mask
|
|
12
|
+
} from "../../shader/chunk/light/io/chunk_directional_lights_iteration_mask.js";
|
|
13
|
+
import {
|
|
14
|
+
chunk_get_directional_light_info_by_index
|
|
15
|
+
} from "../../shader/chunk/light/io/chunk_get_directional_light_info_by_index.js";
|
|
16
|
+
import {
|
|
17
|
+
METRO_L1_IRRADIANCE_STRUCT
|
|
18
|
+
} from "../../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
|
|
19
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
20
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
21
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
22
|
+
import { f32, i32, u32, vec3i, vec3u } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
23
|
+
import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
24
|
+
import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
|
|
25
|
+
import { chunk_shadowmap_get_light_visibility } from "../../shadow/map/shader/chunk_shadowmap_get_light_visibility.js";
|
|
26
|
+
import { SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR } from "../../shadow/map/SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR.js";
|
|
27
|
+
import { chunk_volumetrics_irradiance_sh } from "../chunk_volumetrics_irradiance_sh.js";
|
|
28
|
+
import { chunk_volumetrics_local_light_shadow } from "../chunk_volumetrics_local_light_shadow.js";
|
|
29
|
+
import { chunk_irradiance_clipmap_gi_sample } from "./chunk_irradiance_clipmap_gi_sample.js";
|
|
30
|
+
import { chunk_irradiance_clipmap_local_light } from "./chunk_irradiance_clipmap_local_light.js";
|
|
31
|
+
import {
|
|
32
|
+
IRRADIANCE_CLIPMAP_LIGHT_BUDGET,
|
|
33
|
+
IRRADIANCE_CLIPMAP_TILE_FORMAT,
|
|
34
|
+
} from "./IRRADIANCE_CLIPMAP.js";
|
|
35
|
+
|
|
36
|
+
export const IRRADIANCE_CLIPMAP_BUILD_GROUP_SIZE = Object.freeze([4, 4, 4]);
|
|
37
|
+
|
|
38
|
+
export const IRRADIANCE_CLIPMAP_BUILD_STRUCT = WebGPUStruct.from({
|
|
39
|
+
tile_origin: vec3u,
|
|
40
|
+
cascade_index: u32,
|
|
41
|
+
corner: vec3i,
|
|
42
|
+
cell_size: f32,
|
|
43
|
+
tile_size: vec3u,
|
|
44
|
+
border: i32,
|
|
45
|
+
}, "IrradianceClipmapBuild");
|
|
46
|
+
|
|
47
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
48
|
+
|
|
49
|
+
resources.createGroup()
|
|
50
|
+
.addUniform("build_settings", IRRADIANCE_CLIPMAP_BUILD_STRUCT)
|
|
51
|
+
.addUniform("camera", CAMERA_UNIFORM_STRUCT)
|
|
52
|
+
.addUniform("environment_sh", ENVIRONMENT_SH_TYPE)
|
|
53
|
+
.addStorageBuffer("brick4", BRICK4_DATA_STRUCT, false, true)
|
|
54
|
+
.addStorageBuffer("light_data", WebGPUArray.u32, false)
|
|
55
|
+
.addStorageBuffer("world_cluster_lookup", LIGHT_CLUSTER_LOOKUP_STRUCT, false)
|
|
56
|
+
.addStorageBuffer("world_cluster_data", WebGPUArray.u32, false)
|
|
57
|
+
.addTexture("shadowmapAtlas", "depth")
|
|
58
|
+
.addSampler("sCompareLinear", "comparison", SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR)
|
|
59
|
+
.addStorageTexture("atlas_y", IRRADIANCE_CLIPMAP_TILE_FORMAT, "3d", "write-only")
|
|
60
|
+
.addStorageTexture("atlas_cocg", IRRADIANCE_CLIPMAP_TILE_FORMAT, "3d", "write-only");
|
|
61
|
+
|
|
62
|
+
resources.addGroup(LPV_SHADER_RESOURCE_GROUP_WITH_DEFAULTS);
|
|
63
|
+
|
|
64
|
+
const body = CodeChunk.from(
|
|
65
|
+
//language=WGSL
|
|
66
|
+
`
|
|
67
|
+
@compute @workgroup_size(${IRRADIANCE_CLIPMAP_BUILD_GROUP_SIZE.join(", ")})
|
|
68
|
+
fn main(@builtin(global_invocation_id) local_texel: vec3<u32>) {
|
|
69
|
+
let tile_size = build_settings.tile_size;
|
|
70
|
+
if (any(local_texel >= tile_size)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let local_cell = vec3<i32>(local_texel) - vec3<i32>(build_settings.border);
|
|
75
|
+
let world_cell = build_settings.corner + local_cell;
|
|
76
|
+
let position_ws = (vec3<f32>(world_cell) + vec3<f32>(0.5)) * build_settings.cell_size;
|
|
77
|
+
|
|
78
|
+
const INDIRECT_INTENSITY: f32 = ${INDIRECT_LIGHT_INTENSITY};
|
|
79
|
+
let gi_radiance = irradiance_clipmap_gi_sample(position_ws);
|
|
80
|
+
let scaled_gi = array<vec3<f32>, 4>(
|
|
81
|
+
gi_radiance[0] * INDIRECT_INTENSITY,
|
|
82
|
+
gi_radiance[1] * INDIRECT_INTENSITY,
|
|
83
|
+
gi_radiance[2] * INDIRECT_INTENSITY,
|
|
84
|
+
gi_radiance[3] * INDIRECT_INTENSITY,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
var irradiance: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
|
|
88
|
+
irradiance = volumetrics_irradiance_sh_add_radiance(irradiance, scaled_gi);
|
|
89
|
+
|
|
90
|
+
let to_camera = mat4_extract_position(camera.transform) - position_ws;
|
|
91
|
+
let to_camera_len = max(length(to_camera), 1e-5);
|
|
92
|
+
let toward_camera = to_camera / to_camera_len;
|
|
93
|
+
|
|
94
|
+
var directional_bits = directional_lights_iteration_mask(&light_data);
|
|
95
|
+
while (directional_bits != 0u) {
|
|
96
|
+
let directional_index = countTrailingZeros(directional_bits);
|
|
97
|
+
directional_bits &= ~(1u << directional_index);
|
|
98
|
+
|
|
99
|
+
let sun = get_directional_light_info_by_index(&light_data, directional_index);
|
|
100
|
+
|
|
101
|
+
let shadow_term = shadowmap_get_directional_light_visibility(
|
|
102
|
+
&light_data,
|
|
103
|
+
directional_index,
|
|
104
|
+
position_ws,
|
|
105
|
+
toward_camera,
|
|
106
|
+
sun.direction
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * sun.color, sun.direction);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let cluster_meta = world_light_cluster_metadata_by_texel(
|
|
113
|
+
build_settings.cascade_index,
|
|
114
|
+
local_texel,
|
|
115
|
+
tile_size
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
let cluster_offset = cluster_meta.offset;
|
|
119
|
+
let point_count = light_cluster_count_point(cluster_meta.counts);
|
|
120
|
+
let spot_count = light_cluster_count_spot(cluster_meta.counts);
|
|
121
|
+
|
|
122
|
+
for (var j = 0u; j < min(point_count, ${IRRADIANCE_CLIPMAP_LIGHT_BUDGET}u); j++) {
|
|
123
|
+
let light_index = world_cluster_data[cluster_offset + j];
|
|
124
|
+
let direct_light = irradiance_clipmap_get_point_light_info_by_index(
|
|
125
|
+
&light_data,
|
|
126
|
+
light_index,
|
|
127
|
+
position_ws,
|
|
128
|
+
build_settings.cell_size
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (all(direct_light.color == vec3<f32>(0.0))) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let shadow_term = volumetrics_point_light_shadow(&light_data, light_index, position_ws);
|
|
136
|
+
irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (var k = 0u; k < min(spot_count, ${IRRADIANCE_CLIPMAP_LIGHT_BUDGET}u); k++) {
|
|
140
|
+
let light_index = world_cluster_data[cluster_offset + point_count + k];
|
|
141
|
+
let direct_light = irradiance_clipmap_get_spot_light_info_by_index(
|
|
142
|
+
&light_data,
|
|
143
|
+
light_index,
|
|
144
|
+
position_ws,
|
|
145
|
+
build_settings.cell_size
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
if (all(direct_light.color == vec3<f32>(0.0))) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let shadow_term = volumetrics_spot_light_shadow(&light_data, light_index, position_ws);
|
|
153
|
+
irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let stored = volumetrics_irradiance_sh_storable(irradiance);
|
|
157
|
+
let atlas_texel = build_settings.tile_origin + local_texel;
|
|
158
|
+
|
|
159
|
+
textureStore(atlas_y, atlas_texel, stored.Y);
|
|
160
|
+
textureStore(atlas_cocg, atlas_texel, vec4<f32>(stored.CoCg, 0.0, 0.0));
|
|
161
|
+
}
|
|
162
|
+
`, [
|
|
163
|
+
METRO_L1_IRRADIANCE_STRUCT.declaration_chunk,
|
|
164
|
+
chunk_mat4_extract_position,
|
|
165
|
+
chunk_irradiance_clipmap_gi_sample,
|
|
166
|
+
chunk_world_light_cluster_lookup,
|
|
167
|
+
chunk_light_cluster_counts,
|
|
168
|
+
chunk_directional_lights_iteration_mask,
|
|
169
|
+
chunk_get_directional_light_info_by_index,
|
|
170
|
+
chunk_irradiance_clipmap_local_light,
|
|
171
|
+
chunk_shadowmap_get_light_visibility,
|
|
172
|
+
chunk_volumetrics_local_light_shadow,
|
|
173
|
+
chunk_volumetrics_irradiance_sh,
|
|
174
|
+
]
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Populates one cascade's tile (including its 1-texel trilinear skirt) in the synchronized `Y` and
|
|
179
|
+
* `CoCg` 3D tile atlases of the world-space irradiance clipmap.
|
|
180
|
+
*
|
|
181
|
+
* Evaluates indirect lighting (`INDIRECT_LIGHTING`), directional lights (`SHADOW_DIRECTIONAL_TECHNIQUE`),
|
|
182
|
+
* and world-space clustered point and spot lights with shadow maps at deterministic world-space
|
|
183
|
+
* voxel centres.
|
|
184
|
+
*
|
|
185
|
+
* @type {ComputeShader}
|
|
186
|
+
*/
|
|
187
|
+
export const shader_irradiance_clipmap_build = ComputeShader.from({
|
|
188
|
+
label: "Volumetrics / irradiance clipmap build",
|
|
189
|
+
resources,
|
|
190
|
+
body,
|
|
191
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const VOLUMETRICS_CLASSIFY_WORKGROUP_RESOLUTION: readonly number[];
|
|
2
|
+
/**
|
|
3
|
+
* Classifies every froxel of the volumetric grid into one of the three lighting regimes (Decision 4.2)
|
|
4
|
+
* using subgroup-coalesced appends ({@link chunk_collection_u32_append}):
|
|
5
|
+
*
|
|
6
|
+
* 1. `list_clipmap` — froxels fully inside the world-space irradiance clipmap (`c < count - 1`, or
|
|
7
|
+
* `c == count - 1` with `edge_weight == 0`).
|
|
8
|
+
* 2. `list_blended` — froxels in the outer transition band of the coarsest cascade (`c == count - 1`
|
|
9
|
+
* with `edge_weight > 0`), where clipmap irradiance blends into the far-field lighting.
|
|
10
|
+
* 3. `list_far_field` — froxels outside all cascades (`CLIPMAP_LEVEL_NONE`).
|
|
11
|
+
*
|
|
12
|
+
* @type {ComputeShader}
|
|
13
|
+
*/
|
|
14
|
+
export const shader_volumetrics_classify_froxels: ComputeShader;
|
|
15
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
16
|
+
//# sourceMappingURL=shader_volumetrics_classify_froxels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_volumetrics_classify_froxels.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/shader_volumetrics_classify_froxels.js"],"names":[],"mappings":"AAgBA,0EAAkF;AAyDlF;;;;;;;;;;;GAWG;AACH,kDAFU,aAAa,CAMpB;8BApF2B,4BAA4B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workgroup size (64 threads) used by each of the 3 volumetric lighting regime dispatches.
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
5
|
+
export const VOLUMETRICS_REGIME_WORKGROUP_SIZE: number;
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates far-field in-scattering at a froxel sample (`VolumetricsFroxelSample`) using the same
|
|
8
|
+
* full irradiance model as the world-space irradiance clipmap (environment GI + directional lights
|
|
9
|
+
* with atmospheric transmittance and multiple scattering, evaluated through
|
|
10
|
+
* `irradiance_clipmap_sh_multiscattering`).
|
|
11
|
+
*
|
|
12
|
+
* Shared as a first-class {@link CodeChunk} between `shader_volumetrics_lighting_blended` and
|
|
13
|
+
* `shader_volumetrics_lighting_far_field`.
|
|
14
|
+
*
|
|
15
|
+
* @type {CodeChunk}
|
|
16
|
+
*/
|
|
17
|
+
export const chunk_volumetrics_far_field_directional: CodeChunk;
|
|
18
|
+
export const shader_volumetrics_lighting_clipmap: ComputeShader;
|
|
19
|
+
export const shader_volumetrics_lighting_blended: ComputeShader;
|
|
20
|
+
export const shader_volumetrics_lighting_far_field: ComputeShader;
|
|
21
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
22
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
23
|
+
//# sourceMappingURL=shader_volumetrics_lighting_regimes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_volumetrics_lighting_regimes.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/shader_volumetrics_lighting_regimes.js"],"names":[],"mappings":"AA+CA;;;GAGG;AACH,gDAFU,MAAM,CAEoC;AAEpD;;;;;;;;;;GAUG;AACH,sDAFU,SAAS,CA6FjB;AAwFF,gEAIG;AAuFH,gEAIG;AA2DH,kEAIG;0BAhYuB,iCAAiC;8BAC7B,4BAA4B"}
|
|
@@ -42,7 +42,7 @@ export class GPUSceneWind {
|
|
|
42
42
|
* @param {number} capacity
|
|
43
43
|
* @returns {GPUTileAtlas3D}
|
|
44
44
|
*/
|
|
45
|
-
static "__#
|
|
45
|
+
static "__#161@#make_atlas"(device: GPUDevice, content: ArrayLike<number>, capacity: number): GPUTileAtlas3D;
|
|
46
46
|
/**
|
|
47
47
|
* @param {GPUDevice} device
|
|
48
48
|
*/
|
|
@@ -126,7 +126,7 @@ export class GPUSceneWind {
|
|
|
126
126
|
|
|
127
127
|
return new GPUTileAtlas3D({
|
|
128
128
|
device,
|
|
129
|
-
|
|
129
|
+
formats: [WIND_FIELD_TILE_FORMAT],
|
|
130
130
|
// copied by the atlas; made only when the atlas is
|
|
131
131
|
content_size: [content[0], content[1], content[2]],
|
|
132
132
|
border: WIND_FIELD_TILE_BORDER,
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a decal atlas fills the border around a patch.
|
|
3
|
-
*
|
|
4
|
-
* Two rules rather than one, because the correct fill depends on what the channel means and getting
|
|
5
|
-
* it wrong shows up only once the mip chain is built.
|
|
6
|
-
*
|
|
7
|
-
* @enum {number}
|
|
8
|
-
*/
|
|
9
|
-
export const DecalAtlasFill = {
|
|
10
|
-
/**
|
|
11
|
-
* Colour weighted by coverage, and a gutter of nothing.
|
|
12
|
-
*
|
|
13
|
-
* The patch is stored **premultiplied** and its border is zero. Averaging that pair down a mip
|
|
14
|
-
* chain gives premultiplied colour times coverage at every level, which is what a decal fading
|
|
15
|
-
* out at its edge should look like. The same arrangement in *straight* alpha is where dark
|
|
16
|
-
* halos come from — an edge texel averaged against transparent black keeps its alpha and loses
|
|
17
|
-
* its colour — and straight alpha beside a zeroed gutter is exactly what the atlas this
|
|
18
|
-
* replaces has today.
|
|
19
|
-
*/
|
|
20
|
-
PremultipliedCoverage: 0,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The nearest content texel, repeated outward.
|
|
24
|
-
*
|
|
25
|
-
* For channels that carry no coverage of their own — a normal, a roughness, a metalness — there
|
|
26
|
-
* is nothing to fade toward, and a zeroed gutter would drag a partially covered mip texel toward
|
|
27
|
-
* a meaningless value (a zero normal, mirror-smooth roughness). Coverage for these comes from
|
|
28
|
-
* the albedo's alpha, so their border repeats the edge and lets the mip chain average content
|
|
29
|
-
* against more of the same.
|
|
30
|
-
*/
|
|
31
|
-
EdgeExtend: 1,
|
|
32
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { chunk_cluster_depth_from_z_slice } from "../../light/cluster/chunk_cluster_depth_from_z_slice.js";
|
|
2
|
-
import { chunk_camera_ray_from_uv } from "../../shader/chunk/geometry/ray/chunk_camera_ray_from_uv.js";
|
|
3
|
-
import { RAY_STRUCT } from "../../shader/chunk/geometry/ray/RAY_STRUCT.js";
|
|
4
|
-
import { chunk_texel_coordinate_to_uv } from "../../shader/chunk/texture/chunk_texel_coordinate_to_uv.js";
|
|
5
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
6
|
-
import { chunk_camera_ray_planar_depth_scale } from "../chunk_camera_ray_planar_depth_scale.js";
|
|
7
|
-
import { chunk_volumetrics_froxel_content_offset } from "../chunk_volumetrics_froxel_content_offset.js";
|
|
8
|
-
import { CAMERA_RESOURCE } from "../../camera/CAMERA_RESOURCE.js";
|
|
9
|
-
import { VOLUMETRICS_METADATA_RESOURCE } from "../VOLUMETRICS_RESOURCES.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* `volumetrics_froxel_centre_ws(voxel, resolution)` — the world position a froxel's value stands for:
|
|
13
|
-
* its column's centre, at the depth its slab's content sits at (`volumetrics_froxel_content_offset`),
|
|
14
|
-
* which is where the lighting pass's jittered samples average to and where
|
|
15
|
-
* `volumetrics_position_world_to_froxel_uvw` puts the froxel's texel centre. A froxel GI module
|
|
16
|
-
* whose answer depends on position asks it there; GI is smooth enough across a froxel that one
|
|
17
|
-
* sample is all of it.
|
|
18
|
-
*
|
|
19
|
-
* The enclosing shader binds `camera` and `volumetrics_metadata` under those names.
|
|
20
|
-
*
|
|
21
|
-
* @type {CodeChunk}
|
|
22
|
-
*/
|
|
23
|
-
export const chunk_volumetrics_froxel_centre_ws = CodeChunk.from(
|
|
24
|
-
//language=WGSL
|
|
25
|
-
`
|
|
26
|
-
fn volumetrics_froxel_centre_ws(voxel: vec3<u32>, resolution: vec3<u32>) -> vec3<f32> {
|
|
27
|
-
let curve = volumetrics_metadata.froxel_cluster_parameters;
|
|
28
|
-
let near_far = camera.clip_near_far;
|
|
29
|
-
|
|
30
|
-
let slice = f32(voxel.z) + volumetrics_froxel_content_offset(curve.z);
|
|
31
|
-
let view_depth = clamp(cluster_depth_from_z_slice(slice, curve, f32(resolution.z)), near_far.x, near_far.y);
|
|
32
|
-
|
|
33
|
-
let ray = camera_ray_from_uv(texel_coordinate_to_uv(vec2<f32>(voxel.xy), resolution.xy), camera);
|
|
34
|
-
|
|
35
|
-
// planar depth to a distance along the ray, as the lighting pass does
|
|
36
|
-
return ray.origin + ray.direction * (view_depth * camera_ray_planar_depth_scale(ray.direction, camera));
|
|
37
|
-
}
|
|
38
|
-
`, [
|
|
39
|
-
RAY_STRUCT.declaration_chunk,
|
|
40
|
-
chunk_volumetrics_froxel_content_offset,
|
|
41
|
-
chunk_cluster_depth_from_z_slice,
|
|
42
|
-
chunk_camera_ray_from_uv,
|
|
43
|
-
chunk_texel_coordinate_to_uv,
|
|
44
|
-
chunk_camera_ray_planar_depth_scale,
|
|
45
|
-
]
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
chunk_volumetrics_froxel_centre_ws.requireResource(CAMERA_RESOURCE);
|
|
49
|
-
chunk_volumetrics_froxel_centre_ws.requireResource(VOLUMETRICS_METADATA_RESOURCE);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
METRO_L1_IRRADIANCE_STRUCT
|
|
3
|
-
} from "../../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
|
|
4
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
5
|
-
import { INDIRECT_LIGHT_INTENSITY } from "../../deferred/INDIRECT_LIGHT_INTENSITY.js";
|
|
6
|
-
import { chunk_volumetrics_irradiance_sh } from "../chunk_volumetrics_irradiance_sh.js";
|
|
7
|
-
import { VOLUMETRICS_GI_COCG_RESOURCE, VOLUMETRICS_GI_Y_RESOURCE } from "./volumetrics_gi_resources.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* How the froxel GI stage (`shader_volumetrics_gi`) stores its answer. One thread per froxel asks the
|
|
11
|
-
* renderer's indirect lighting mode what radiance arrives at the froxel, as RGB SH2
|
|
12
|
-
* (`chunk_volumetrics_gi_sample`), and hands the answer to `volumetrics_gi_store`. That starts the
|
|
13
|
-
* froxel irradiance volume, and `shader_volumetrics_build_irradiance` adds the lights to it.
|
|
14
|
-
*
|
|
15
|
-
* `volumetrics_gi_store(voxel, radiance)` scales the field by `INDIRECT_LIGHT_INTENSITY`, as the
|
|
16
|
-
* deferred and forward paths scale their indirect light, encodes it as the volume stores light
|
|
17
|
-
* (`volumetrics_irradiance_sh_add_radiance`) and writes it to `tGIY` / `tGICoCg`.
|
|
18
|
-
*
|
|
19
|
-
* The enclosing shader binds `tGIY` and `tGICoCg` under those names.
|
|
20
|
-
*
|
|
21
|
-
* @type {CodeChunk}
|
|
22
|
-
*/
|
|
23
|
-
export const chunk_volumetrics_gi = CodeChunk.from(
|
|
24
|
-
//language=WGSL
|
|
25
|
-
`
|
|
26
|
-
fn volumetrics_gi_store(voxel: vec3<u32>, radiance: array<vec3<f32>, 4>) {
|
|
27
|
-
const INDIRECT_INTENSITY : f32 = ${INDIRECT_LIGHT_INTENSITY};
|
|
28
|
-
|
|
29
|
-
let scaled = array<vec3<f32>, 4>(
|
|
30
|
-
radiance[0] * INDIRECT_INTENSITY,
|
|
31
|
-
radiance[1] * INDIRECT_INTENSITY,
|
|
32
|
-
radiance[2] * INDIRECT_INTENSITY,
|
|
33
|
-
radiance[3] * INDIRECT_INTENSITY,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
var sh: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
|
|
37
|
-
|
|
38
|
-
let stored = volumetrics_irradiance_sh_storable(volumetrics_irradiance_sh_add_radiance(sh, scaled));
|
|
39
|
-
|
|
40
|
-
textureStore(tGIY, voxel, stored.Y);
|
|
41
|
-
textureStore(tGICoCg, voxel, vec4<f32>(stored.CoCg, 0.0, 0.0));
|
|
42
|
-
}
|
|
43
|
-
`, [
|
|
44
|
-
METRO_L1_IRRADIANCE_STRUCT.declaration_chunk,
|
|
45
|
-
chunk_volumetrics_irradiance_sh,
|
|
46
|
-
]
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
chunk_volumetrics_gi.requireResource(VOLUMETRICS_GI_COCG_RESOURCE);
|
|
50
|
-
chunk_volumetrics_gi.requireResource(VOLUMETRICS_GI_Y_RESOURCE);
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { chunk_brick4_sample_sh } from "../../global_illumination/brick4/gpu/draw/chunk_brick4_sample_sh.js";
|
|
2
|
-
import { INDIRECT_LIGHTING } from "../../INDIRECT_LIGHTING.js";
|
|
3
|
-
import { ShadeIndirectLightingMode } from "../../ShadeIndirectLightingMode.js";
|
|
4
|
-
import { chunk_lpv_mesh_interpolation_probe_sh } from "../../shader/chunk/light/lpv/chunk_lpv_mesh_interpolation_probe_sh.js";
|
|
5
|
-
import { chunk_lpv_mesh_lookup_nearest_cell } from "../../shader/chunk/light/lpv/chunk_lpv_mesh_lookup_nearest_cell.js";
|
|
6
|
-
import { INVALID_TET_DECLARATION } from "../../shader/chunk/light/lpv/INVALID_TET_DECLARATION.js";
|
|
7
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
8
|
-
import { CodeChunkChoice } from "../../shader/compiler/CodeChunkChoice.js";
|
|
9
|
-
import { chunk_volumetrics_froxel_centre_ws } from "./chunk_volumetrics_froxel_centre_ws.js";
|
|
10
|
-
import { ENVIRONMENT_SH_RESOURCE } from "../../light/environment/ENVIRONMENT_SH_RESOURCE.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* {@link chunk_volumetrics_gi_sample} under IBL: the environment, as `GPULightCollection.environment_sh`
|
|
14
|
-
* holds it (`shader_project_environment_sh`). It is infinitely far, so every froxel receives the same
|
|
15
|
-
* field.
|
|
16
|
-
* @type {CodeChunk}
|
|
17
|
-
*/
|
|
18
|
-
export const chunk_volumetrics_gi_sample_ibl = CodeChunk.from(
|
|
19
|
-
//language=WGSL
|
|
20
|
-
`
|
|
21
|
-
fn volumetrics_gi_sample(voxel: vec3<u32>, resolution: vec3<u32>) -> array<vec3<f32>, 4> {
|
|
22
|
-
return array<vec3<f32>, 4>(
|
|
23
|
-
environment_sh[0].xyz,
|
|
24
|
-
environment_sh[1].xyz,
|
|
25
|
-
environment_sh[2].xyz,
|
|
26
|
-
environment_sh[3].xyz,
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
`, []);
|
|
30
|
-
|
|
31
|
-
chunk_volumetrics_gi_sample_ibl.requireResource(ENVIRONMENT_SH_RESOURCE);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* {@link chunk_volumetrics_gi_sample} under Brick4: the sparse volumetric light map's probes,
|
|
35
|
-
* interpolated at the froxel's centre and truncated from SH3 to SH2. Reads `brick4`.
|
|
36
|
-
* @type {CodeChunk}
|
|
37
|
-
*/
|
|
38
|
-
export const chunk_volumetrics_gi_sample_brick4 = CodeChunk.from(
|
|
39
|
-
//language=WGSL
|
|
40
|
-
`
|
|
41
|
-
fn volumetrics_gi_sample(voxel: vec3<u32>, resolution: vec3<u32>) -> array<vec3<f32>, 4> {
|
|
42
|
-
let position = volumetrics_froxel_centre_ws(voxel, resolution);
|
|
43
|
-
|
|
44
|
-
// A froxel has no surface. The normal only masks probes behind one, and a zero normal weighs
|
|
45
|
-
// every probe of the brick the same (brick4_probe_compute_weight_by_normal), which is the
|
|
46
|
-
// interpolation a point in open space wants.
|
|
47
|
-
let sh = brick4_sample_sh(position, vec3<f32>(0.0));
|
|
48
|
-
|
|
49
|
-
// SH3 to SH2: the first four coefficients are the same two bands, in the same order
|
|
50
|
-
return array<vec3<f32>, 4>(sh[0], sh[1], sh[2], sh[3]);
|
|
51
|
-
}
|
|
52
|
-
`, [
|
|
53
|
-
chunk_volumetrics_froxel_centre_ws,
|
|
54
|
-
chunk_brick4_sample_sh,
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* {@link chunk_volumetrics_gi_sample} under LPV: the light probe volume's tetrahedral mesh, its probes
|
|
59
|
-
* (radiance SH2) interpolated barycentrically at the froxel's centre. Reads the LPV's buffers.
|
|
60
|
-
* @type {CodeChunk}
|
|
61
|
-
*/
|
|
62
|
-
export const chunk_volumetrics_gi_sample_lpv = CodeChunk.from(
|
|
63
|
-
//language=WGSL
|
|
64
|
-
`
|
|
65
|
-
fn volumetrics_gi_sample(voxel: vec3<u32>, resolution: vec3<u32>) -> array<vec3<f32>, 4> {
|
|
66
|
-
let position = volumetrics_froxel_centre_ws(voxel, resolution);
|
|
67
|
-
|
|
68
|
-
var weights: vec4<f32>;
|
|
69
|
-
let tet = lpv_mesh_lookup_nearest_cell(position, &weights);
|
|
70
|
-
|
|
71
|
-
// Outside the probe mesh there is nothing to interpolate, and the deferred LPV pass gives such a
|
|
72
|
-
// point no indirect light either. No visibility mask: that needs a surface normal, and a froxel
|
|
73
|
-
// has none.
|
|
74
|
-
var radiance = array<vec3<f32>, 4>();
|
|
75
|
-
|
|
76
|
-
if (tet != INVALID_TET) {
|
|
77
|
-
radiance = lpv_mesh_interpolation_probe_sh(weights, tet);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return radiance;
|
|
81
|
-
}
|
|
82
|
-
`, [
|
|
83
|
-
chunk_volumetrics_froxel_centre_ws,
|
|
84
|
-
chunk_lpv_mesh_lookup_nearest_cell,
|
|
85
|
-
chunk_lpv_mesh_interpolation_probe_sh,
|
|
86
|
-
INVALID_TET_DECLARATION,
|
|
87
|
-
]);
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The radiance that arrives at a froxel, as RGB SH2, by the renderer's indirect lighting mode
|
|
91
|
-
* ({@link INDIRECT_LIGHTING}):
|
|
92
|
-
*
|
|
93
|
-
* ```wgsl
|
|
94
|
-
* fn volumetrics_gi_sample(voxel: vec3<u32>, resolution: vec3<u32>) -> array<vec3<f32>, 4>
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* A new mode is one more alternative: nothing downstream knows which mode wrote the volume.
|
|
98
|
-
*
|
|
99
|
-
* @type {CodeChunkChoice}
|
|
100
|
-
*/
|
|
101
|
-
export const chunk_volumetrics_gi_sample = CodeChunkChoice.from(INDIRECT_LIGHTING);
|
|
102
|
-
|
|
103
|
-
chunk_volumetrics_gi_sample.add(ShadeIndirectLightingMode.IBL, chunk_volumetrics_gi_sample_ibl);
|
|
104
|
-
chunk_volumetrics_gi_sample.add(ShadeIndirectLightingMode.Brick4, chunk_volumetrics_gi_sample_brick4);
|
|
105
|
-
chunk_volumetrics_gi_sample.add(ShadeIndirectLightingMode.LPV, chunk_volumetrics_gi_sample_lpv);
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { TextureResourceDescriptor } from "../../../device/graph/TextureResourceDescriptor.js";
|
|
2
|
-
import { graph_compute_pass } from "../../shader/graph/compute/graph_compute_pass.js";
|
|
3
|
-
import { graph_import_buffer } from "../../shader/graph/graph_import_buffer.js";
|
|
4
|
-
import { ShaderSwitchSet } from "../../shader/compiler/ShaderSwitchSet.js";
|
|
5
|
-
import { shader_volumetrics_gi } from "./shader_volumetrics_gi.js";
|
|
6
|
-
import { VOLUMETRICS_GI_WORKGROUP_RESOLUTION } from "./volumetrics_gi_resources.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The froxel GI stage: the renderer's indirect lighting at every froxel, as the froxel irradiance
|
|
10
|
-
* volume encodes light, for `shader_volumetrics_build_irradiance` to add the lights to. The shader is
|
|
11
|
-
* built for the renderer's switches, which pick the indirect lighting mode it samples
|
|
12
|
-
* (`chunk_volumetrics_gi_sample`); this binds the environment and the running mode's source.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} options.graph
|
|
16
|
-
* @param {ShaderSwitchSet} [options.shader_switches] the renderer's
|
|
17
|
-
* @param {import("../../scene/GPUSceneContext.js").GPUSceneContext} options.scene_ctx for its environment,
|
|
18
|
-
* `lights.environment_sh`
|
|
19
|
-
* @param {import("../../global_illumination/brick4/Brick4LightMap.js").Brick4LightMap} [options.brick4] the scene's,
|
|
20
|
-
* while Brick4 runs
|
|
21
|
-
* @param {import("../../global_illumination/lpv/GPULightProbeVolume.js").GPULightProbeVolume} [options.lpv] the
|
|
22
|
-
* scene's, while LPV runs. A source not given is the shader's default, for a variant that does not read it
|
|
23
|
-
* @param {import("../../camera/GPUCameraContext.js").GPUCameraContext} options.camera
|
|
24
|
-
* @param {number} options.volumetrics_metadata graph handle
|
|
25
|
-
* @param {number[]} options.resolution the froxel grid
|
|
26
|
-
* @returns {{Y: number, CoCg: number}} handles of the GI volume, in the froxel irradiance encoding
|
|
27
|
-
*/
|
|
28
|
-
export function graph_build_froxel_gi({
|
|
29
|
-
graph,
|
|
30
|
-
shader_switches = ShaderSwitchSet.EMPTY,
|
|
31
|
-
scene_ctx,
|
|
32
|
-
brick4,
|
|
33
|
-
lpv,
|
|
34
|
-
camera,
|
|
35
|
-
volumetrics_metadata,
|
|
36
|
-
resolution,
|
|
37
|
-
}) {
|
|
38
|
-
const volume = () => TextureResourceDescriptor.from({
|
|
39
|
-
resolution,
|
|
40
|
-
dimension: "3d",
|
|
41
|
-
format: "rgba16float",
|
|
42
|
-
usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const bindings = {
|
|
46
|
-
volumetrics_metadata,
|
|
47
|
-
camera: graph_import_buffer(graph, camera.buffer.buffer, "froxel gi camera"),
|
|
48
|
-
tGIY: volume(),
|
|
49
|
-
tGICoCg: volume(),
|
|
50
|
-
environment_sh: scene_ctx.lights.environment_sh,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// the running mode's source; the others are the shader's defaults, which its variant does not read
|
|
54
|
-
if (brick4 !== undefined) {
|
|
55
|
-
bindings.brick4 = brick4.buffer;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (lpv !== undefined) {
|
|
59
|
-
bindings.lpv_lookup = lpv.buffer_mesh_bvh;
|
|
60
|
-
bindings.lpv_metadata = lpv.buffer_metadata;
|
|
61
|
-
bindings.lpv_mesh = lpv.buffer_mesh;
|
|
62
|
-
bindings.lpv_probes = lpv.buffer_probes;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const outputs = graph_compute_pass({
|
|
66
|
-
graph,
|
|
67
|
-
shader: shader_volumetrics_gi.variant(shader_switches),
|
|
68
|
-
group_count: [
|
|
69
|
-
Math.ceil(resolution[0] / VOLUMETRICS_GI_WORKGROUP_RESOLUTION[0]),
|
|
70
|
-
Math.ceil(resolution[1] / VOLUMETRICS_GI_WORKGROUP_RESOLUTION[1]),
|
|
71
|
-
Math.ceil(resolution[2] / VOLUMETRICS_GI_WORKGROUP_RESOLUTION[2]),
|
|
72
|
-
],
|
|
73
|
-
bindings,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
Y: outputs.tGIY,
|
|
78
|
-
CoCg: outputs.tGICoCg,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BRICK4_DATA_STRUCT } from "../../global_illumination/brick4/gpu/BRICK4_DATA_STRUCT.js";
|
|
2
|
-
import { LPV_SHADER_RESOURCE_GROUP_WITH_DEFAULTS } from "../../global_illumination/probe/octahedral/LPV_SHADER_RESOURCE_GROUP.js";
|
|
3
|
-
import { ENVIRONMENT_SH_TYPE } from "../../light/environment/shader_project_environment_sh.js";
|
|
4
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
5
|
-
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
6
|
-
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
7
|
-
import { chunk_volumetrics_gi } from "./chunk_volumetrics_gi.js";
|
|
8
|
-
import { chunk_volumetrics_gi_sample } from "./chunk_volumetrics_gi_sample.js";
|
|
9
|
-
import { VOLUMETRICS_GI_WORKGROUP_RESOLUTION, volumetrics_gi_resource_group } from "./volumetrics_gi_resources.js";
|
|
10
|
-
|
|
11
|
-
const resources = new ShaderResourceSetDescriptor();
|
|
12
|
-
|
|
13
|
-
// every indirect lighting mode's source, whichever the variant reads (chunk_volumetrics_gi_sample). The pass
|
|
14
|
-
// binds the environment and the running mode's source; the others have defaults the variant does not read.
|
|
15
|
-
resources.addGroup(
|
|
16
|
-
volumetrics_gi_resource_group()
|
|
17
|
-
.addUniform("environment_sh", ENVIRONMENT_SH_TYPE)
|
|
18
|
-
.addStorageBuffer("brick4", BRICK4_DATA_STRUCT, false, true)
|
|
19
|
-
);
|
|
20
|
-
resources.addGroup(LPV_SHADER_RESOURCE_GROUP_WITH_DEFAULTS);
|
|
21
|
-
|
|
22
|
-
const body = CodeChunk.from(
|
|
23
|
-
//language=WGSL
|
|
24
|
-
`
|
|
25
|
-
@compute @workgroup_size(${VOLUMETRICS_GI_WORKGROUP_RESOLUTION.join(", ")})
|
|
26
|
-
fn main(@builtin(global_invocation_id) voxel: vec3<u32>) {
|
|
27
|
-
let resolution = textureDimensions(tGIY);
|
|
28
|
-
|
|
29
|
-
if (any(voxel >= resolution)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
volumetrics_gi_store(voxel, volumetrics_gi_sample(voxel, resolution));
|
|
34
|
-
}
|
|
35
|
-
`, [
|
|
36
|
-
chunk_volumetrics_gi,
|
|
37
|
-
chunk_volumetrics_gi_sample,
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The froxel GI stage: the renderer's indirect lighting at every froxel, one thread per froxel. Which
|
|
42
|
-
* mode's light it asks for is a shader switch ({@link chunk_volumetrics_gi_sample}); the bindings are
|
|
43
|
-
* the same for every mode. See `chunk_volumetrics_gi` for what it does with the answer.
|
|
44
|
-
*
|
|
45
|
-
* @type {ComputeShader}
|
|
46
|
-
*/
|
|
47
|
-
export const shader_volumetrics_gi = ComputeShader.from({
|
|
48
|
-
label: "Volumetrics / GI",
|
|
49
|
-
resources,
|
|
50
|
-
body,
|
|
51
|
-
});
|