TypologySienna Chen
ToolsLightweight

WGSL

GLSL’s stricter cousin, for WebGPU.

The shader language for WebGPU. It does the same job as GLSL with stricter rules, and it can also run general computation, which is what makes huge particle counts possible. Fewer examples exist online, so give the model a working snippet to copy from.

Breaks when
few examples online, so models guess syntax
Also called
WebGPU shading language

Prompts

Compute-shader particle step
WGSL compute shader over a storage buffer of Particle { pos: vec2f, vel: vec2f }, @workgroup_size(64). Each invocation accelerates its particle toward a uniform pointer (0.6), damps velocity by 0.97 and wraps at the edges. Include the bind group layout and the JS dispatch math (ceil(N / 64)). No “similar to above” shortcuts — complete code.
Full-screen fragment in WGSL
WGSL vertex + fragment for a full-screen triangle from @builtin(vertex_index), no vertex buffer. Uniform struct { time: f32, res: vec2f }. The fragment draws a moiré of two rotated stripe fields with smoothstep anti-aliasing. Point out the three places WGSL differs from GLSL here: types, swizzle assignment, and no implicit int-to-float.
Port this GLSL to WGSL
Convert the following GLSL ES 3.00 fragment shader to WGSL with identical output. [paste shader] Keep function names, make every implicit cast explicit, replace mix/fract/mod with their WGSL equivalents, and list any function that has no direct counterpart.

Related

Resources · 2