indexed_quad.slang

cross platform rendering playground

src/shaders/conformance/indexed_quad.slang

777 B
struct VSInput {
    [[vk::location(0)]]
    float2 position;
    [[vk::location(1)]]
    float3 color;
};

struct VSOutput {
    float4 position : SV_Position;
    float3 color : COLOR;
};

struct QuadPush {
    float time;
    float2 offset;
    float4 tint;
};

[vk::push_constant]
QuadPush pc;

[shader("vertex")]
VSOutput vsMain(VSInput input) {
    float c = cos(pc.time);
    float s = sin(pc.time);
    float2 p = float2(input.position.x * c - input.position.y * s, input.position.x * s + input.position.y * c);
    p += pc.offset;

    VSOutput output;
    output.position = float4(p, 0.0, 1.0);
    output.color = input.color;
    return output;
}

[shader("fragment")]
float4 fsMain(VSOutput input) : SV_Target {
    return float4(input.color * pc.tint.rgb, 1.0);
}