This repository has been archived by the owner on Oct 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlay.fx
91 lines (61 loc) · 1.95 KB
/
overlay.fx
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//credits: ms d3d tutorials which I hacked apart
Texture2D txDiffuse : register( t0 );
SamplerState samLinear : register( s0 );
cbuffer ConstantBuffer : register( b0 )
{
float4x4 rotation;
float2 originpoint;
float2 translation;
float2 scaling;
float transparency;
float garbage;
}
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS( VS_INPUT input )
{
PS_INPUT r=input;
float4 rp;
r.Pos[0]-=originpoint[0];
r.Pos[1]+=originpoint[1];
r.Pos=mul(r.Pos, rotation);
r.Pos[0]+=originpoint[0];
r.Pos[1]-=originpoint[1];
//scale to the required size (calculated by the renderer)
r.Pos[0]=r.Pos[0]*scaling[0];
r.Pos[1]=r.Pos[1]*scaling[1];
//position the sprite so the origin is at the top left
r.Pos[0]+=1.0f*scaling[0];
r.Pos[1]-=1.0f*scaling[1];
//now translate to the proper position (0,0=center)
r.Pos[0]+=translation[0];
r.Pos[1]-=translation[1];
r.Pos[2]=0.0f;
return r;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
//For those wondering: Here used to be a secondary pixelshader. It's gone (yup, it's gone)
float4 PSNormal( PS_INPUT input): SV_Target
{
//pixel shader for overlays that do not use the 255,255,255 = transparency rule
float4 r;
r=txDiffuse.Sample( samLinear, input.Tex );
r[3]=r[3]*transparency;
return r;
// r[3]=r[3]*transparency;
// return float4(0.0f, 1.0f, 0.0f, 1.0f);
}