@woosh/meep-engine 3.14.6 → 3.15.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/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +48 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +246 -3
- package/src/shade/RENDERER_CONTRACT.md +584 -580
- package/src/shade/playground/avboit/README.md +117 -0
- package/src/shade/playground/avboit/index.html +215 -0
- package/src/shade/playground/avboit/main.d.ts +2 -0
- package/src/shade/playground/avboit/main.d.ts.map +1 -0
- package/src/shade/playground/avboit/main.js +875 -0
- package/src/shade/renderer/Renderer.d.ts +16 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +29 -28
- package/src/shade/renderer/ShadeTransparencyMode.d.ts +13 -0
- package/src/shade/renderer/ShadeTransparencyMode.d.ts.map +1 -0
- package/src/shade/renderer/ShadeTransparencyMode.js +30 -0
- package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.d.ts +9 -0
- package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.js +26 -0
- package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts +7 -2
- 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 +12 -1
- package/src/shade/renderer/rasterize/expand/shader_filter_triangle_by_material_side.js +1 -1
- package/src/shade/renderer/rasterize/forward/FORWARD_VERTEX_SHADER_STRUCT.d.ts +3 -0
- package/src/shade/renderer/rasterize/forward/FORWARD_VERTEX_SHADER_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/FORWARD_VERTEX_SHADER_STRUCT.js +4 -4
- package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.d.ts +3 -0
- package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.js +17 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_forward_shade_standard_fragment_brick4.d.ts +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_brick4.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_forward_shade_standard_fragment_brick4.js +16 -16
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_forward_shade_standard_fragment_ibl.d.ts +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_ibl.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_forward_shade_standard_fragment_ibl.js +17 -17
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_material_side_should_draw.d.ts +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_material_side_should_draw.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/chunk_material_side_should_draw.js +2 -2
- package/src/shade/renderer/rasterize/forward/vertex_shader_chunk.d.ts +3 -0
- package/src/shade/renderer/rasterize/forward/vertex_shader_chunk.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/{native/oit → forward}/vertex_shader_chunk.js +4 -4
- package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.d.ts +27 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.js +27 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.d.ts +107 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.js +120 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_LEDGER.md +463 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_PLAN_2026_09_03.md +509 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_WARP_STRUCT.d.ts +15 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_WARP_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/AVBOIT_WARP_STRUCT.js +33 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_build_depth_curve.d.ts +20 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_build_depth_curve.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_build_depth_curve.js +38 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts +38 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +130 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_spec_support.d.ts +37 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_spec_support.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_spec_support.js +73 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_counts_to_extinction.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_counts_to_extinction.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_counts_to_extinction.js +17 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_dilate_word.d.ts +11 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_dilate_word.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_dilate_word.js +18 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_counts.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_counts.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_counts.js +17 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.js +17 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.d.ts +15 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.js +25 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts +17 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.js +35 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_range.d.ts +11 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_range.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_range.js +21 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_word_mask.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_word_mask.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_word_mask.js +26 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_overflows.d.ts +11 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_overflows.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_overflows.js +22 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_pack_counts.d.ts +10 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_pack_counts.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_pack_counts.js +21 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.d.ts +10 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.js +32 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmission_tint.d.ts +20 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmission_tint.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmission_tint.js +27 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmittance_to_extinction.d.ts +10 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmittance_to_extinction.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_transmittance_to_extinction.js +18 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unpack_counts.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unpack_counts.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unpack_counts.js +21 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_physical.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_physical.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_physical.js +23 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_virtual.d.ts +13 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_virtual.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_view_depth_to_virtual.js +27 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp.d.ts +22 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp.js +38 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts +117 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +935 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_build_warp.d.ts +8 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_build_warp.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_build_warp.js +135 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.d.ts +3 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.js +101 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.d.ts +3 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.js +96 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_integrate.d.ts +3 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_integrate.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_integrate.js +83 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_occupancy.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_occupancy.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_occupancy.js +119 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_resolve.d.ts +3 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_resolve.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_resolve.js +81 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts +15 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +237 -0
- package/src/shade/renderer/rasterize/native/material_draw_indirect.d.ts +22 -0
- package/src/shade/renderer/rasterize/native/material_draw_indirect.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/material_draw_indirect.js +69 -0
- package/src/shade/renderer/rasterize/native/oit/graph_rasterize_meshes_transparent_oit.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/graph_rasterize_meshes_transparent_oit.js +665 -722
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +3 -3
- package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments.js +4 -4
- package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.js +4 -4
- package/src/shade/renderer/rasterize/native/oit/FORWARD_VERTEX_SHADER_STRUCT.d.ts +0 -3
- package/src/shade/renderer/rasterize/native/oit/FORWARD_VERTEX_SHADER_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/rasterize/native/oit/SHADING_SCENE_RESOURCE_GROUP.d.ts +0 -3
- package/src/shade/renderer/rasterize/native/oit/SHADING_SCENE_RESOURCE_GROUP.d.ts.map +0 -1
- package/src/shade/renderer/rasterize/native/oit/SHADING_SCENE_RESOURCE_GROUP.js +0 -17
- package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_brick4.d.ts.map +0 -1
- package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_ibl.d.ts.map +0 -1
- package/src/shade/renderer/rasterize/native/oit/chunk_material_side_should_draw.d.ts.map +0 -1
- package/src/shade/renderer/rasterize/native/oit/vertex_shader_chunk.d.ts +0 -3
- package/src/shade/renderer/rasterize/native/oit/vertex_shader_chunk.d.ts.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fragment stage of the AVBOIT draw pass, shared verbatim by the IBL and Brick4 pipelines
|
|
3
|
+
* (`shader_avboit_draw_ibl`, `shader_avboit_draw_brick4`), which differ only in which
|
|
4
|
+
* `forward_shade_standard_fragment` they link and in one storage buffer in the view group. Same
|
|
5
|
+
* arrangement as the two MBOIT resolve shaders, with the body held in one place.
|
|
6
|
+
*
|
|
7
|
+
* Per fragment (plan §3.8): full forward shading and the inline volumetric composite exactly as the
|
|
8
|
+
* MBOIT resolve does them, then the transmittance of everything in front from the integral texture,
|
|
9
|
+
* and three additive outputs:
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* color += shaded × coverage × T premultiplied, as MBOIT
|
|
13
|
+
* norm += (1 - T_self) × T per channel — the normalization denominator
|
|
14
|
+
* extinction += -log(T_self) per channel — the total, resolved to exp(-Σ)
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* `T_self = (1 - coverage) × tint` is the same self-transmittance the splat recorded for this
|
|
18
|
+
* surface, through the same chunk, which is what keeps the volume and the accumulators consistent.
|
|
19
|
+
*
|
|
20
|
+
* The transmittance is sampled *before* shading, and a fragment the volume already calls extinct
|
|
21
|
+
* (`T ≤ 1/256` in every channel) is discarded without being shaded — the per-fragment form of the
|
|
22
|
+
* deck's zero-transmittance early-out, without its depth-buffer rewrite. The bound on what that
|
|
23
|
+
* changes is in `AVBOIT_EXTINCT_TRANSMITTANCE`.
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
export const AVBOIT_DRAW_FRAGMENT_BODY: string;
|
|
28
|
+
/**
|
|
29
|
+
* Dependencies of {@link AVBOIT_DRAW_FRAGMENT_BODY} other than the shading chunk each pipeline picks.
|
|
30
|
+
* @type {CodeChunk[]}
|
|
31
|
+
*/
|
|
32
|
+
export const AVBOIT_DRAW_FRAGMENT_DEPENDENCIES: CodeChunk[];
|
|
33
|
+
/**
|
|
34
|
+
* The three additive `rgba16float` targets, in `AVBOITDrawOutput` order.
|
|
35
|
+
* @type {GPUColorTargetState[]}
|
|
36
|
+
*/
|
|
37
|
+
export const AVBOIT_DRAW_TARGETS: GPUColorTargetState[];
|
|
38
|
+
//# sourceMappingURL=avboit_draw_fragment_body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avboit_draw_fragment_body.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wCAFU,MAAM,CA8DV;AAEN;;;GAGG;AACH,gDAFU,WAAW,CASnB;AAEF;;;GAGG;AACH,kCAFU,qBAAqB,CAiB3B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { chunk_sample_volumetrics } from "../../../deferred/chunk_sample_volumetrics.js";
|
|
2
|
+
import { chunk_get_view_space_depth } from "../../../shader/chunk/depth/chunk_get_view_space_depth.js";
|
|
3
|
+
import { chunk_unjitter_uv } from "../../../shader/chunk/texture/chunk_unjitter_uv.js";
|
|
4
|
+
import { FORWARD_VERTEX_SHADER_STRUCT } from "../../forward/FORWARD_VERTEX_SHADER_STRUCT.js";
|
|
5
|
+
import { OIT_COVERAGE_MAX } from "../oit/OIT_CONSTANTS.js";
|
|
6
|
+
import { AVBOIT_EXTINCT_TRANSMITTANCE } from "./AVBOIT_CONSTANTS.js";
|
|
7
|
+
import { chunk_avboit_sample_transmittance } from "./chunk_avboit_sample_transmittance.js";
|
|
8
|
+
import { chunk_avboit_transmission_tint } from "./chunk_avboit_transmission_tint.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The fragment stage of the AVBOIT draw pass, shared verbatim by the IBL and Brick4 pipelines
|
|
12
|
+
* (`shader_avboit_draw_ibl`, `shader_avboit_draw_brick4`), which differ only in which
|
|
13
|
+
* `forward_shade_standard_fragment` they link and in one storage buffer in the view group. Same
|
|
14
|
+
* arrangement as the two MBOIT resolve shaders, with the body held in one place.
|
|
15
|
+
*
|
|
16
|
+
* Per fragment (plan §3.8): full forward shading and the inline volumetric composite exactly as the
|
|
17
|
+
* MBOIT resolve does them, then the transmittance of everything in front from the integral texture,
|
|
18
|
+
* and three additive outputs:
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* color += shaded × coverage × T premultiplied, as MBOIT
|
|
22
|
+
* norm += (1 - T_self) × T per channel — the normalization denominator
|
|
23
|
+
* extinction += -log(T_self) per channel — the total, resolved to exp(-Σ)
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* `T_self = (1 - coverage) × tint` is the same self-transmittance the splat recorded for this
|
|
27
|
+
* surface, through the same chunk, which is what keeps the volume and the accumulators consistent.
|
|
28
|
+
*
|
|
29
|
+
* The transmittance is sampled *before* shading, and a fragment the volume already calls extinct
|
|
30
|
+
* (`T ≤ 1/256` in every channel) is discarded without being shaded — the per-fragment form of the
|
|
31
|
+
* deck's zero-transmittance early-out, without its depth-buffer rewrite. The bound on what that
|
|
32
|
+
* changes is in `AVBOIT_EXTINCT_TRANSMITTANCE`.
|
|
33
|
+
*
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
export const AVBOIT_DRAW_FRAGMENT_BODY =
|
|
37
|
+
//language=WGSL
|
|
38
|
+
`
|
|
39
|
+
struct AVBOITDrawOutput {
|
|
40
|
+
@location(0) color : vec4<f32>,
|
|
41
|
+
@location(1) norm : vec4<f32>,
|
|
42
|
+
@location(2) extinction : vec4<f32>,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@fragment
|
|
46
|
+
fn main(
|
|
47
|
+
@builtin(front_facing) front_facing : bool,
|
|
48
|
+
vert: ${FORWARD_VERTEX_SHADER_STRUCT.wgsl_ref},
|
|
49
|
+
) -> AVBOITDrawOutput {
|
|
50
|
+
|
|
51
|
+
// need to unjitter UV to account for TAA
|
|
52
|
+
var vert_adjusted = vert;
|
|
53
|
+
vert_adjusted.uv = unjitter_uv(vert.uv, view.jitter);
|
|
54
|
+
|
|
55
|
+
// linear view depth (vert.position is @builtin(position); .z is device depth) and screen uv,
|
|
56
|
+
// for the volume lookup and the fog composite alike
|
|
57
|
+
let frag_view_depth = get_view_space_depth(vert_adjusted.position.z, camera);
|
|
58
|
+
let frag_screen_uv = vert_adjusted.position.xy / vec2<f32>(f32(view.width), f32(view.height));
|
|
59
|
+
|
|
60
|
+
let transmittance = avboit_sample_transmittance(&warp, tIntegral, sLinear, frag_screen_uv, frag_view_depth);
|
|
61
|
+
|
|
62
|
+
if (all(transmittance <= vec3<f32>(${AVBOIT_EXTINCT_TRANSMITTANCE}))) {
|
|
63
|
+
// nothing this fragment contributes survives what is in front of it; skip the shading
|
|
64
|
+
discard;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let shaded = forward_shade_standard_fragment(vert_adjusted, front_facing);
|
|
68
|
+
|
|
69
|
+
// composite volumetric fog between the camera and this fragment
|
|
70
|
+
let volumetrics = sample_volumetrics(frag_view_depth, frag_screen_uv, vert_adjusted.position.xy);
|
|
71
|
+
|
|
72
|
+
let color = shaded.rgb * volumetrics.w + volumetrics.xyz;
|
|
73
|
+
|
|
74
|
+
// full opacity would be zero transmittance, whose logarithm breaks the accumulators
|
|
75
|
+
let coverage = min(shaded.a, ${OIT_COVERAGE_MAX});
|
|
76
|
+
|
|
77
|
+
// the same tint the splat recorded, from the same inputs
|
|
78
|
+
var tint = vec3<f32>(1.0);
|
|
79
|
+
let f_transmission = material_info.transmission_factor;
|
|
80
|
+
if (f_transmission > 0.0) {
|
|
81
|
+
let t_diffuse = textureSample(texture_diffuse, texture_diffuse_sampler, vert_adjusted.uv);
|
|
82
|
+
let base_color = (t_diffuse.rgb / max(t_diffuse.a, 1e-7)) * vert.color;
|
|
83
|
+
tint = avboit_transmission_tint(base_color, f_transmission * f32(warp.tint_from_base_color));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let self_transmittance = (1.0 - coverage) * tint;
|
|
87
|
+
|
|
88
|
+
var out: AVBOITDrawOutput;
|
|
89
|
+
|
|
90
|
+
out.color = vec4<f32>(color * coverage * transmittance, 0.0);
|
|
91
|
+
out.norm = vec4<f32>((1.0 - self_transmittance) * transmittance, 0.0);
|
|
92
|
+
out.extinction = vec4<f32>(-log(self_transmittance), 0.0);
|
|
93
|
+
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Dependencies of {@link AVBOIT_DRAW_FRAGMENT_BODY} other than the shading chunk each pipeline picks.
|
|
100
|
+
* @type {CodeChunk[]}
|
|
101
|
+
*/
|
|
102
|
+
export const AVBOIT_DRAW_FRAGMENT_DEPENDENCIES = [
|
|
103
|
+
FORWARD_VERTEX_SHADER_STRUCT.declaration_chunk,
|
|
104
|
+
chunk_unjitter_uv,
|
|
105
|
+
chunk_get_view_space_depth,
|
|
106
|
+
chunk_sample_volumetrics,
|
|
107
|
+
chunk_avboit_sample_transmittance,
|
|
108
|
+
chunk_avboit_transmission_tint,
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The three additive `rgba16float` targets, in `AVBOITDrawOutput` order.
|
|
113
|
+
* @type {GPUColorTargetState[]}
|
|
114
|
+
*/
|
|
115
|
+
export const AVBOIT_DRAW_TARGETS = ["color", "norm", "extinction"].map(label => ({
|
|
116
|
+
label,
|
|
117
|
+
format: "rgba16float",
|
|
118
|
+
blend: {
|
|
119
|
+
color: {
|
|
120
|
+
operation: "add",
|
|
121
|
+
srcFactor: "one",
|
|
122
|
+
dstFactor: "one",
|
|
123
|
+
},
|
|
124
|
+
alpha: {
|
|
125
|
+
operation: "add",
|
|
126
|
+
srcFactor: "one",
|
|
127
|
+
dstFactor: "one",
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only helpers shared by the AVBOIT emulator specs: a warp binding built by hand the way
|
|
3
|
+
* `shader_avboit_build_warp` builds it on the GPU, and the depth that lands on a given finest-level
|
|
4
|
+
* virtual slice, so a spec can reason in slices and still feed the real curve.
|
|
5
|
+
*
|
|
6
|
+
* Not a spec, and not shipped: nothing outside `*.spec.js` imports it.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The emulator hands a `u32` with its top bit set back as a negative JS number; compare unsigned.
|
|
10
|
+
* @param {number} x
|
|
11
|
+
* @returns {number}
|
|
12
|
+
*/
|
|
13
|
+
export function u32(x: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* @param {number[]} occupancy one flag per virtual slice; its length is the active `V`
|
|
16
|
+
* @param {object} [overrides] header fields to override
|
|
17
|
+
* @returns {object} a warp binding as the shaders see it
|
|
18
|
+
*/
|
|
19
|
+
export function make_warp(occupancy: number[], overrides?: object): object;
|
|
20
|
+
/**
|
|
21
|
+
* The view depth whose finest-level slice coordinate is `slice`, inverting the pure-log curve
|
|
22
|
+
* `avboit_build_depth_curve` builds: `slice = log2(depth · B + O) · scale`.
|
|
23
|
+
*
|
|
24
|
+
* @param {ArrayLike<number>} curve cluster parameters
|
|
25
|
+
* @param {number} slice in `[0, AVBOIT_VIRTUAL_SLICES_MAX]`
|
|
26
|
+
* @returns {number}
|
|
27
|
+
*/
|
|
28
|
+
export function depth_for_finest_slice(curve: ArrayLike<number>, slice: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* The view depth whose coordinate at the active resolution `V` is `virtual_slice`.
|
|
31
|
+
*
|
|
32
|
+
* @param {object} warp
|
|
33
|
+
* @param {number} virtual_slice in `[0, V]`
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export function depth_for_virtual_slice(warp: object, virtual_slice: number): number;
|
|
37
|
+
//# sourceMappingURL=avboit_spec_support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avboit_spec_support.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/avboit_spec_support.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH;;;;GAIG;AACH,uBAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,qCAJW,MAAM,EAAE,cACR,MAAM,GACJ,MAAM,CAsBlB;AAED;;;;;;;GAOG;AACH,8CAJW,UAAU,MAAM,CAAC,SACjB,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,8CAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAOlB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AVBOIT_PHYSICAL_SLICES, AVBOIT_VIRTUAL_SLICES_MAX } from "./AVBOIT_CONSTANTS.js";
|
|
2
|
+
import { avboit_build_depth_curve } from "./avboit_build_depth_curve.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Test-only helpers shared by the AVBOIT emulator specs: a warp binding built by hand the way
|
|
6
|
+
* `shader_avboit_build_warp` builds it on the GPU, and the depth that lands on a given finest-level
|
|
7
|
+
* virtual slice, so a spec can reason in slices and still feed the real curve.
|
|
8
|
+
*
|
|
9
|
+
* Not a spec, and not shipped: nothing outside `*.spec.js` imports it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The emulator hands a `u32` with its top bit set back as a negative JS number; compare unsigned.
|
|
14
|
+
* @param {number} x
|
|
15
|
+
* @returns {number}
|
|
16
|
+
*/
|
|
17
|
+
export function u32(x) {
|
|
18
|
+
return x >>> 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {number[]} occupancy one flag per virtual slice; its length is the active `V`
|
|
23
|
+
* @param {object} [overrides] header fields to override
|
|
24
|
+
* @returns {object} a warp binding as the shaders see it
|
|
25
|
+
*/
|
|
26
|
+
export function make_warp(occupancy, overrides = {}) {
|
|
27
|
+
const lut = new Uint32Array(occupancy.length + 1);
|
|
28
|
+
let prefix = 0;
|
|
29
|
+
for (let v = 0; v < occupancy.length; v++) {
|
|
30
|
+
lut[v] = (prefix << 1) | occupancy[v];
|
|
31
|
+
prefix += occupancy[v];
|
|
32
|
+
}
|
|
33
|
+
lut[occupancy.length] = prefix << 1;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
virtual_count: occupancy.length,
|
|
37
|
+
occupied_count: prefix,
|
|
38
|
+
physical_count: AVBOIT_PHYSICAL_SLICES,
|
|
39
|
+
voxel_width: 1,
|
|
40
|
+
voxel_height: 1,
|
|
41
|
+
tint_from_base_color: 0,
|
|
42
|
+
cluster_parameters: avboit_build_depth_curve(0.1, 200),
|
|
43
|
+
lut,
|
|
44
|
+
...overrides,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The view depth whose finest-level slice coordinate is `slice`, inverting the pure-log curve
|
|
50
|
+
* `avboit_build_depth_curve` builds: `slice = log2(depth · B + O) · scale`.
|
|
51
|
+
*
|
|
52
|
+
* @param {ArrayLike<number>} curve cluster parameters
|
|
53
|
+
* @param {number} slice in `[0, AVBOIT_VIRTUAL_SLICES_MAX]`
|
|
54
|
+
* @returns {number}
|
|
55
|
+
*/
|
|
56
|
+
export function depth_for_finest_slice(curve, slice) {
|
|
57
|
+
const [B, O, scale] = curve;
|
|
58
|
+
return (Math.pow(2, slice / scale) - O) / B;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The view depth whose coordinate at the active resolution `V` is `virtual_slice`.
|
|
63
|
+
*
|
|
64
|
+
* @param {object} warp
|
|
65
|
+
* @param {number} virtual_slice in `[0, V]`
|
|
66
|
+
* @returns {number}
|
|
67
|
+
*/
|
|
68
|
+
export function depth_for_virtual_slice(warp, virtual_slice) {
|
|
69
|
+
return depth_for_finest_slice(
|
|
70
|
+
warp.cluster_parameters,
|
|
71
|
+
virtual_slice * AVBOIT_VIRTUAL_SLICES_MAX / warp.virtual_count
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accumulated counts back to normalized extinction. Not clamped: a field that summed past 255 reads
|
|
3
|
+
* above 1.0 here and saturates in the integration, which is where the running value is kept.
|
|
4
|
+
*
|
|
5
|
+
* @type {CodeChunk}
|
|
6
|
+
*/
|
|
7
|
+
export const chunk_avboit_counts_to_extinction: CodeChunk;
|
|
8
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
9
|
+
//# sourceMappingURL=chunk_avboit_counts_to_extinction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_counts_to_extinction.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_counts_to_extinction.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,gDAFU,SAAS,CASjB;0BAhBwB,uCAAuC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { AVBOIT_EXTINCTION_SCALE } from "./AVBOIT_CONSTANTS.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Accumulated counts back to normalized extinction. Not clamped: a field that summed past 255 reads
|
|
6
|
+
* above 1.0 here and saturates in the integration, which is where the running value is kept.
|
|
7
|
+
*
|
|
8
|
+
* @type {CodeChunk}
|
|
9
|
+
*/
|
|
10
|
+
export const chunk_avboit_counts_to_extinction = CodeChunk.from(
|
|
11
|
+
//language=WGSL
|
|
12
|
+
`
|
|
13
|
+
fn avboit_counts_to_extinction(counts: vec3<u32>) -> vec3<f32> {
|
|
14
|
+
return vec3<f32>(counts) / ${AVBOIT_EXTINCTION_SCALE}.0;
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One occupancy word dilated by one slice each side. `below` carries bit 31 of the previous word
|
|
3
|
+
* into bit 0, `above` carries bit 0 of the next word already shifted up to bit 31, so runs grow
|
|
4
|
+
* across word boundaries too. The margin is what keeps a fragment on the edge of a meshlet's bounds
|
|
5
|
+
* from linear-splatting into a neighbouring run.
|
|
6
|
+
*
|
|
7
|
+
* @type {CodeChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const chunk_avboit_dilate_word: CodeChunk;
|
|
10
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
11
|
+
//# sourceMappingURL=chunk_avboit_dilate_word.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_dilate_word.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_dilate_word.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,uCAFU,SAAS,CASjB;0BAjBwB,uCAAuC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One occupancy word dilated by one slice each side. `below` carries bit 31 of the previous word
|
|
5
|
+
* into bit 0, `above` carries bit 0 of the next word already shifted up to bit 31, so runs grow
|
|
6
|
+
* across word boundaries too. The margin is what keeps a fragment on the edge of a meshlet's bounds
|
|
7
|
+
* from linear-splatting into a neighbouring run.
|
|
8
|
+
*
|
|
9
|
+
* @type {CodeChunk}
|
|
10
|
+
*/
|
|
11
|
+
export const chunk_avboit_dilate_word = CodeChunk.from(
|
|
12
|
+
//language=WGSL
|
|
13
|
+
`
|
|
14
|
+
fn avboit_dilate_word(x: u32, below: u32, above: u32) -> u32 {
|
|
15
|
+
return x | (x << 1u) | below | (x >> 1u) | above;
|
|
16
|
+
}
|
|
17
|
+
`
|
|
18
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized extinction to the 8-bit counts the splat adds: rounded to nearest, so an event below
|
|
3
|
+
* half a count registers nothing — the finest single-event occlusion the volume holds is about 2 %.
|
|
4
|
+
*
|
|
5
|
+
* @type {CodeChunk}
|
|
6
|
+
*/
|
|
7
|
+
export const chunk_avboit_extinction_to_counts: CodeChunk;
|
|
8
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
9
|
+
//# sourceMappingURL=chunk_avboit_extinction_to_counts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_extinction_to_counts.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_counts.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,gDAFU,SAAS,CASjB;0BAhBwB,uCAAuC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { AVBOIT_EXTINCTION_SCALE } from "./AVBOIT_CONSTANTS.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normalized extinction to the 8-bit counts the splat adds: rounded to nearest, so an event below
|
|
6
|
+
* half a count registers nothing — the finest single-event occlusion the volume holds is about 2 %.
|
|
7
|
+
*
|
|
8
|
+
* @type {CodeChunk}
|
|
9
|
+
*/
|
|
10
|
+
export const chunk_avboit_extinction_to_counts = CodeChunk.from(
|
|
11
|
+
//language=WGSL
|
|
12
|
+
`
|
|
13
|
+
fn avboit_extinction_to_counts(extinction: vec3<f32>) -> vec3<u32> {
|
|
14
|
+
return vec3<u32>(saturate(extinction) * ${AVBOIT_EXTINCTION_SCALE}.0 + 0.5);
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
);
|
package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inverse of `avboit_transmittance_to_extinction`: `exp(-e · ln 256)` per channel, what the
|
|
3
|
+
* draw applies to a sampled integral.
|
|
4
|
+
*
|
|
5
|
+
* @type {CodeChunk}
|
|
6
|
+
*/
|
|
7
|
+
export const chunk_avboit_extinction_to_transmittance: CodeChunk;
|
|
8
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
9
|
+
//# sourceMappingURL=chunk_avboit_extinction_to_transmittance.d.ts.map
|
package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_extinction_to_transmittance.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,uDAFU,SAAS,CASjB;0BAhBwB,uCAAuC"}
|
package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_extinction_to_transmittance.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { AVBOIT_EXTINCTION_MAX } from "./AVBOIT_CONSTANTS.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The inverse of `avboit_transmittance_to_extinction`: `exp(-e · ln 256)` per channel, what the
|
|
6
|
+
* draw applies to a sampled integral.
|
|
7
|
+
*
|
|
8
|
+
* @type {CodeChunk}
|
|
9
|
+
*/
|
|
10
|
+
export const chunk_avboit_extinction_to_transmittance = CodeChunk.from(
|
|
11
|
+
//language=WGSL
|
|
12
|
+
`
|
|
13
|
+
fn avboit_extinction_to_transmittance(extinction: vec3<f32>) -> vec3<f32> {
|
|
14
|
+
return exp(-extinction * ${AVBOIT_EXTINCTION_MAX});
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Halve the slice resolution of one occupancy word: bit `j` of the 16-bit result is bit `2j` OR bit
|
|
3
|
+
* `2j + 1` of the input — the even bits compacted, OR the odd bits compacted.
|
|
4
|
+
*
|
|
5
|
+
* Both compactions come from the BVH builder's 2D Morton decode. Only its `.x` is used: for a 32-bit
|
|
6
|
+
* code that function's `.x` is the even bits compacted to 16, while its `.y` is not the odd bits (the
|
|
7
|
+
* `<< 31` that separates the odd bits works in the 16-bit variant, where the shift is 15, and cannot
|
|
8
|
+
* in 32 bits). Shifting the word right by one puts the odd bits on even positions, so the same `.x`
|
|
9
|
+
* serves both halves.
|
|
10
|
+
*
|
|
11
|
+
* @type {CodeChunk}
|
|
12
|
+
*/
|
|
13
|
+
export const chunk_avboit_fold_pairs: CodeChunk;
|
|
14
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
15
|
+
//# sourceMappingURL=chunk_avboit_fold_pairs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_fold_pairs.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,sCAFU,SAAS,CAWjB;0BAvBwB,uCAAuC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { chunk_decode32_morton2 } from "../../../shader/chunk/bvh/morton/chunk_decode32_morton2.js";
|
|
2
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Halve the slice resolution of one occupancy word: bit `j` of the 16-bit result is bit `2j` OR bit
|
|
6
|
+
* `2j + 1` of the input — the even bits compacted, OR the odd bits compacted.
|
|
7
|
+
*
|
|
8
|
+
* Both compactions come from the BVH builder's 2D Morton decode. Only its `.x` is used: for a 32-bit
|
|
9
|
+
* code that function's `.x` is the even bits compacted to 16, while its `.y` is not the odd bits (the
|
|
10
|
+
* `<< 31` that separates the odd bits works in the 16-bit variant, where the shift is 15, and cannot
|
|
11
|
+
* in 32 bits). Shifting the word right by one puts the odd bits on even positions, so the same `.x`
|
|
12
|
+
* serves both halves.
|
|
13
|
+
*
|
|
14
|
+
* @type {CodeChunk}
|
|
15
|
+
*/
|
|
16
|
+
export const chunk_avboit_fold_pairs = CodeChunk.from(
|
|
17
|
+
//language=WGSL
|
|
18
|
+
`
|
|
19
|
+
fn avboit_fold_pairs(x: u32) -> u32 {
|
|
20
|
+
return decode32_morton2(x).x | decode32_morton2(x >> 1u).x;
|
|
21
|
+
}
|
|
22
|
+
`, [
|
|
23
|
+
chunk_decode32_morton2,
|
|
24
|
+
]
|
|
25
|
+
);
|
package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The normalized depth coordinate into the integral texture for a fragment at `z_view` (plan §3.8).
|
|
3
|
+
*
|
|
4
|
+
* The sample bias is applied in *virtual* slices before the warp: inside an occupied run that is the
|
|
5
|
+
* same as biasing the physical coordinate; at the start of a run it walks into the gap before it,
|
|
6
|
+
* where the warp is flat, and the sample reads the previous run's total rather than two slices into a
|
|
7
|
+
* run that may be arbitrarily far away in depth.
|
|
8
|
+
*
|
|
9
|
+
* The integral holds `P + 1` texels, one per slice *boundary*, so physical coordinate `p` reads texel
|
|
10
|
+
* centre `(p + 0.5) / (P + 1)`: a run boundary lands exactly on a texel and the sample is the sum of
|
|
11
|
+
* the slices before it, with no share of the slice after.
|
|
12
|
+
*
|
|
13
|
+
* @type {CodeChunk}
|
|
14
|
+
*/
|
|
15
|
+
export const chunk_avboit_integral_depth_coordinate: CodeChunk;
|
|
16
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
17
|
+
//# sourceMappingURL=chunk_avboit_integral_depth_coordinate.d.ts.map
|
package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_integral_depth_coordinate.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,qDAFU,SAAS,CAgBjB;0BAlCwB,uCAAuC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { AVBOIT_SAMPLE_BIAS_SLICES } from "./AVBOIT_CONSTANTS.js";
|
|
3
|
+
import { AVBOIT_WARP_STRUCT } from "./AVBOIT_WARP_STRUCT.js";
|
|
4
|
+
import { chunk_avboit_view_depth_to_virtual } from "./chunk_avboit_view_depth_to_virtual.js";
|
|
5
|
+
import { chunk_avboit_warp } from "./chunk_avboit_warp.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The normalized depth coordinate into the integral texture for a fragment at `z_view` (plan §3.8).
|
|
9
|
+
*
|
|
10
|
+
* The sample bias is applied in *virtual* slices before the warp: inside an occupied run that is the
|
|
11
|
+
* same as biasing the physical coordinate; at the start of a run it walks into the gap before it,
|
|
12
|
+
* where the warp is flat, and the sample reads the previous run's total rather than two slices into a
|
|
13
|
+
* run that may be arbitrarily far away in depth.
|
|
14
|
+
*
|
|
15
|
+
* The integral holds `P + 1` texels, one per slice *boundary*, so physical coordinate `p` reads texel
|
|
16
|
+
* centre `(p + 0.5) / (P + 1)`: a run boundary lands exactly on a texel and the sample is the sum of
|
|
17
|
+
* the slices before it, with no share of the slice after.
|
|
18
|
+
*
|
|
19
|
+
* @type {CodeChunk}
|
|
20
|
+
*/
|
|
21
|
+
export const chunk_avboit_integral_depth_coordinate = CodeChunk.from(
|
|
22
|
+
//language=WGSL
|
|
23
|
+
`
|
|
24
|
+
fn avboit_integral_depth_coordinate(warp: ptr<storage, ${AVBOIT_WARP_STRUCT.wgsl_ref}, read>, z_view: f32) -> f32 {
|
|
25
|
+
let v = avboit_view_depth_to_virtual(warp, z_view);
|
|
26
|
+
let v_biased = max(v - ${AVBOIT_SAMPLE_BIAS_SLICES}, 0.0);
|
|
27
|
+
let p = avboit_warp(warp, v_biased);
|
|
28
|
+
return (p + 0.5) / f32((*warp).physical_count + 1u);
|
|
29
|
+
}
|
|
30
|
+
`, [
|
|
31
|
+
AVBOIT_WARP_STRUCT.declaration_chunk,
|
|
32
|
+
chunk_avboit_view_depth_to_virtual,
|
|
33
|
+
chunk_avboit_warp,
|
|
34
|
+
]
|
|
35
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inclusive range of finest-level virtual slices a depth interval covers, dilated by
|
|
3
|
+
* `AVBOIT_OCCUPANCY_DILATION` each side and clamped to the volume. Both ends are continuous slice
|
|
4
|
+
* coordinates from `cluster_depth_to_z_slice`, so a value of exactly `V_max` (the far plane) lands
|
|
5
|
+
* on the last slice.
|
|
6
|
+
*
|
|
7
|
+
* @type {CodeChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const chunk_avboit_occupancy_range: CodeChunk;
|
|
10
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
11
|
+
//# sourceMappingURL=chunk_avboit_occupancy_range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_occupancy_range.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_range.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,2CAFU,SAAS,CAWjB;0BApBwB,uCAAuC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { AVBOIT_OCCUPANCY_DILATION, AVBOIT_VIRTUAL_SLICES_MAX } from "./AVBOIT_CONSTANTS.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The inclusive range of finest-level virtual slices a depth interval covers, dilated by
|
|
6
|
+
* `AVBOIT_OCCUPANCY_DILATION` each side and clamped to the volume. Both ends are continuous slice
|
|
7
|
+
* coordinates from `cluster_depth_to_z_slice`, so a value of exactly `V_max` (the far plane) lands
|
|
8
|
+
* on the last slice.
|
|
9
|
+
*
|
|
10
|
+
* @type {CodeChunk}
|
|
11
|
+
*/
|
|
12
|
+
export const chunk_avboit_occupancy_range = CodeChunk.from(
|
|
13
|
+
//language=WGSL
|
|
14
|
+
`
|
|
15
|
+
fn avboit_occupancy_range(slice_near: f32, slice_far: f32) -> vec2<i32> {
|
|
16
|
+
let first = max(i32(floor(slice_near)) - ${AVBOIT_OCCUPANCY_DILATION}, 0);
|
|
17
|
+
let last = min(i32(floor(slice_far)) + ${AVBOIT_OCCUPANCY_DILATION}, ${AVBOIT_VIRTUAL_SLICES_MAX - 1});
|
|
18
|
+
return vec2<i32>(first, last);
|
|
19
|
+
}
|
|
20
|
+
`
|
|
21
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bits of occupancy word `word` (32 slices per word) that fall inside the inclusive slice
|
|
3
|
+
* range `[first, last]` — what the prepass ORs into that word.
|
|
4
|
+
*
|
|
5
|
+
* @type {CodeChunk}
|
|
6
|
+
*/
|
|
7
|
+
export const chunk_avboit_occupancy_word_mask: CodeChunk;
|
|
8
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
9
|
+
//# sourceMappingURL=chunk_avboit_occupancy_word_mask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_occupancy_word_mask.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_word_mask.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,+CAFU,SAAS,CAmBjB;0BAzBwB,uCAAuC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The bits of occupancy word `word` (32 slices per word) that fall inside the inclusive slice
|
|
5
|
+
* range `[first, last]` — what the prepass ORs into that word.
|
|
6
|
+
*
|
|
7
|
+
* @type {CodeChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const chunk_avboit_occupancy_word_mask = CodeChunk.from(
|
|
10
|
+
//language=WGSL
|
|
11
|
+
`
|
|
12
|
+
fn avboit_occupancy_word_mask(word: u32, first: i32, last: i32) -> u32 {
|
|
13
|
+
let base = i32(word * 32u);
|
|
14
|
+
let lo = max(first, base) - base;
|
|
15
|
+
let hi = min(last, base + 31) - base;
|
|
16
|
+
if (hi < lo) {
|
|
17
|
+
return 0u;
|
|
18
|
+
}
|
|
19
|
+
let count = u32(hi - lo + 1);
|
|
20
|
+
if (count >= 32u) {
|
|
21
|
+
return 0xFFFFFFFFu;
|
|
22
|
+
}
|
|
23
|
+
return ((1u << count) - 1u) << u32(lo);
|
|
24
|
+
}
|
|
25
|
+
`
|
|
26
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which channels an atomic add of `counts` pushed past 255, given the word's value before the add.
|
|
3
|
+
* The splat records the slice for each such channel; the integration pins the channel at full
|
|
4
|
+
* extinction from there on, since a ray that has overflowed a field is extinct anyway and the field
|
|
5
|
+
* may carry into its neighbour past that point.
|
|
6
|
+
*
|
|
7
|
+
* @type {CodeChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const chunk_avboit_overflows: CodeChunk;
|
|
10
|
+
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
11
|
+
//# sourceMappingURL=chunk_avboit_overflows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_avboit_overflows.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/avboit/chunk_avboit_overflows.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,qCAFU,SAAS,CAWjB;0BArBwB,uCAAuC"}
|