Back home 🏡 WGSL Spec Bevy WGSL Functions

ui.wgsl

Constants

Name Type Value
TEXTURED # u32 1u
RIGHT_VERTEX # u32 2u
BOTTOM_VERTEX # u32 4u
BORDER # u32 8u

Bindings

Name Group Binding index Binding type Type
view # 0 0 <uniform> View
sprite_texture # 1 0 texture_2d<f32>
sprite_sampler # 1 1 sampler

Structures

VertexOutput

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

Functions

enabled

#
fn enabled(flags: u32, mask: u32) -> bool
Parameter Type
flags u32
mask u32
Returns: bool

vertex

#
@vertex
fn vertex(vertex_position: vec3<f32>, vertex_uv: vec2<f32>, vertex_color: vec4<f32>, flags: u32, y: top right, z: bottom right, w: bottom left. @location(4) radius: vec4<f32>, y: top, z: right, w: bottom. @location(5) border: vec4<f32>, size: vec2<f32>, point: vec2<f32>) -> VertexOutput
Parameter Type
vertex_position vec3<f32>
vertex_uv vec2<f32>
vertex_color vec4<f32>
flags u32
y top right
z bottom right
w bottom left. @location(4) radius: vec4<f32>
y top
z right
w bottom. @location(5) border: vec4<f32>
size vec2<f32>
point vec2<f32>
Returns: VertexOutput

sd_rounded_box

#
The returned value is the shortest distance from the given point to the boundary of the rounded box. Negative values indicate that the point is inside the rounded box, positive values that the point is outside, and zero is exactly on the boundary. Arguments: - point -> The function will return the distance from this point to the closest point on the boundary. - size -> The maximum width and height of the box. - corner_radii -> The radius of each rounded corner. Ordered counter clockwise starting top left: x: top left, y: top right, z: bottom right, w: bottom left.
fn sd_rounded_box(point: vec2<f32>, size: vec2<f32>, corner_radii: vec4<f32>) -> f32
Parameter Type
point vec2<f32>
size vec2<f32>
corner_radii vec4<f32>
Returns: f32

sd_inset_rounded_box

#
fn sd_inset_rounded_box(point: vec2<f32>, size: vec2<f32>, radius: vec4<f32>, inset: vec4<f32>) -> f32
Parameter Type
point vec2<f32>
size vec2<f32>
radius vec4<f32>
inset vec4<f32>
Returns: f32

antialias

#
get alpha for antialiasing for sdf
fn antialias(distance: f32) -> f32
Parameter Type
distance f32
Returns: f32

draw

#
fn draw(in: VertexOutput, texture_color: vec4<f32>) -> vec4<f32>
Parameter Type
in VertexOutput
texture_color vec4<f32>
Returns: vec4<f32>

draw_background

#
fn draw_background(in: VertexOutput, texture_color: vec4<f32>) -> vec4<f32>
Parameter Type
in VertexOutput
texture_color vec4<f32>
Returns: vec4<f32>

fragment

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