aboutsummaryrefslogtreecommitdiff
path: root/src/shaders/shader.slang
blob: 1f055c162189c1e0e0979ed0b8980d03afa1a12e (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
31
32
33
34
struct VertexInput {
    float3 pos;
    float3 col;
    float2 uv;
};

struct UniformBuffer {
    float4x4 model, view, proj;
};

ConstantBuffer<UniformBuffer> ubo;

struct VertexOutput {
    float4 pos : SV_Position;
    float3 col;
    float2 uv;
};

[shader("vertex")]
VertexOutput vert_main(VertexInput vi) {
    VertexOutput vo;
    // vo.pos = float4(vi.pos, 0., 1.);
    vo.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(vi.pos, 1.))));
    vo.col = vi.col;
    vo.uv  = vi.uv;
    return vo;
}

Sampler2D texture;

[shader("fragment")]
float4 frag_main(VertexOutput vo) : SV_Target {
    return texture.Sample(vo.uv);
}