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.

specular_gi.wgsl

Import path

Constants

DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD

#
const DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD: f32 = 0.4

SPECULAR_GI_FOR_DI_ROUGHNESS_THRESHOLD

#
const SPECULAR_GI_FOR_DI_ROUGHNESS_THRESHOLD: f32 = 0.0225

TERMINATE_IN_WORLD_CACHE_THRESHOLD

#
const TERMINATE_IN_WORLD_CACHE_THRESHOLD: f32 = 0.03

Bindings

view_output

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

gi_reservoirs_a

#
@group(1)
@binding(5)
var<storage, read_write> gi_reservoirs_a: array<Reservoir>

gbuffer

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

depth_buffer

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

view

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

Structures

PushConstants

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

Reservoir

#

Don’t adjust the size of this struct without also adjusting GI_RESERVOIR_STRUCT_SIZE.

struct Reservoir {
sample_point_world_position: vec3<f32> ,
weight_sum: f32 ,
radiance: vec3<f32> ,
confidence_weight: f32 ,
sample_point_world_normal: vec3<f32> ,
unbiased_contribution_weight: f32 ,
}

Functions

specular_gi

#
@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 specular_gi (
@builtin(global_invocation_id)
global_id: vec3<u32>
)

trace_glossy_path

#
fn trace_glossy_path (
initial_ray_origin: vec3<f32>
initial_wi: vec3<f32>
initial_roughness: f32
initial_p_bounce: f32
) -> vec3<f32>

emissive_mis_weight

#
fn emissive_mis_weight (
initial_roughness: f32
p_bounce: f32
previous_surface_perfectly_specular: bool
) -> f32

nee_mis_weight

#
fn nee_mis_weight (
inverse_p_light: f32
brdf_rays_can_hit: bool
wo_tangent: vec3<f32>
) -> f32