Back home 🏡 WGSL Spec Bevy WGSL Functions

shadows.wgsl

Import path

Constants

Name Type Value
flip_z # vec3<f32> vec3<f32>(1.0, 1.0, -1.0)

Functions

fetch_point_shadow

#
fn fetch_point_shadow(light_id: u32, frag_position: vec4<f32>, surface_normal: vec3<f32>) -> f32
Parameter Type
light_id u32
frag_position vec4<f32>
surface_normal vec3<f32>
Returns: f32

fetch_spot_shadow

#
fn fetch_spot_shadow(light_id: u32, frag_position: vec4<f32>, surface_normal: vec3<f32>, near_z: f32) -> f32
Parameter Type
light_id u32
frag_position vec4<f32>
surface_normal vec3<f32>
near_z f32
Returns: f32

get_cascade_index

#
fn get_cascade_index(light_id: u32, view_z: f32) -> u32
Parameter Type
light_id u32
view_z f32
Returns: u32

world_to_directional_light_local

#
Converts from world space to the uv position in the light's shadow map. The depth is stored in the return value's z coordinate. If the return value's w coordinate is 0.0, then we landed outside the shadow map entirely.
fn world_to_directional_light_local(light_id: u32, cascade_index: u32, offset_position: vec4<f32>) -> vec4<f32>
Parameter Type
light_id u32
cascade_index u32
offset_position vec4<f32>
Returns: vec4<f32>

sample_directional_cascade

#
fn sample_directional_cascade(light_id: u32, cascade_index: u32, frag_position: vec4<f32>, surface_normal: vec3<f32>) -> f32
Parameter Type
light_id u32
cascade_index u32
frag_position vec4<f32>
surface_normal vec3<f32>
Returns: f32

fetch_directional_shadow

#
fn fetch_directional_shadow(light_id: u32, frag_position: vec4<f32>, surface_normal: vec3<f32>, view_z: f32) -> f32
Parameter Type
light_id u32
frag_position vec4<f32>
surface_normal vec3<f32>
view_z f32
Returns: f32

cascade_debug_visualization

#
fn cascade_debug_visualization(output_color: vec3<f32>, light_id: u32, view_z: f32) -> vec3<f32>
Parameter Type
output_color vec3<f32>
light_id u32
view_z f32
Returns: vec3<f32>