Back home 🏡 WGSL Spec Bevy WGSL Functions

oit_resolve.wgsl

Bindings

Name Group Binding index Binding type Type
view # 0 0 <uniform> View
layers # 0 1 <storage, read_write> array<vec2<u32>>
layer_ids # 0 2 <storage, read_write> array<atomic<i32>>
depth # 1 0 texture_depth_2d

Structures

OitFragment

#
Name Type
color vec3<f32>
alpha f32
depth f32

FullscreenVertexOutput

#
Annotation Name Type
builtin(position) position vec4<f32>
location(0) uv vec2<f32>

SortResult

#
Name Type
color vec4f
depth f32

Functions

fragment

#
@fragment
fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32>
Parameter Type
in FullscreenVertexOutput
Returns: @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)
Parameter Type
screen_index i32

sort

#
fn sort(screen_index: i32, buffer_size: i32, opaque_depth: f32) -> SortResult
Parameter Type
screen_index i32
buffer_size i32
opaque_depth f32
Returns: 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>
Parameter Type
color_a vec4<f32>
color_b vec4<f32>
Returns: vec4<f32>