From 3fd33ecff7472e4d6fc9e6b3905f56982e497ef2 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 23 Aug 2026 17:21:37 +0200 Subject: [feat]: complete RHI api --- assets/shaders/skybox.slang | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 assets/shaders/skybox.slang (limited to 'assets/shaders/skybox.slang') diff --git a/assets/shaders/skybox.slang b/assets/shaders/skybox.slang new file mode 100644 index 0000000..6447bea --- /dev/null +++ b/assets/shaders/skybox.slang @@ -0,0 +1,29 @@ +// Fullscreen skybox cube. View/projection in a ConstantBuffer (UBO, binding 0) +// so both backends drive it through the RHI; the cubemap is a sampler at binding 1. +struct SkyboxU +{ + float4x4 u_Projection; + float4x4 u_View; +}; +ConstantBuffer sb; + +struct VSInput { float3 position : POSITION; }; +struct VSOutput { float4 position : SV_Position; float3 texCoords : TEXCOORD0; }; + +[shader("vertex")] +VSOutput vertexMain(VSInput input) +{ + VSOutput output; + output.texCoords = input.position; + float4 pos = mul(sb.u_Projection, mul(sb.u_View, float4(input.position, 1.0))); + output.position = pos.xyww; // force depth = 1 so the skybox stays behind everything + return output; +} + +SamplerCube u_Skybox; + +[shader("fragment")] +float4 fragmentMain(VSOutput input) : SV_Target +{ + return u_Skybox.Sample(input.texCoords); +} -- cgit v1.3