Skip to content

WGSL Usage

Shader

Vertex

  • 꼭짓짐
@vertex fn vs(
    @builtin(vertex_index) vertexIndex : u32
) -> @builtin(position) vec4f {
    let pos = array(
        vec2f( 0.0,  0.5),
        vec2f(-0.5, -0.5),
        vec2f( 0.5, -0.5)
    );

    return vec4f(pos[vertexIndex], 0.0, 1.0);
}

Fragment

  • 색칠
@fragment fn fs() -> @location(0) vec4f {
    return vec4f(1.0, 0.0, 0.0, 1.0);
}

Compute