hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/skybox.slang
blob: de400b8f517b15989c14bab5a692ddb496eaaacd (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
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;
    return output;
}

SamplerCube u_Skybox;

[shader("fragment")]
float4 fragmentMain(VSOutput input) : SV_Target
{
    return u_Skybox.Sample(input.texCoords);
}