Back home 🏡 WGSL Spec Bevy WGSL Functions

auto_exposure.wgsl

Constants

Name Type Value
RGB_TO_LUM # vec3<f32> vec3<f32>(0.2125, 0.7154, 0.0721)

Bindings

Name Group Binding index Binding type Type
globals # 0 0 <uniform> Globals
settings # 0 1 <uniform> AutoExposure
tex_color # 0 2 texture_2d<f32>
tex_mask # 0 3 texture_2d<f32>
tex_compensation # 0 4 texture_1d<f32>
compensation_curve # 0 5 <uniform> CompensationCurve
histogram # 0 6 <storage, read_write> array<atomic<u32>, 64>
exposure # 0 7 <storage, read_write> f32
view # 0 8 <storage, read_write> View

Structures

AutoExposure

#
Name Type
min_log_lum f32
inv_log_lum_range f32
log_lum_range f32
low_percent f32
high_percent f32
speed_up f32
speed_down f32
exponential_transition_distance f32

CompensationCurve

#
Name Type
min_log_lum f32
inv_log_lum_range f32
min_compensation f32
compensation_range f32

Functions

color_to_bin

#
For a given color, return the histogram bin index
fn color_to_bin(hdr: vec3<f32>) -> u32
Parameter Type
hdr vec3<f32>
Returns: u32

metering_weight

#
Read the metering mask at the given UV coordinates, returning a weight for the histogram. Since the histogram is summed in the compute_average step, there is a limit to the amount of distinct values that can be represented. When using the chosen value of 16, the maximum amount of pixels that can be weighted and summed is 2^32 / 16 = 16384^2.
fn metering_weight(coords: vec2<f32>) -> u32
Parameter Type
coords vec2<f32>
Returns: u32

compute_histogram

#
@compute
fn compute_histogram(global_invocation_id: vec3<u32>, local_invocation_index: u32)
Parameter Type
global_invocation_id vec3<u32>
local_invocation_index u32

compute_average

#
@compute
fn compute_average(local_index: u32)
Parameter Type
local_index u32