summaryrefslogtreecommitdiff
path: root/engine/res
diff options
context:
space:
mode:
Diffstat (limited to 'engine/res')
-rw-r--r--engine/res/imgui_shader.slang54
1 files changed, 54 insertions, 0 deletions
diff --git a/engine/res/imgui_shader.slang b/engine/res/imgui_shader.slang
new file mode 100644
index 0000000..6ce51d6
--- /dev/null
+++ b/engine/res/imgui_shader.slang
@@ -0,0 +1,54 @@
+struct Vertex
+{
+ float3 pos;
+ float4 color;
+ float2 texture_coords;
+};
+
+struct VertexData
+{
+ float4 color;
+ float2 texture_coords;
+};
+
+struct VertexStageOutput
+{
+ VertexData vertex_data : VertexData;
+ float4 sv_position : SV_Position;
+};
+
+struct Fragment
+{
+ float4 color;
+};
+
+cbuffer Uniforms
+{
+ float4x4 projection;
+};
+
+Sampler2D main_texture;
+
+[shader("vertex")]
+VertexStageOutput vertex_main(Vertex vertex: VERTEX)
+{
+ VertexStageOutput stage_output;
+
+ stage_output.sv_position = mul(projection, float4(vertex.pos.xy, 0.f, 1.f));
+
+ stage_output.vertex_data.color = vertex.color;
+ stage_output.vertex_data.texture_coords = vertex.texture_coords;
+
+ return stage_output;
+}
+
+[shader("fragment")]
+Fragment fragment_main(VertexData vertex_data: VertexData) : SV_Target
+{
+ Fragment fragment;
+
+ fragment.color = vertex_data.color * main_texture.Sample(vertex_data.texture_coords);
+
+ return fragment;
+}
+