blob: f7aeb50f7e4fe6da28f751cc3fe3edb1fdc66a8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Full-screen 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 Skybox
{
float4x4 u_projection;
float4x4 u_view;
};
ConstantBuffer<Skybox> 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);
}
|