Shader Explorer
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.

compute_mesh.wgsl

Constants

half_size

#
const half_size: vec3 = vec3(1.5)

min

#
const min: AbstractInt = -half_size

max

#
const max: AbstractInt = half_size

vertices

#
const vertices: AbstractFloat = array( // xyz, normal.xyz, uv.xy // Front min.x, min.y, max.z, 0.0, 0.0, 1.0, 0.0, 0.0, max.x, min.y, max.z, 0.0, 0.0, 1.0, 1.0, 0.0, max.x, max.y, max.z, 0.0, 0.0, 1.0, 1.0, 1.0, min.x, max.y, max.z, 0.0, 0.0, 1.0, 0.0, 1.0, // Back min.x, max.y, min.z, 0.0, 0.0, -1.0, 1.0, 0.0, max.x, max.y, min.z, 0.0, 0.0, -1.0, 0.0, 0.0, max.x, min.y, min.z, 0.0, 0.0, -1.0, 0.0, 1.0, min.x, min.y, min.z, 0.0, 0.0, -1.0, 1.0, 1.0, // Right max.x, min.y, min.z, 1.0, 0.0, 0.0, 0.0, 0.0, max.x, max.y, min.z, 1.0, 0.0, 0.0, 1.0, 0.0, max.x, max.y, max.z, 1.0, 0.0, 0.0, 1.0, 1.0, max.x, min.y, max.z, 1.0, 0.0, 0.0, 0.0, 1.0, // Left min.x, min.y, max.z, -1.0, 0.0, 0.0, 1.0, 0.0, min.x, max.y, max.z, -1.0, 0.0, 0.0, 0.0, 0.0, min.x, max.y, min.z, -1.0, 0.0, 0.0, 0.0, 1.0, min.x, min.y, min.z, -1.0, 0.0, 0.0, 1.0, 1.0, // Top max.x, max.y, min.z, 0.0, 1.0, 0.0, 1.0, 0.0, min.x, max.y, min.z, 0.0, 1.0, 0.0, 0.0, 0.0, min.x, max.y, max.z, 0.0, 1.0, 0.0, 0.0, 1.0, max.x, max.y, max.z, 0.0, 1.0, 0.0, 1.0, 1.0, // Bottom max.x, min.y, max.z, 0.0, -1.0, 0.0, 0.0, 0.0, min.x, min.y, max.z, 0.0, -1.0, 0.0, 1.0, 0.0, min.x, min.y, min.z, 0.0, -1.0, 0.0, 1.0, 1.0, max.x, min.y, min.z, 0.0, -1.0, 0.0, 0.0, 1.0 )

indices

#
const indices: AbstractInt = array( 0, 1, 2, 2, 3, 0, // front 4, 5, 6, 6, 7, 4, // back 8, 9, 10, 10, 11, 8, // right 12, 13, 14, 14, 15, 12, // left 16, 17, 18, 18, 19, 16, // top 20, 21, 22, 22, 23, 20, // bottom )

Bindings

data_range

#
@group(0)
@binding(0)
var<uniform> data_range: DataRanges

vertex_data

#
@group(0)
@binding(1)
var<storage, read_write> vertex_data: array<f32>

index_data

#
@group(0)
@binding(2)
var<storage, read_write> index_data: array<u32>

Structures

DataRanges

#

vertex_start is the starting offset of the mesh data in the vertex_data storage buffer index_start is the starting offset of the index data in the index_data storage buffer

struct DataRanges {
vertex_start: u32 ,
vertex_end: u32 ,
index_start: u32 ,
index_end: u32 ,
}

Functions

main

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1
fn main (
@builtin(global_invocation_id)
global_id: vec3<u32>
)