aboutsummaryrefslogtreecommitdiff
path: root/src/shaders/shader.slang
blob: b5f7a541a1fa898120d708c7b1f1fb91f38755e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
static float2 positions[3] = float2[] (
    float2( 0.0, -0.5),
    float2( 0.5,  0.5),
    float2(-0.5,  0.5),
);

static float3 colors[3] = float3[] (
    float3(1.0, 0.0, 0.0),
    float3(0.0, 1.0, 0.0),
    float3(0.0, 0.0, 1.0),
);

struct VertexOutput {
    float3 color;
    float4 sv_position : SV_Position;
};

[shader("vertex")]
VertexOutput vert_main(uint vid : SV_VertexID) {
    VertexOutput output;
    output.color = colors[vid];
    output.sv_position = float4(positions[vid], 0.0, 1.0);
    return output;
}

[shader("fragment")]
float4 frag_main(VertexOutput vert) : SV_Target {
    float3 color = vert.color;
    return float4(color, 1.0);
}