Shader Explorer
Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

restir_di.wgsl

Constants

INITIAL_SAMPLES

#
const INITIAL_SAMPLES: u32 = 32u

SPATIAL_REUSE_RADIUS_PIXELS

#
const SPATIAL_REUSE_RADIUS_PIXELS: AbstractFloat = 30.0

CONFIDENCE_WEIGHT_CAP

#
const CONFIDENCE_WEIGHT_CAP: AbstractFloat = 20.0

NULL_RESERVOIR_SAMPLE

#
const NULL_RESERVOIR_SAMPLE: u32 = 0xFFFFFFFFu

Bindings

view_output

#
@group(1)
@binding(0)
var view_output: texture_storage_2d<rgba16float, read_write>

light_tile_samples

#
@group(1)
@binding(1)
var<storage, read_write> light_tile_samples: array<LightSample>

light_tile_resolved_samples

#
@group(1)
@binding(2)
var<storage, read_write> light_tile_resolved_samples: array<ResolvedLightSamplePacked>

di_reservoirs_a

#
@group(1)
@binding(3)
var di_reservoirs_a: texture_storage_2d<rgba32uint, read_write>

di_reservoirs_b

#
@group(1)
@binding(4)
var di_reservoirs_b: texture_storage_2d<rgba32uint, read_write>

gbuffer

#
@group(1)
@binding(7)
var gbuffer: texture_2d<u32>

depth_buffer

#
@group(1)
@binding(8)
var depth_buffer: texture_depth_2d

motion_vectors

#
@group(1)
@binding(9)
var motion_vectors: texture_2d<f32>

previous_gbuffer

#
@group(1)
@binding(10)
var previous_gbuffer: texture_2d<u32>

previous_depth_buffer

#
@group(1)
@binding(11)
var previous_depth_buffer: texture_depth_2d

view

#
@group(1)
@binding(12)
var<uniform> view: View

previous_view

#
@group(1)
@binding(13)
var<uniform> previous_view: PreviousViewUniforms

Structures

PushConstants

#
struct PushConstants {
frame_index: u32 ,
reset: u32 ,
}

Reservoir

#
struct Reservoir {
sample: LightSample ,
confidence_weight: f32 ,
unbiased_contribution_weight: f32 ,
}

ReservoirMergeResult

#
struct ReservoirMergeResult {
merged_reservoir: Reservoir ,
selected_sample_radiance: vec3<f32> ,
}

Functions

initial_and_temporal

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(8, 8, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1
fn initial_and_temporal (
@builtin(workgroup_id)
workgroup_id: vec3<u32>
@builtin(global_invocation_id)
global_id: vec3<u32>
)

spatial_and_shade

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(8, 8, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1
fn spatial_and_shade (
@builtin(global_invocation_id)
global_id: vec3<u32>
)

generate_initial_reservoir

#
fn generate_initial_reservoir (
world_position: vec3<f32>
world_normal: vec3<f32>
diffuse_brdf: vec3<f32>
workgroup_id: vec2<u32>
) -> Reservoir

load_temporal_reservoir

#
fn load_temporal_reservoir (
pixel_id: vec2<u32>
depth: f32
world_position: vec3<f32>
world_normal: vec3<f32>
) -> Reservoir

load_spatial_reservoir

#
fn load_spatial_reservoir (
pixel_id: vec2<u32>
depth: f32
world_position: vec3<f32>
world_normal: vec3<f32>
) -> Reservoir

get_neighbor_pixel_id

#
fn get_neighbor_pixel_id (
center_pixel_id: vec2<u32>
) -> vec2<u32>

reconstruct_world_position

#
fn reconstruct_world_position (
pixel_id: vec2<u32>
depth: f32
) -> vec3<f32>

reconstruct_previous_world_position

#
fn reconstruct_previous_world_position (
pixel_id: vec2<u32>
depth: f32
) -> vec3<f32>

pixel_dissimilar

#

Reject if tangent plane difference difference more than 0.3% or angle between normals more than 25 degrees

fn pixel_dissimilar (
depth: f32
world_position: vec3<f32>
other_world_position: vec3<f32>
other_normal: vec3<f32>
) -> bool

depth_ndc_to_view_z

#
fn depth_ndc_to_view_z (
ndc_depth: f32
) -> f32

empty_reservoir

#
fn empty_reservoir () -> Reservoir

reservoir_valid

#
fn reservoir_valid (
reservoir: Reservoir
) -> bool

pack_reservoir

#
fn pack_reservoir (
reservoir: Reservoir
) -> vec4<u32>

store_reservoir_a

#
fn store_reservoir_a (
reservoir: Reservoir
)

store_reservoir_b

#
fn store_reservoir_b (
reservoir: Reservoir
)

unpack_reservoir

#
fn unpack_reservoir ( ) -> Reservoir

load_reservoir_a

#
fn load_reservoir_a ( ) -> Reservoir

load_reservoir_b

#
fn load_reservoir_b ( ) -> Reservoir

merge_reservoirs

#
fn merge_reservoirs (
canonical_reservoir: Reservoir
other_reservoir: Reservoir
world_position: vec3<f32>
world_normal: vec3<f32>
diffuse_brdf: vec3<f32>
) -> ReservoirMergeResult

reservoir_target_function

#
fn reservoir_target_function (
reservoir: Reservoir
world_position: vec3<f32>
world_normal: vec3<f32>
diffuse_brdf: vec3<f32>
) -> vec4<f32>