SIMPLE_VERTEX_SHADER

Constant SIMPLE_VERTEX_SHADER 

Source
pub const SIMPLE_VERTEX_SHADER: &str = r#"
struct VertexInput {
    @location(0) position: vec2<f32>,
    @location(1) color: vec4<f32>,
    @location(2) size: f32,
}

struct VertexOutput {
    @builtin(position) clip_position: vec4<f32>,
    @location(0) color: vec4<f32>,
}

@vertex
fn vs_main(vertex: VertexInput) -> VertexOutput {
    var out: VertexOutput;
    out.clip_position = vec4<f32>(vertex.position, 0.0, 1.0);
    out.color = vertex.color;
    return out;
}
"#;
Expand description

Simple vertex shader (currently used for basic point rendering)

Pipeline Stage 1: VERTEX PROCESSING

  • Takes each vertex (point) from our Rust Vertex struct
  • Converts 2D position (x, y) to 4D GPU clip space (x, y, z, w)
  • Passes color through unchanged to fragment shader

Input layout matches our Rust Vertex struct:

  • @location(0): position [x, y]
  • @location(1): color [r, g, b, a]
  • @location(2): size (not currently used)

This shader does minimal work - just format conversion. Perfect for rendering millions of points quickly.