/
RA3 dx9 new shader SIMPLE.fx
70 lines (56 loc) · 1.41 KB
/
RA3 dx9 new shader SIMPLE.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
//placeholder parameters
//the only texture
texture DiffuseTexture <string UIName = "DiffuseTexture";>;
bool AlphaTestEnable <string UIName = "Alpha Test Enable";> = 0 ;
sampler DiffuseSampler = sampler_state
{
Texture = <DiffuseTexture>;
MinFilter = 3;
MagFilter = 2;
MipFilter = 2;
MaxAnisotropy = 8;
AddressU = 1;
AddressV = 1;
};
// Default transformations
float4x4 WorldViewProjection : WorldViewProjection;
// Vertex shader
struct VS_INPUT
{
float4 Position : POSITION;
float3 Normal : NORMAL;
float2 TexCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};
VS_OUTPUT VS_Main(VS_INPUT input)
{
VS_OUTPUT output;
output.Position = mul(input.Position, WorldViewProjection);
output.TexCoord = input.TexCoord;
return output;
}
// Pixel shader
struct PS_INPUT
{
float2 TexCoord : TEXCOORD0;
};
float4 PS_Main(PS_INPUT input) : COLOR
{
// Sample the diffuse texture
float4 diffuseColor = tex2D(DiffuseSampler, input.TexCoord);
// Alpha test: Discard pixels with alpha below a threshold
if (AlphaTestEnable && diffuseColor.a < 0.5) discard;
return diffuseColor;
}
technique MainTechnique
{
pass Pass1
{
vertexShader = compile vs_3_0 VS_Main();
pixelShader = compile ps_3_0 PS_Main();
}
}