aboutsummaryrefslogtreecommitdiff
path: root/src/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaders')
-rw-r--r--src/shaders/shader.slang34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/shaders/shader.slang b/src/shaders/shader.slang
index b5f7a54..37041c6 100644
--- a/src/shaders/shader.slang
+++ b/src/shaders/shader.slang
@@ -1,30 +1,22 @@
-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 VertexInput {
+ float2 pos;
+ float3 col;
+};
struct VertexOutput {
- float3 color;
- float4 sv_position : SV_Position;
+ float4 pos : SV_Position;
+ float3 col;
};
[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;
+VertexOutput vert_main(VertexInput vi) {
+ VertexOutput vo;
+ vo.pos = float4(vi.pos, 0., 1.);
+ vo.col = vi.col;
+ return vo;
}
[shader("fragment")]
-float4 frag_main(VertexOutput vert) : SV_Target {
- float3 color = vert.color;
- return float4(color, 1.0);
+float4 frag_main(VertexOutput vo) : SV_Target {
+ return float4(vo.col, 1.);
}