Back home 🏡 WGSL Spec Bevy WGSL Functions

volumetric_fog.wgsl

Constants

Name Type Value
FRAC_4_PI # f32 0.07957747154594767

Bindings

Name Group Binding index Binding type Type Shader Def
volumetric_fog # 1 0 <uniform> VolumetricFog
depth_texture # 1 1 texture_depth_multisampled_2d 🟢 MULTISAMPLED
depth_texture # 1 1 texture_depth_2d 🔴 MULTISAMPLED
density_texture # 1 2 texture_3d<f32> 🟢 DENSITY_TEXTURE
density_sampler # 1 3 sampler 🟢 DENSITY_TEXTURE

Structures

VolumetricFog

#
The GPU version of [VolumetricFog]. See the comments in volumetric_fog/mod.rs for descriptions of the fields here.
Name Type
clip_from_local mat4x4<f32>
uvw_from_world mat4x4<f32>
far_planes array<vec4<f32>, 3>
fog_color vec3<f32>
light_tint vec3<f32>
ambient_color vec3<f32>
ambient_intensity f32
step_count u32
bounding_radius f32
absorption f32
scattering f32
density_factor f32
density_texture_offset vec3<f32>
scattering_asymmetry f32
light_intensity f32
jitter_strength f32

Vertex

#
Annotation Name Type
builtin(instance_index) instance_index u32
location(0) position vec3<f32>

Functions

vertex

#
@vertex
fn vertex(vertex: Vertex) -> @builtin(position) vec4<f32>
Parameter Type
vertex Vertex
Returns: @builtin(position) vec4<f32>

henyey_greenstein

#
The common Henyey-Greenstein asymmetric phase function [1] [2]. This determines how much light goes toward the viewer as opposed to away from the viewer. From a visual point of view, it controls how the light shafts appear and disappear as the camera looks at the light source. [1]: https://www.scratchapixel.com/lessons/3d-basic-rendering/volume-rendering-for-developers/ray-marching-get-it-right.html [2]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction
fn henyey_greenstein(neg_LdotV: f32) -> f32
Parameter Type
neg_LdotV f32
Returns: f32

fragment

#
@fragment
fn fragment(position: vec4<f32>) -> @location(0) vec4<f32>
Parameter Type
position vec4<f32>
Returns: @location(0) vec4<f32>

fetch_point_shadow_without_normal

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

fetch_spot_shadow_without_normal

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