From 00370c21f107ff2a320fbdef170e24a8b5cda92a Mon Sep 17 00:00:00 2001 From: vimene Date: Wed, 24 Dec 2025 01:38:45 +0100 Subject: added uniform buffers, small tweaks - fixed aspect ratio being the inverse of what it's supposed to be - use std::chrono::high_resolution_clock instead of system_clock - convert ellapsed time to float representing seconds - renamed engine::math::Matrix4::projection to perspective - use [0,1] instead of [-1,1] for the range of z values, to be aligned with vulkan - added engine::math::Matrix4::{look_at,transpose} --- src/shaders/shader.slang | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/shaders/shader.slang') diff --git a/src/shaders/shader.slang b/src/shaders/shader.slang index 37041c6..24d9946 100644 --- a/src/shaders/shader.slang +++ b/src/shaders/shader.slang @@ -3,6 +3,12 @@ struct VertexInput { float3 col; }; +struct UniformBuffer { + float4x4 model, view, proj; +}; + +ConstantBuffer ubo; + struct VertexOutput { float4 pos : SV_Position; float3 col; @@ -11,7 +17,8 @@ struct VertexOutput { [shader("vertex")] VertexOutput vert_main(VertexInput vi) { VertexOutput vo; - vo.pos = float4(vi.pos, 0., 1.); + // vo.pos = float4(vi.pos, 0., 1.); + vo.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(vi.pos, 0., 1.)))); vo.col = vi.col; return vo; } -- cgit v1.2.3