Back home 🏡 WGSL Spec Bevy WGSL Functions

taa.wgsl

Constants

Name Type Value
DEFAULT_HISTORY_BLEND_RATE # f32 0.1
MIN_HISTORY_BLEND_RATE # f32 0.015

Bindings

Name Group Binding index Binding type Type
view_target # 0 0 texture_2d<f32>
history # 0 1 texture_2d<f32>
motion_vectors # 0 2 texture_2d<f32>
depth # 0 3 texture_depth_2d
nearest_sampler # 0 4 sampler
linear_sampler # 0 5 sampler

Structures

Output

#
Annotation Name Type
location(0) view_target vec4<f32>
location(1) history vec4<f32>

Functions

rcp

#
TAA is ideally applied after tonemapping, but before post processing Post processing wants to go before tonemapping, which conflicts Solution: Put TAA before tonemapping, tonemap TAA input, apply TAA, invert-tonemap TAA output https://advances.realtimerendering.com/s2014/index.html#_HIGH-QUALITY_TEMPORAL_SUPERSAMPLING, slide 20 https://gpuopen.com/learn/optimized-reversible-tonemapper-for-resolve
fn rcp(x: f32) -> f32
Parameter Type
x f32
Returns: f32

max3

#
fn max3(x: vec3<f32>) -> f32
Parameter Type
x vec3<f32>
Returns: f32

tonemap

#
fn tonemap(color: vec3<f32>) -> vec3<f32>
Parameter Type
color vec3<f32>
Returns: vec3<f32>

reverse_tonemap

#
fn reverse_tonemap(color: vec3<f32>) -> vec3<f32>
Parameter Type
color vec3<f32>
Returns: vec3<f32>

RGB_to_YCoCg

#
The following 3 functions are from Playdead (MIT-licensed) https://github.com/playdeadgames/temporal/blob/master/Assets/Shaders/TemporalReprojection.shader
fn RGB_to_YCoCg(rgb: vec3<f32>) -> vec3<f32>
Parameter Type
rgb vec3<f32>
Returns: vec3<f32>

YCoCg_to_RGB

#
fn YCoCg_to_RGB(ycocg: vec3<f32>) -> vec3<f32>
Parameter Type
ycocg vec3<f32>
Returns: vec3<f32>

clip_towards_aabb_center

#
fn clip_towards_aabb_center(history_color: vec3<f32>, current_color: vec3<f32>, aabb_min: vec3<f32>, aabb_max: vec3<f32>) -> vec3<f32>
Parameter Type
history_color vec3<f32>
current_color vec3<f32>
aabb_min vec3<f32>
aabb_max vec3<f32>
Returns: vec3<f32>

sample_history

#
fn sample_history(u: f32, v: f32) -> vec3<f32>
Parameter Type
u f32
v f32
Returns: vec3<f32>

sample_view_target

#
fn sample_view_target(uv: vec2<f32>) -> vec3<f32>
Parameter Type
uv vec2<f32>
Returns: vec3<f32>

taa

#
@fragment
fn taa(uv: vec2<f32>) -> Output
Parameter Type
uv vec2<f32>
Returns: Output