From e5d67bf7e36671d290b19064f58bc11616c05b8b Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 5 Jun 2026 21:50:56 +0200 Subject: feat(engine): add imgui ui support --- engine/res/imgui_shader.slang | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 engine/res/imgui_shader.slang (limited to 'engine/res') 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; +} + -- cgit v1.2.3-18-g5258