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.

auto_exposure.wgsl

Constants

RGB_TO_LUM

#
const RGB_TO_LUM: vec3<f32> = vec3<f32>(0.2125, 0.7154, 0.0721)

Bindings

globals

#
@group(0)
@binding(0)
var<uniform> globals: Globals

settings

#
@group(0)
@binding(1)
var<uniform> settings: AutoExposure

tex_color

#
@group(0)
@binding(2)
var tex_color: texture_2d<f32>

tex_mask

#
@group(0)
@binding(3)
var tex_mask: texture_2d<f32>

tex_compensation

#
@group(0)
@binding(4)
var tex_compensation: texture_1d<f32>

compensation_curve

#
@group(0)
@binding(5)
var<uniform> compensation_curve: CompensationCurve

histogram

#
@group(0)
@binding(6)
var<storage, read_write> histogram: array<atomic<u32>, 64>

exposure

#
@group(0)
@binding(7)
var<storage, read_write> exposure: f32

view

#
@group(0)
@binding(8)
var<storage, read_write> view: View

Structures

AutoExposure

#
struct AutoExposure {
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

#
struct CompensationCurve {
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 ( ) -> u32

metering_weight

#

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 ( ) -> u32

compute_histogram

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(16, 16, 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 compute_histogram (
@builtin(global_invocation_id)
global_invocation_id: vec3<u32>
@builtin(local_invocation_index)
local_invocation_index: u32
)

compute_average

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(1, 1, 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 compute_average (
@builtin(local_invocation_index)
local_index: u32
)