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.

oit_resolve.wgsl

Bindings

view

#
@group(0)
@binding(0)
var<uniform> view: View

layers

#
@group(0)
@binding(1)
var<storage, read_write> layers: array<vec2<u32>>

layer_ids

#
@group(0)
@binding(2)
var<storage, read_write> layer_ids: array<atomic<i32>>

depth

#
@group(1)
@binding(0)
var depth: texture_depth_2d

Structures

OitFragment

#
struct OitFragment {
color: vec3<f32> ,
alpha: f32 ,
depth: f32 ,
}

FullscreenVertexOutput

#
struct FullscreenVertexOutput {
@builtin(position)
position: vec4<f32> ,
@location(0)
uv: vec2<f32> ,
}

SortResult

#
struct SortResult {
color: vec4f ,
depth: f32 ,
}

Functions

fragment

#
@fragment
Calculates the final color of each pixel on the screen
fn fragment ( ) ->
@location(0)
vec4<f32>

reset_indices

#

Resets all indices to 0. This means we don’t have to clear the entire layers buffer

fn reset_indices (
screen_index: i32
)

sort

#
fn sort (
screen_index: i32
buffer_size: i32
opaque_depth: f32
) -> SortResult

blend

#

OVER operator using premultiplied alpha see: https://en.wikipedia.org/wiki/Alpha_compositing

fn blend (
color_a: vec4<f32>
color_b: vec4<f32>
) -> vec4<f32>