Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1import bevy_render::view::View;
2import bevy_pbr::prepass::bindings::PreviousViewUniforms;
3import package::scene::sampling::{LightSample, NULL_LIGHT_ID};
5enable wgpu_ray_query;
7@group(1) @binding(0) var view_output: texture_storage_2d<rgba16float, read_write>;
8@group(1) @binding(1) var<storage, read_write> light_tile_samples: array<LightSample>;
9@group(1) @binding(2) var<storage, read_write> light_tile_resolved_samples: array<ResolvedLightSamplePacked>;
10@group(1) @binding(3) var gbuffer: texture_2d<u32>;
11@group(1) @binding(4) var depth_buffer: texture_depth_2d;
12@if(MOTION_VECTORS_READ_WRITE)
13@group(1) @binding(5) var motion_vectors: texture_storage_2d<rg16float, read_write>;
14@if(!MOTION_VECTORS_READ_WRITE)
15@group(1) @binding(5) var motion_vectors: texture_2d<f32>;
16@group(1) @binding(6) var<uniform> view: View;
17@group(1) @binding(7) var<uniform> previous_view: PreviousViewUniforms;
18@group(1) @binding(8) var<storage, read_write> world_cache: WorldCache;
19@group(1) @binding(9) var<uniform> constants: SolariLightingSettings;
21@if(RESTIR) {
22@group(1) @binding(10) var previous_gbuffer: texture_2d<u32>;
23@group(1) @binding(11) var previous_depth_buffer: texture_depth_2d;
24@group(1) @binding(12) var<storage, read_write> reservoirs_a: array<Reservoir>;
25@group(1) @binding(13) var<storage, read_write> reservoirs_b: array<Reservoir>;
28@if(DLSS_RR_GUIDE_BUFFERS) {
29@group(2) @binding(0) var diffuse_albedo: texture_storage_2d<rgba8unorm, write>;
30@group(2) @binding(1) var specular_albedo: texture_storage_2d<rgba8unorm, write>;
31@group(2) @binding(2) var normal_roughness: texture_storage_2d<rgba16float, write>;
32@group(2) @binding(3) var dlss_rr_depth: texture_storage_2d<r32float, write>;
33@group(2) @binding(4) var specular_motion_vectors: texture_storage_2d<rg16float, write>;
36fn load_motion_vector(pixel_id: vec2<u32>) -> vec2<f32> {
37 @if(MOTION_VECTORS_READ_WRITE)
38 return textureLoad(motion_vectors, pixel_id).xy;
39 @if(!MOTION_VECTORS_READ_WRITE)
40 return textureLoad(motion_vectors, pixel_id, 0).xy;
43/// User-configurable settings from the `SolariLighting` component, plus per-frame
44/// state. Field order and types must match `SolariLightingUniforms` in `prepare.rs`.
45struct SolariLightingSettings {
46 confidence_weight_cap: f32,
47 primary_di_samples: u32,
48 secondary_di_samples: u32,
49 max_bounces: u32,
50 world_cache_max_temporal_samples: f32,
51 world_cache_direct_light_sample_count: u32,
52 world_cache_max_gi_ray_distance: f32,
53 world_cache_cell_updates_soft_target: u32,
54 world_cache_position_base_cell_size: f32,
55 world_cache_position_lod_scale: f32,
56 frame_rng: u32,
57 reset: u32,
60/// Don't adjust the size of this struct without also adjusting `prepare::RESOLVED_LIGHT_SAMPLE_STRUCT_SIZE`.
61struct ResolvedLightSamplePacked {
62 world_position_x: f32,
63 world_position_y: f32,
64 world_position_z: f32,
65 world_normal: u32,
66 radiance: u32,
67 inverse_pdf: f32,
70/// Don't adjust the size of this struct without also adjusting `prepare::RESERVOIR_STRUCT_SIZE`.
71struct Reservoir {
72 sample_point_world_position: vec3<f32>,
73 unbiased_contribution_weight: f32,
74 radiance: vec3<f32>,
75 confidence_weight: f32,
76 sample_point_world_normal: vec2<f32>,
77 light_sample: LightSample,
80fn empty_reservoir() -> Reservoir {
81 return Reservoir(
82 vec3(0.0),
83 0.0,
84 vec3(0.0),
85 0.0,
86 vec2(0.0),
87 LightSample(NULL_LIGHT_ID, 0u),
88 );
91struct WorldCacheGeometryData {
92 world_position: vec3<f32>,
93 padding_a: u32,
94 world_normal: vec3<f32>,
95 padding_b: u32,
98/// Keep in sync with the packed world-cache layout constants in `prepare.rs`.
99struct WorldCache {
100 checksums: array<atomic<u32>, constants::WORLD_CACHE_SIZE>,
101 @if(WORLD_CACHE_NON_ATOMIC_LIFE_BUFFER)
102 life: array<u32, constants::WORLD_CACHE_SIZE>,
103 @if(!WORLD_CACHE_NON_ATOMIC_LIFE_BUFFER)
104 life: array<atomic<u32>, constants::WORLD_CACHE_SIZE>,
105 radiance: array<vec4<f32>, constants::WORLD_CACHE_SIZE>,
106 geometry_data: array<WorldCacheGeometryData, constants::WORLD_CACHE_SIZE>,
107 luminance_deltas: array<f32, constants::WORLD_CACHE_SIZE>,
108 active_cells_new_radiance: array<vec3<f32>, constants::WORLD_CACHE_SIZE>,
109 a: array<u32, constants::WORLD_CACHE_SIZE>,
110 b: array<u32, 1024u>,
111 active_cell_indices: array<u32, constants::WORLD_CACHE_SIZE>,
112 active_cells_count: u32,
Contents