forked from PJayB/DirectCompositionDirectX12Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shaders.hlsl
43 lines (33 loc) · 1.04 KB
/
shaders.hlsl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
struct PSInput
{
float4 position : SV_POSITION;
float2 uv : TEXCOORD;
};
Texture2D g_texture : register(t0);
SamplerState g_sampler : register(s0);
float g_rotation : register(b0);
PSInput VSMain(float4 position : POSITION, float4 uv : TEXCOORD)
{
PSInput result;
float2 theta;
sincos(g_rotation, theta.x, theta.y);
float2x2 rotate2D = { theta.y, -theta.x, theta.x, theta.y };
float2 offset = float2(0.5f, 0.5f);
result.position = position;
result.uv = mul(rotate2D, uv - offset) + offset;
return result;
}
float4 PSMain(PSInput input) : SV_TARGET
{
return g_texture.Sample(g_sampler, input.uv);
}