Back home 🏡 WGSL Spec Bevy WGSL Functions

box_shadow.wgsl

Constants

Name Type Value
PI # f32 3.14159265358979323846
SAMPLES # i32 #SHADOW_SAMPLES

Bindings

Name Group Binding index Binding type Type
view # 0 0 <uniform> View

Structures

BoxShadowVertexOutput

#
Annotation Name Type
builtin(position) position vec4<f32>
location(0) point vec2<f32>
location(1) color vec4<f32>

Functions

gaussian

#
fn gaussian(x: f32, sigma: f32) -> f32
Parameter Type
x f32
sigma f32
Returns: f32

erf

#
Approximates the Gauss error function: https://en.wikipedia.org/wiki/Error_function
fn erf(p: vec2<f32>) -> vec2<f32>
Parameter Type
p vec2<f32>
Returns: vec2<f32>

selectCorner

#
returns the closest corner radius based on the signs of the components of p
fn selectCorner(p: vec2<f32>, c: vec4<f32>) -> f32
Parameter Type
p vec2<f32>
c vec4<f32>
Returns: f32

horizontalRoundedBoxShadow

#
fn horizontalRoundedBoxShadow(x: f32, y: f32, blur: f32, corner: f32, half_size: vec2<f32>) -> f32
Parameter Type
x f32
y f32
blur f32
corner f32
half_size vec2<f32>
Returns: f32

roundedBoxShadow

#
fn roundedBoxShadow(lower: vec2<f32>, upper: vec2<f32>, point: vec2<f32>, blur: f32, corners: vec4<f32>) -> f32
Parameter Type
lower vec2<f32>
upper vec2<f32>
point vec2<f32>
blur f32
corners vec4<f32>
Returns: f32

vertex

#
@vertex
fn vertex(vertex_position: vec3<f32>, uv: vec2<f32>, vertex_color: vec4<f32>, size: vec2<f32>, radius: vec4<f32>, blur: f32, bounds: vec2<f32>) -> BoxShadowVertexOutput
Parameter Type
vertex_position vec3<f32>
uv vec2<f32>
vertex_color vec4<f32>
size vec2<f32>
radius vec4<f32>
blur f32
bounds vec2<f32>
Returns: BoxShadowVertexOutput

fragment

#
@fragment
fn fragment(in: BoxShadowVertexOutput) -> @location(0) vec4<f32>
Parameter Type
in BoxShadowVertexOutput
Returns: @location(0) vec4<f32>