Symbols in this topic
@vgpu/wgsl-std/fullscreen
Pure WGSL fullscreen-triangle helpers for resolver-managed shaders. Import them when a vertex shader should draw a full-screen pass with three vertices and no vertex buffer.
Import
WGSL
1
import { fullscreenTriangleClip, fullscreenTriangleUv } from "@vgpu/wgsl-std/fullscreen";Signature
WGSL
1
2
export fn fullscreenTriangleClip(index: u32) -> vec4f;
export fn fullscreenTriangleUv(clipXy: vec2f) -> vec2f;Parameters
| Param | Type | Required | Default | Notes |
|---|---|---|---|---|
| index | u32 | ✔ | — | Vertex index for fullscreenTriangleClip. Use @builtin(vertex_index) and draw exactly 3 vertices. Values 0, 1, and 2 map to the oversized fullscreen triangle. |
| clipXy | vec2f | ✔ | — | Clip-space XY position, normally fullscreenTriangleClip(index).xy, for UV conversion with a render-target-friendly Y flip. |
Returns: fullscreenTriangleClip returns clip-space vec4f; fullscreenTriangleUv returns vec2f UVs where clip-space top-left (-1.0, 1.0) maps to (0.0, 0.0).
Throws: These WGSL declarations do not throw. resolveShader() can still throw VGPU-WGSL-SYM-NOEXPORT for misspelled imports, VGPU-WGSL-PKG-NOTFOUND if the package import cannot be resolved, or validation errors such as VGPU-WGSL-NAGA-UNKNOWN if caller WGSL is invalid.
Examples
TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const fullscreenVertexWgsl = `
import { fullscreenTriangleClip, fullscreenTriangleUv } from "@vgpu/wgsl-std/fullscreen";
struct VertexOutput {
@builtin(position) position: vec4f,
@location(0) uv: vec2f,
}
@vertex
fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput {
var out: VertexOutput;
out.position = fullscreenTriangleClip(index);
out.uv = fullscreenTriangleUv(out.position.xy);
return out;
}
`;
console.log(fullscreenVertexWgsl.includes("vs_main"));TypeScript
1
2
3
4
5
6
7
8
9
10
const postProcessWgsl = `
import { fullscreenTriangleClip } from "@vgpu/wgsl-std/fullscreen";
@vertex
fn vs_main(@builtin(vertex_index) index: u32) -> @builtin(position) vec4f {
return fullscreenTriangleClip(index);
}
`;
console.log(postProcessWgsl.length > 0);Notes
- This module is pure WGSL: it declares no
@group, no@binding, no overrides, no hidden state, and no entry points. - Clip outputs are
0 -> (-1, -3),1 -> (-1, 1),2 -> (3, 1), covering the viewport as one oversized triangle. fullscreenTriangleUvappliesclipXy * vec2f(0.5, -0.5) + vec2f(0.5), matching top-left texture coordinate convention for fullscreen passes.- The helpers do not choose varying locations, fragment outputs, bind groups, or samplers; those remain in your entry shader.
- See also:
@vgpu/wgsl-std/color,resolveShader,wgslVitePlugin.