@woosh/meep-engine 3.11.1 → 3.11.3
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/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
- package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +294 -290
- package/src/engine/graphics3/ParticipatingMedia.d.ts +111 -0
- package/src/engine/graphics3/ParticipatingMedia.d.ts.map +1 -0
- package/src/engine/graphics3/ParticipatingMedia.js +203 -0
- package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts +34 -0
- package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.js +73 -0
- package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts +87 -0
- package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts.map +1 -0
- package/src/engine/graphics3/ParticipatingMediaSystem3.js +184 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.d.ts +16 -2
- package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.d.ts.map +1 -1
- package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.js +28 -4
- package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.d.ts +1 -1
- package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.d.ts.map +1 -1
- package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.js +5 -2
- package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +564 -451
- package/src/shade/device/ShadeGPUCommandContext.d.ts +18 -2
- package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
- package/src/shade/device/ShadeGPUCommandContext.js +994 -940
- package/src/shade/device/immediate_data_supported.d.ts +33 -0
- package/src/shade/device/immediate_data_supported.d.ts.map +1 -0
- package/src/shade/device/immediate_data_supported.js +53 -0
- package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts +18 -0
- package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts.map +1 -1
- package/src/shade/device/mock/SoftwareGPUCommandEncoder.js +24 -0
- package/src/shade/device/mock/SoftwareGPUComputePassEncoder.d.ts +7 -0
- package/src/shade/device/mock/SoftwareGPUComputePassEncoder.d.ts.map +1 -1
- package/src/shade/device/mock/SoftwareGPUComputePassEncoder.js +49 -1
- package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
- package/src/shade/device/mock/SoftwareGPUDevice.js +20 -2
- package/src/shade/device/mock/SoftwareGPUImmediateData.d.ts +65 -0
- package/src/shade/device/mock/SoftwareGPUImmediateData.d.ts.map +1 -0
- package/src/shade/device/mock/SoftwareGPUImmediateData.js +160 -0
- package/src/shade/device/mock/SoftwareGPURenderPassEncoder.d.ts +7 -0
- package/src/shade/device/mock/SoftwareGPURenderPassEncoder.d.ts.map +1 -1
- package/src/shade/device/mock/SoftwareGPURenderPassEncoder.js +50 -0
- package/src/shade/device/mock/pipeline_immediate_size.d.ts +11 -0
- package/src/shade/device/mock/pipeline_immediate_size.d.ts.map +1 -0
- package/src/shade/device/mock/pipeline_immediate_size.js +18 -0
- package/src/shade/device/pipeline/PipelineLayoutManager.d.ts.map +1 -1
- package/src/shade/device/pipeline/PipelineLayoutManager.js +1 -0
- package/src/shade/playground/volumetrics_froxel/README.md +104 -1
- package/src/shade/playground/volumetrics_froxel/index.html +20 -1
- package/src/shade/playground/volumetrics_froxel/main.d.ts.map +1 -1
- package/src/shade/playground/volumetrics_froxel/main.js +298 -0
- package/src/shade/playground/volumetrics_froxel/measure.d.ts +119 -0
- package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -0
- package/src/shade/playground/volumetrics_froxel/measure.js +559 -0
- package/src/shade/renderer/GraphicsContext.d.ts +9 -2
- package/src/shade/renderer/GraphicsContext.d.ts.map +1 -1
- package/src/shade/renderer/GraphicsContext.js +13 -1
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +22 -18
- package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/GPUSky.js +145 -142
- package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.d.ts +34 -0
- package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.js +36 -0
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts +20 -0
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.js +25 -0
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts +14 -1
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.js +163 -177
- package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.d.ts +20 -0
- package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.js +46 -0
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts +11 -1
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js +57 -27
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts +19 -1
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js +69 -33
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts +13 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js +35 -35
- package/src/shade/renderer/atmosphere/chunk_sky_lut_params.d.ts +13 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_params.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_params.js +38 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.d.ts +17 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.js +29 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.d.ts +21 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.js +42 -0
- package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts +2 -2
- package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +165 -84
- package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js +215 -204
- package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_transmittance_lut.js +79 -67
- package/src/shade/renderer/light/cluster/graph_assign_clsuters.d.ts.map +1 -1
- package/src/shade/renderer/light/cluster/graph_assign_clsuters.js +6 -2
- package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/GTAO.js +4 -0
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +341 -345
- package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts +0 -2
- package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.js +58 -57
- package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +7 -3
- package/src/shade/renderer/rasterize/fast/graph_extract_meshes_from_bucket.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/fast/graph_extract_meshes_from_bucket.js +77 -81
- package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +5 -1
- package/src/shade/renderer/shader/ComputeShader.d.ts.map +1 -1
- package/src/shade/renderer/shader/ComputeShader.js +6 -2
- package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
- package/src/shade/renderer/shader/ImageShader.js +4 -1
- package/src/shade/renderer/shader/ShaderDescriptor.d.ts.map +1 -1
- package/src/shade/renderer/shader/ShaderDescriptor.js +26 -0
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts +18 -0
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js +32 -0
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.d.ts +7 -0
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.js +17 -6
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts +21 -0
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js +69 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.d.ts +9 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.js +22 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.js +41 -0
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.d.ts +11 -0
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.js +15 -19
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.d.ts +23 -0
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.js +44 -0
- package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_octahedral_unit_decode.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_octahedral_unit_decode.js +1 -4
- package/src/shade/renderer/shader/compiler/CodeChunk.d.ts +7 -1
- package/src/shade/renderer/shader/compiler/CodeChunk.d.ts.map +1 -1
- package/src/shade/renderer/shader/compiler/CodeChunk.js +37 -2
- package/src/shade/renderer/shader/graph/compute/compute_binding_read_names.d.ts.map +1 -1
- package/src/shade/renderer/shader/graph/compute/compute_binding_read_names.js +6 -0
- package/src/shade/renderer/shader/graph/compute/graph_compute_indirect_pass.js +1 -1
- package/src/shade/renderer/shader/graph/compute/graph_compute_pass.js +1 -1
- package/src/shade/renderer/shader/graph/graph_image_pass.js +1 -1
- package/src/shade/renderer/shader/graph/graph_prepare_bindings.d.ts.map +1 -1
- package/src/shade/renderer/shader/graph/graph_prepare_bindings.js +7 -0
- package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.d.ts +3 -1
- package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.d.ts.map +1 -1
- package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.js +12 -1
- package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts.map +1 -1
- package/src/shade/renderer/shader/pass/RenderPassDescriptor.js +1 -0
- package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.d.ts +21 -0
- package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.d.ts.map +1 -0
- package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.js +21 -0
- package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.d.ts +59 -1
- package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.d.ts.map +1 -1
- package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.js +195 -2
- package/src/shade/renderer/shader/type/type_has_arrays.d.ts +14 -0
- package/src/shade/renderer/shader/type/type_has_arrays.d.ts.map +1 -0
- package/src/shade/renderer/shader/type/type_has_arrays.js +33 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +14 -13
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +133 -129
- package/src/shade/renderer/view/GPUViewSkyContext.d.ts.map +1 -1
- package/src/shade/renderer/view/GPUViewSkyContext.js +169 -173
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +480 -315
- package/src/shade/renderer/volumetrics/NOTES.md +887 -8
- package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts +5 -0
- package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.js +21 -2
- package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts +26 -0
- package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/SceneVolumetrics.js +64 -21
- package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.js +84 -28
- package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts +98 -0
- package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.js +111 -0
- package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts +84 -0
- package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.js +252 -0
- package/src/shade/renderer/volumetrics/chunk_integrate_optical_depth.js +75 -75
- package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts +43 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.js +145 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts +20 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.js +48 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts +38 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.js +130 -0
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +18 -3
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +193 -70
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts +16 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +83 -15
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.js +29 -18
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +260 -260
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts +58 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts.map +1 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.js +290 -0
- package/src/shade/wgsl/emulator/CPUBitmapData.d.ts +25 -0
- package/src/shade/wgsl/emulator/CPUBitmapData.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/CPUBitmapData.js +33 -0
- package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +2228 -2215
- package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.js +210 -2
- package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts +69 -0
- package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts.map +1 -0
- package/src/shade/wgsl/emulator/cpu_texture_gather.js +148 -0
- package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts +16 -0
- package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/cpu_texture_sample.js +176 -172
- package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.d.ts +0 -2
- package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.d.ts.map +0 -1
- package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.js +0 -1
|
@@ -1,33 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { chunk_sky_lut_params } from "./chunk_sky_lut_params.js";
|
|
3
|
+
import { chunk_sky_lut_uv } from "./chunk_sky_lut_uv.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Assumes following in the context:
|
|
7
|
+
* tSkyLutTransmittance: texture_2d<f32> (sample type "float", i.e. filterable)
|
|
8
|
+
* sSkyLut: sampler (see {@link SAMPLER_SKY_LUT})
|
|
9
|
+
*
|
|
10
|
+
* The LUT is rgba16float, which is filterable in core WebGPU -- only the 32-bit float
|
|
11
|
+
* formats need the `float32-filterable` feature -- so this goes through the texture unit
|
|
12
|
+
* rather than the 4-tap `texture_sample_bilinear_uv`. Clamp-to-edge on the sampler
|
|
13
|
+
* reproduces that function's per-corner clamping.
|
|
14
|
+
*
|
|
15
|
+
* The half-texel inset {@link chunk_sky_lut_uv} applies needs the LUT's resolution, which is
|
|
16
|
+
* read from the binding rather than passed in: the texture is the authority on its own size,
|
|
17
|
+
* and a caller cannot get it wrong.
|
|
18
|
+
*
|
|
19
|
+
* see {@link shader_transmittance_lut}
|
|
20
|
+
* @type {CodeChunk}
|
|
21
|
+
*/
|
|
22
|
+
export const chunk_sample_transmittance_lut_params = CodeChunk.from(
|
|
23
|
+
//language=WGSL
|
|
24
|
+
`
|
|
25
|
+
fn sample_transmittance_lut_params(
|
|
26
|
+
height: f32,
|
|
27
|
+
sun_cos_zenith_angle: f32
|
|
28
|
+
) -> vec3<f32>{
|
|
29
|
+
|
|
30
|
+
let uv = sky_lut_uv(
|
|
31
|
+
height,
|
|
32
|
+
sun_cos_zenith_angle,
|
|
33
|
+
vec2<f32>(textureDimensions(tSkyLutTransmittance))
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return textureSampleLevel(tSkyLutTransmittance, sSkyLut, uv, 0.0).rgb;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
`, [
|
|
40
|
+
chunk_sky_lut_uv,
|
|
41
|
+
]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* {@link chunk_sample_transmittance_lut_params} from a world-space position. A ray-march that
|
|
46
|
+
* already knows the altitude and the local up vector should build the pair itself and call
|
|
47
|
+
* the primitive, rather than have this recover them with another square root.
|
|
48
|
+
*
|
|
49
|
+
* @type {CodeChunk}
|
|
50
|
+
*/
|
|
51
|
+
export const chunk_sample_transmittance_lut = CodeChunk.from(
|
|
52
|
+
//language=WGSL
|
|
53
|
+
`
|
|
54
|
+
fn sample_transmittance_lut(
|
|
55
|
+
pos: vec3<f32>,
|
|
56
|
+
sunDir: vec3<f32>
|
|
57
|
+
) -> vec3<f32>{
|
|
58
|
+
|
|
59
|
+
let params = sky_lut_params(pos, sunDir);
|
|
60
|
+
|
|
61
|
+
return sample_transmittance_lut_params(params.x, params.y);
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
[
|
|
66
|
+
chunk_sample_transmittance_lut_params,
|
|
67
|
+
chunk_sky_lut_params,
|
|
68
|
+
]
|
|
69
|
+
);
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link chunk_sky_lut_uv} straight from a world-space position, for a shader that samples a
|
|
3
|
+
* sky LUT through its own binding rather than through the `sample_*_lut_params` chunks --
|
|
4
|
+
* the volumetrics passes, which bind the same transmittance LUT under a name of their own.
|
|
5
|
+
*
|
|
6
|
+
* `resolution` is the LUT's, and it matters: the half-texel inset is what makes a lookup at
|
|
7
|
+
* either end of the range read a value that was computed there. Pass
|
|
8
|
+
* `vec2<f32>(textureDimensions(...))` of the texture being sampled, not of some other one --
|
|
9
|
+
* the transmittance and multiple-scattering LUTs are different sizes, so one uv cannot serve
|
|
10
|
+
* both.
|
|
11
|
+
*
|
|
12
|
+
* @type {CodeChunk}
|
|
13
|
+
*/
|
|
1
14
|
export const chunk_sky_lut_compute_uv: CodeChunk;
|
|
2
15
|
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
3
16
|
//# sourceMappingURL=chunk_sky_lut_compute_uv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_sky_lut_compute_uv.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_sky_lut_compute_uv.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,uCAFU,SAAS,CAmBlB;0BAlCyB,iCAAiC"}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]
|
|
35
|
-
)
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { chunk_sky_lut_params } from "./chunk_sky_lut_params.js";
|
|
3
|
+
import { chunk_sky_lut_uv } from "./chunk_sky_lut_uv.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link chunk_sky_lut_uv} straight from a world-space position, for a shader that samples a
|
|
7
|
+
* sky LUT through its own binding rather than through the `sample_*_lut_params` chunks --
|
|
8
|
+
* the volumetrics passes, which bind the same transmittance LUT under a name of their own.
|
|
9
|
+
*
|
|
10
|
+
* `resolution` is the LUT's, and it matters: the half-texel inset is what makes a lookup at
|
|
11
|
+
* either end of the range read a value that was computed there. Pass
|
|
12
|
+
* `vec2<f32>(textureDimensions(...))` of the texture being sampled, not of some other one --
|
|
13
|
+
* the transmittance and multiple-scattering LUTs are different sizes, so one uv cannot serve
|
|
14
|
+
* both.
|
|
15
|
+
*
|
|
16
|
+
* @type {CodeChunk}
|
|
17
|
+
*/
|
|
18
|
+
export const chunk_sky_lut_compute_uv = CodeChunk.from(
|
|
19
|
+
//language=WGSL
|
|
20
|
+
`
|
|
21
|
+
fn sky_lut_compute_uv(
|
|
22
|
+
pos: vec3<f32>,
|
|
23
|
+
sunDir: vec3<f32>,
|
|
24
|
+
resolution: vec2<f32>
|
|
25
|
+
) -> vec2<f32> {
|
|
26
|
+
|
|
27
|
+
let params = sky_lut_params(pos, sunDir);
|
|
28
|
+
|
|
29
|
+
return sky_lut_uv(params.x, params.y, resolution);
|
|
30
|
+
}
|
|
31
|
+
`, [
|
|
32
|
+
chunk_sky_lut_params,
|
|
33
|
+
chunk_sky_lut_uv,
|
|
34
|
+
]
|
|
35
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pair every sky LUT is addressed by — altitude in `x`, cosine of the sun's zenith angle
|
|
3
|
+
* in `y` — recovered from a world-space position.
|
|
4
|
+
*
|
|
5
|
+
* Costs the square root a ray-march step has usually already paid for: a march that is
|
|
6
|
+
* stepping a planet-relative position should build the pair itself and call the
|
|
7
|
+
* `sample_*_lut_params` primitives directly rather than come through here.
|
|
8
|
+
*
|
|
9
|
+
* @type {CodeChunk}
|
|
10
|
+
*/
|
|
11
|
+
export const chunk_sky_lut_params: CodeChunk;
|
|
12
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
13
|
+
//# sourceMappingURL=chunk_sky_lut_params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_sky_lut_params.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sky_lut_params.js"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,mCAFU,SAAS,CAuBjB;0BAjCwB,iCAAiC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ATMOSPHERE_RADII_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js";
|
|
2
|
+
import {
|
|
3
|
+
chunk_position_relative_to_planet_center
|
|
4
|
+
} from "../shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js";
|
|
5
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The pair every sky LUT is addressed by — altitude in `x`, cosine of the sun's zenith angle
|
|
9
|
+
* in `y` — recovered from a world-space position.
|
|
10
|
+
*
|
|
11
|
+
* Costs the square root a ray-march step has usually already paid for: a march that is
|
|
12
|
+
* stepping a planet-relative position should build the pair itself and call the
|
|
13
|
+
* `sample_*_lut_params` primitives directly rather than come through here.
|
|
14
|
+
*
|
|
15
|
+
* @type {CodeChunk}
|
|
16
|
+
*/
|
|
17
|
+
export const chunk_sky_lut_params = CodeChunk.from(
|
|
18
|
+
//language=WGSL
|
|
19
|
+
`
|
|
20
|
+
fn sky_lut_params(
|
|
21
|
+
pos: vec3<f32>,
|
|
22
|
+
sunDir: vec3<f32>
|
|
23
|
+
) -> vec2<f32> {
|
|
24
|
+
|
|
25
|
+
let rel = position_relative_to_planet_center(pos);
|
|
26
|
+
|
|
27
|
+
let radius = length(rel);
|
|
28
|
+
|
|
29
|
+
return vec2(
|
|
30
|
+
radius - ATMOSPHERE_GROUND_RADIUS,
|
|
31
|
+
dot(sunDir, rel / radius)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
`, [
|
|
35
|
+
chunk_position_relative_to_planet_center,
|
|
36
|
+
ATMOSPHERE_RADII_DECLARATION,
|
|
37
|
+
]
|
|
38
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which point of the parameter range a sky LUT texel stands for: the generator's half of the
|
|
3
|
+
* mapping {@link chunk_sky_lut_uv} inverts. Texel 0 carries the bottom of the range and the
|
|
4
|
+
* last texel the top, so a lookup at either end reads a value that was actually computed
|
|
5
|
+
* there rather than one from half a texel inside.
|
|
6
|
+
*
|
|
7
|
+
* `texel` is the integer index, not a texel centre — pass the invocation's own coordinate,
|
|
8
|
+
* not `coord.xy` from a fragment shader.
|
|
9
|
+
*
|
|
10
|
+
* Both components come back in [0,1]; the caller maps them onto the physical ranges (the sun
|
|
11
|
+
* zenith cosine and the altitude).
|
|
12
|
+
*
|
|
13
|
+
* @type {CodeChunk}
|
|
14
|
+
*/
|
|
15
|
+
export const chunk_sky_lut_texel_to_unit: CodeChunk;
|
|
16
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
17
|
+
//# sourceMappingURL=chunk_sky_lut_texel_to_unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_sky_lut_texel_to_unit.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,0CAFU,SAAS,CAcjB;0BA5BwB,iCAAiC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which point of the parameter range a sky LUT texel stands for: the generator's half of the
|
|
5
|
+
* mapping {@link chunk_sky_lut_uv} inverts. Texel 0 carries the bottom of the range and the
|
|
6
|
+
* last texel the top, so a lookup at either end reads a value that was actually computed
|
|
7
|
+
* there rather than one from half a texel inside.
|
|
8
|
+
*
|
|
9
|
+
* `texel` is the integer index, not a texel centre — pass the invocation's own coordinate,
|
|
10
|
+
* not `coord.xy` from a fragment shader.
|
|
11
|
+
*
|
|
12
|
+
* Both components come back in [0,1]; the caller maps them onto the physical ranges (the sun
|
|
13
|
+
* zenith cosine and the altitude).
|
|
14
|
+
*
|
|
15
|
+
* @type {CodeChunk}
|
|
16
|
+
*/
|
|
17
|
+
export const chunk_sky_lut_texel_to_unit = CodeChunk.from(
|
|
18
|
+
//language=WGSL
|
|
19
|
+
`
|
|
20
|
+
fn sky_lut_texel_to_unit(
|
|
21
|
+
texel: vec2<f32>,
|
|
22
|
+
resolution: vec2<f32>
|
|
23
|
+
) -> vec2<f32> {
|
|
24
|
+
|
|
25
|
+
// a one-texel axis has no range to spread: it stands for the bottom of it
|
|
26
|
+
return texel / max(resolution - 1.0, vec2(1.0));
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameterisation shared by the transmittance and multiple-scattering LUTs: `x` is the
|
|
3
|
+
* cosine of the sun's zenith angle remapped to [0,1], `y` is the altitude as a fraction of
|
|
4
|
+
* the atmosphere's thickness.
|
|
5
|
+
*
|
|
6
|
+
* The result is a texture coordinate, not the raw parameter pair. A LUT of N texels can only
|
|
7
|
+
* store N samples of a continuous range, and the two ends of that range have to land on the
|
|
8
|
+
* two end texels: without the half-texel inset here, a lookup at altitude zero addresses the
|
|
9
|
+
* texel a generator wrote for the centre of the first row -- 780 m up in the 64-row
|
|
10
|
+
* transmittance LUT, which is a tenth of a Rayleigh scale height. Hillaire spends
|
|
11
|
+
* `fromUnitToSubUvs` / `fromSubUvsToUnit` on the same problem.
|
|
12
|
+
*
|
|
13
|
+
* {@link chunk_sky_lut_texel_to_unit} is the other half, and the two have to agree — a
|
|
14
|
+
* generator that does not use it writes a LUT this addresses wrongly. `sky_lut_uv.spec.js`
|
|
15
|
+
* round-trips them.
|
|
16
|
+
*
|
|
17
|
+
* @type {CodeChunk}
|
|
18
|
+
*/
|
|
19
|
+
export const chunk_sky_lut_uv: CodeChunk;
|
|
20
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
21
|
+
//# sourceMappingURL=chunk_sky_lut_uv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_sky_lut_uv.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sky_lut_uv.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,+BAFU,SAAS,CAsBjB;0BAxCwB,iCAAiC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ATMOSPHERE_HEIGHT_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js";
|
|
2
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parameterisation shared by the transmittance and multiple-scattering LUTs: `x` is the
|
|
6
|
+
* cosine of the sun's zenith angle remapped to [0,1], `y` is the altitude as a fraction of
|
|
7
|
+
* the atmosphere's thickness.
|
|
8
|
+
*
|
|
9
|
+
* The result is a texture coordinate, not the raw parameter pair. A LUT of N texels can only
|
|
10
|
+
* store N samples of a continuous range, and the two ends of that range have to land on the
|
|
11
|
+
* two end texels: without the half-texel inset here, a lookup at altitude zero addresses the
|
|
12
|
+
* texel a generator wrote for the centre of the first row -- 780 m up in the 64-row
|
|
13
|
+
* transmittance LUT, which is a tenth of a Rayleigh scale height. Hillaire spends
|
|
14
|
+
* `fromUnitToSubUvs` / `fromSubUvsToUnit` on the same problem.
|
|
15
|
+
*
|
|
16
|
+
* {@link chunk_sky_lut_texel_to_unit} is the other half, and the two have to agree — a
|
|
17
|
+
* generator that does not use it writes a LUT this addresses wrongly. `sky_lut_uv.spec.js`
|
|
18
|
+
* round-trips them.
|
|
19
|
+
*
|
|
20
|
+
* @type {CodeChunk}
|
|
21
|
+
*/
|
|
22
|
+
export const chunk_sky_lut_uv = CodeChunk.from(
|
|
23
|
+
//language=WGSL
|
|
24
|
+
`
|
|
25
|
+
fn sky_lut_uv(
|
|
26
|
+
height: f32,
|
|
27
|
+
sun_cos_zenith_angle: f32,
|
|
28
|
+
resolution: vec2<f32>
|
|
29
|
+
) -> vec2<f32> {
|
|
30
|
+
|
|
31
|
+
let unit = vec2(
|
|
32
|
+
saturate(0.5 + 0.5 * sun_cos_zenith_angle),
|
|
33
|
+
saturate(height / ATMOSPHERE_HEIGHT)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// unit 0 lands on the centre of texel 0, unit 1 on the centre of the last one
|
|
37
|
+
return (unit * (resolution - 1.0) + 0.5) / resolution;
|
|
38
|
+
}
|
|
39
|
+
`, [
|
|
40
|
+
ATMOSPHERE_HEIGHT_DECLARATION,
|
|
41
|
+
]
|
|
42
|
+
);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const shader_multiscatter_lut:
|
|
2
|
-
import {
|
|
1
|
+
export const shader_multiscatter_lut: ComputeShader;
|
|
2
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
3
3
|
//# sourceMappingURL=shader_multiscatter_lut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_multiscatter_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_multiscatter_lut.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_multiscatter_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_multiscatter_lut.js"],"names":[],"mappings":"AA+JA,oDAKG;8BAhK2B,4BAA4B"}
|
|
@@ -1,84 +1,165 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
import { WebGPUExtensionType } from "../../descriptor/WebGPUExtensionType.js";
|
|
2
|
+
import { ATMOSPHERE_HEIGHT_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js";
|
|
3
|
+
import { chunk_safe_acos } from "../shader/chunk/math/chunk_safe_acos.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_get_multiscatter_values } from "./chunk_get_multiscatter_values.js";
|
|
8
|
+
import { chunk_multiscatter_sample_direction } from "./chunk_multiscatter_sample_direction.js";
|
|
9
|
+
import { chunk_sky_lut_texel_to_unit } from "./chunk_sky_lut_texel_to_unit.js";
|
|
10
|
+
import {
|
|
11
|
+
MULTISCATTER_LUT_DIRECTION_COUNT,
|
|
12
|
+
MULTISCATTER_LUT_MAX_SUBGROUP_PARTIALS
|
|
13
|
+
} from "./MULTISCATTER_LUT_CONFIG.js";
|
|
14
|
+
import { SAMPLER_SKY_LUT } from "./SAMPLER_SKY_LUT.js";
|
|
15
|
+
|
|
16
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
17
|
+
resources.createGroup()
|
|
18
|
+
// "float" rather than the default "unfilterable-float": rgba16float is filterable in
|
|
19
|
+
// core WebGPU, so the LUT goes through the texture unit instead of a 4-tap manual
|
|
20
|
+
// bilinear.
|
|
21
|
+
.addTexture("tSkyLutTransmittance", "float")
|
|
22
|
+
.addSampler("sSkyLut", "filtering", SAMPLER_SKY_LUT)
|
|
23
|
+
.addStorageTexture("tSkyLutMultiscatterOut", "rgba16float")
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* the multiple-scattering LUT. Each pixel coordinate corresponds to a height and sun zenith angle, and
|
|
29
|
+
* the value is the multiple scattering approximation (Psi_ms from the paper, Eq. 10).
|
|
30
|
+
*
|
|
31
|
+
* One workgroup per LUT texel, one thread per direction, mirroring Hillaire's
|
|
32
|
+
* `[numthreads(1,1,64)]` `NewMultiScattCS`. The 64 directions used to be a serial loop
|
|
33
|
+
* inside a fragment shader, which left the whole pass with 32*32 = 1024 threads of
|
|
34
|
+
* parallelism -- a few dozen waves, one per scheduler at best, with nothing to hide the
|
|
35
|
+
* latency of the transmittance fetches. Per-thread it is now a single direction's 20-step
|
|
36
|
+
* march.
|
|
37
|
+
*
|
|
38
|
+
* The per-direction results are summed with `subgroupAdd` and then across subgroups through
|
|
39
|
+
* workgroup memory; Hillaire uses a six-step groupshared log-reduction, which the subgroup
|
|
40
|
+
* op collapses into one instruction plus a handful of partials.
|
|
41
|
+
*
|
|
42
|
+
* @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
|
|
43
|
+
* @see https://www.shadertoy.com/view/slSXRW
|
|
44
|
+
* @type {CodeChunk}
|
|
45
|
+
*/
|
|
46
|
+
const body = CodeChunk.from(
|
|
47
|
+
//language=WGSL
|
|
48
|
+
`
|
|
49
|
+
const MULTISCATTER_DIRECTION_COUNT = ${MULTISCATTER_LUT_DIRECTION_COUNT}u;
|
|
50
|
+
const MULTISCATTER_MAX_SUBGROUP_PARTIALS = ${MULTISCATTER_LUT_MAX_SUBGROUP_PARTIALS}u;
|
|
51
|
+
|
|
52
|
+
var<workgroup> wg_partial_count: atomic<u32>;
|
|
53
|
+
var<workgroup> wg_lum: array<vec3<f32>, MULTISCATTER_MAX_SUBGROUP_PARTIALS>;
|
|
54
|
+
var<workgroup> wg_fms: array<vec3<f32>, MULTISCATTER_MAX_SUBGROUP_PARTIALS>;
|
|
55
|
+
|
|
56
|
+
@compute @workgroup_size(${MULTISCATTER_LUT_DIRECTION_COUNT}, 1, 1)
|
|
57
|
+
fn main(
|
|
58
|
+
@builtin(workgroup_id) workgroup_id: vec3<u32>,
|
|
59
|
+
@builtin(local_invocation_index) thread_index: u32,
|
|
60
|
+
) {
|
|
61
|
+
|
|
62
|
+
if (thread_index == 0u) {
|
|
63
|
+
atomicStore(&wg_partial_count, 0u);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Every thread is here together anyway, so the counter's initialisation costs nothing
|
|
67
|
+
// beyond the barrier itself. WGSL does not promise workgroup variables start zeroed.
|
|
68
|
+
workgroupBarrier();
|
|
69
|
+
|
|
70
|
+
// one workgroup per texel; the dispatch is sized from the texture, so this is in range
|
|
71
|
+
let texel = workgroup_id.xy;
|
|
72
|
+
|
|
73
|
+
let lut_size = vec2<f32>(textureDimensions(tSkyLutMultiscatterOut));
|
|
74
|
+
|
|
75
|
+
// The point of each range this texel stands for: texel 0 carries the bottom and the last
|
|
76
|
+
// texel the top, which is what lets a lookup at either end read a value computed there
|
|
77
|
+
// rather than one from half a texel inside. sky_lut_uv is the other half of this.
|
|
78
|
+
let unit = sky_lut_texel_to_unit(vec2<f32>(texel), lut_size);
|
|
79
|
+
|
|
80
|
+
let sunCosTheta = 2.0*unit.x - 1.0;
|
|
81
|
+
let sunTheta = safe_acos(sunCosTheta);
|
|
82
|
+
|
|
83
|
+
let height = ATMOSPHERE_HEIGHT*unit.y;
|
|
84
|
+
|
|
85
|
+
let pos = vec3(0.0, height, 0.0);
|
|
86
|
+
let sunDir = normalize(vec3(0.0, sunCosTheta, -sin(sunTheta)));
|
|
87
|
+
|
|
88
|
+
// pos on the +y axis and sunDir with a zero x component are exactly the preconditions
|
|
89
|
+
// multiscatter_sample_direction's half-azimuth sample set needs
|
|
90
|
+
let rayDir = multiscatter_sample_direction(thread_index);
|
|
91
|
+
|
|
92
|
+
var lum:vec3<f32>;
|
|
93
|
+
var f_ms:vec3<f32>;
|
|
94
|
+
|
|
95
|
+
get_multiscatter_values(pos, sunDir, rayDir, &lum, &f_ms);
|
|
96
|
+
|
|
97
|
+
// Uniform control flow up to here, so every one of the workgroup's threads is an active
|
|
98
|
+
// lane and the subgroup sum covers all of them.
|
|
99
|
+
let lum_subgroup = subgroupAdd(lum);
|
|
100
|
+
let fms_subgroup = subgroupAdd(f_ms);
|
|
101
|
+
|
|
102
|
+
// subgroupElect picks exactly one active invocation per subgroup, and the slot it claims
|
|
103
|
+
// is whichever the counter hands out. Deriving the slot from local_invocation_index /
|
|
104
|
+
// subgroup_size instead would assume invocations are packed into subgroups in contiguous
|
|
105
|
+
// index order, which WGSL leaves unspecified: a mapping that is not contiguous blocks
|
|
106
|
+
// would collide two subgroups onto one slot and silently drop a partial sum. Which slot
|
|
107
|
+
// a subgroup lands in does not matter, only that it gets its own.
|
|
108
|
+
//
|
|
109
|
+
// Every lane holds the same subgroup sum, so letting them all store it would be a data
|
|
110
|
+
// race on one address even though the values agree.
|
|
111
|
+
if (subgroupElect()) {
|
|
112
|
+
let slot = atomicAdd(&wg_partial_count, 1u);
|
|
113
|
+
|
|
114
|
+
wg_lum[slot] = lum_subgroup;
|
|
115
|
+
wg_fms[slot] = fms_subgroup;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
workgroupBarrier();
|
|
119
|
+
|
|
120
|
+
if (thread_index != 0u) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// WGSL pins the subgroup size to a power of two in [4, 128], so the workgroup cannot hold
|
|
125
|
+
// more subgroups than the partials array has room for. The clamp keeps a driver that
|
|
126
|
+
// broke that promise reading initialised slots rather than garbage.
|
|
127
|
+
let partial_count = min(atomicLoad(&wg_partial_count), MULTISCATTER_MAX_SUBGROUP_PARTIALS);
|
|
128
|
+
|
|
129
|
+
var lum_total = vec3(0.0);
|
|
130
|
+
var fms_total = vec3(0.0);
|
|
131
|
+
|
|
132
|
+
for (var i = 0u; i < partial_count; i++) {
|
|
133
|
+
lum_total += wg_lum[i];
|
|
134
|
+
fms_total += wg_fms[i];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The directions carry equal solid angle, so the mean over them is the spherical average
|
|
138
|
+
// the paper's uniform phase reduces to.
|
|
139
|
+
let inv_samples = 1.0 / f32(MULTISCATTER_DIRECTION_COUNT);
|
|
140
|
+
|
|
141
|
+
lum_total *= inv_samples;
|
|
142
|
+
fms_total *= inv_samples;
|
|
143
|
+
|
|
144
|
+
// Equation 10 from the paper.
|
|
145
|
+
let psi = lum_total / (1.0 - fms_total);
|
|
146
|
+
|
|
147
|
+
textureStore(tSkyLutMultiscatterOut, texel, vec4(psi, 1.0));
|
|
148
|
+
}
|
|
149
|
+
`, [
|
|
150
|
+
chunk_safe_acos,
|
|
151
|
+
ATMOSPHERE_HEIGHT_DECLARATION,
|
|
152
|
+
chunk_multiscatter_sample_direction,
|
|
153
|
+
chunk_sky_lut_texel_to_unit,
|
|
154
|
+
chunk_get_multiscatter_values,
|
|
155
|
+
]
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
body.addExtension(WebGPUExtensionType.Subgroups);
|
|
159
|
+
|
|
160
|
+
export const shader_multiscatter_lut = ComputeShader.from({
|
|
161
|
+
label: "Sky / multi-scatter LUT",
|
|
162
|
+
body,
|
|
163
|
+
resources,
|
|
164
|
+
group_size: [MULTISCATTER_LUT_DIRECTION_COUNT, 1, 1],
|
|
165
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_sky_irradiance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_sky_irradiance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js"],"names":[],"mappings":"AA4MA,oDAWG;4BA1LyB,0BAA0B"}
|