forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.fx
206 lines (172 loc) · 4.07 KB
/
ui.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// variables global to this effect.
float4x4 ObjectToWorld;
float4x4 WorldToView;
float4x4 Projection;
texture Texture1;
texture Texture2;
float UiGlow;
//============================================================================
//
// Ui Canvas shaders
//
//============================================================================
sampler2D Sampler1 = sampler_state
{
Texture = (Texture1);
MipFilter = NONE;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
sampler2D WrapSampler = sampler_state
{
Texture = (Texture1);
MipFilter = NONE;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
sampler2D WrapSampler2 = sampler_state
{
Texture = (Texture2);
MipFilter = NONE;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
sampler2D MipSampler = sampler_state
{
Texture = (Texture1);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR0;
float2 Tex1 : TEXCOORD0;
};
VS_OUTPUT FixedVS(
float3 Pos : POSITION,
float4 Color : COLOR0,
float2 Tex : TEXCOORD0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
float4x4 WorldView = mul(ObjectToWorld, WorldToView);
float3 P = mul(float4(Pos, 1), (float4x3)WorldView); // position (view space)
Out.Pos = mul(float4(P, 1), Projection); // position (projected)
// copy through color and tex coords
Out.Color = Color;
Out.Tex1 = Tex;
return Out;
}
float4 UiSelectPS(
float4 Diff : COLOR0,
float2 Tex1 : TEXCOORD0,
uniform sampler2D sampler1,
uniform bool alphaTestEnable,
uniform int alphaFunc,
uniform int alphaRef ) : COLOR
{
float4 texColor;
if ( Diff.g == 1.0f )
texColor = tex2D(sampler1, Tex1);
else
texColor = tex2D(WrapSampler2, Tex1);
#ifdef DIRECT3D10
if( alphaTestEnable )
AlphaTestD3D10( texColor.a, alphaFunc, alphaRef );
#endif
return texColor;
}
float4 UiPS(
float4 Diff : COLOR0,
float2 Tex1 : TEXCOORD0,
uniform sampler2D sampler1) : COLOR
{
float4 texColor = tex2D(sampler1, Tex1) * Diff;
return texColor;
}
float4 SelectGlowPS(
float4 Diff : COLOR0,
float2 Tex1 : TEXCOORD0) : COLOR
{
return float4( Diff + 0.01 );
}
float4 UiGlowPS(
float4 Diff : COLOR0,
float2 Tex1 : TEXCOORD0) : COLOR
{
return float4( UiGlow, UiGlow, UiGlow, UiGlow );
}
technique TPath
{
pass P0
{
AlphaState( AlphaBlend_SrcAlpha_InvSrcAlpha_Write_RGBA )
DepthState( Depth_Enable_Less )
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 UiPS(MipSampler);
}
}
technique TSelect
{
pass P0
{
AlphaState( AlphaBlend_SrcAlpha_InvSrcAlpha_Write_RGBA )
DepthState( Depth_Always )
#ifndef DIRECT3D10
AlphaTestEnable = true;
AlphaFunc = Greater;
AlphaRef = 0;
#endif
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 UiSelectPS(WrapSampler, true, d3d_Greater, 0 );
}
}
technique TSelectGlow
{
pass P0
{
AlphaState( AlphaBlend_Disable )
DepthState( Depth_Enable_Always_Write_None )
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 SelectGlowPS();
}
}
technique TPathGlow
{
pass P0
{
AlphaState( AlphaBlend_Disable )
DepthState( Depth_Enable_Always_Write_None )
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 UiGlowPS();
}
}
technique TPathNoMip
{
pass P0
{
AlphaState( AlphaBlend_SrcAlpha_InvSrcAlpha_Write_RGBA )
DepthState( Depth_Always )
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 UiPS(Sampler1);
}
}
technique TPathNoZClip
{
pass P0
{
AlphaState( AlphaBlend_SrcAlpha_InvSrcAlpha_Write_RGBA )
DepthState( Depth_Always )
VertexShader = compile vs_1_1 FixedVS();
PixelShader = compile ps_2_0 UiPS(MipSampler);
}
}