comparison Data/Shaders/Bot.fx @ 65:41980ff0607d

Added shader and textures for bot
author koryspansel <koryspansel@bendbroadband.com>
date Wed, 05 Oct 2011 12:55:46 -0700
parents
children
comparison
equal deleted inserted replaced
64:3507bd831c7f 65:41980ff0607d
1 extern uniform float4x4 kWorld;
2 extern uniform float4x4 kView;
3 extern uniform float4x4 kProjection;
4 extern uniform float4 kColor;
5 extern uniform texture kTexture;
6 extern uniform texture kTextureMask;
7
8 sampler TextureSampler = sampler_state
9 {
10 Texture = <kTexture>;
11 MinFilter = LINEAR;
12 MagFilter = LINEAR;
13 AddressU = CLAMP;
14 AddressV = CLAMP;
15 };
16
17 sampler MaskSampler = sampler_state
18 {
19 Texture = <kTextureMask>;
20 MinFilter = LINEAR;
21 MagFilter = LINEAR;
22 AddressU = CLAMP;
23 AddressV = CLAMP;
24 };
25
26 struct VertexOutput
27 {
28 /*
29 * kPosition
30 */
31 float4 kPosition : POSITION0;
32
33 /*
34 * kTextureCoords
35 */
36 float2 kTextureCoords : TEXCOORD0;
37
38 /*
39 * kNormal
40 */
41 float3 kColor : COLOR0;
42 };
43
44 VertexOutput BotVS(float3 kVertexPosition : POSITION0, float3 kVertexNormal : NORMAL, float2 kTextureCoords : TEXCOORD0)
45 {
46 float4x4 kWorldViewProjection = mul(mul(kWorld, kView), kProjection);
47
48 float4 kDiffuse = float4(0.8f, 0.8f, 0.8f, 1.0f);
49 float4 kAmbient = float4(0.4f, 0.4f, 0.4f, 1.0f);
50 float3 kDirection = normalize(float3(-1.0f, -0.60f, -0.3f));
51
52 float3 kNormal = normalize(mul(kVertexNormal, (float3x3)kWorld));
53
54 VertexOutput kOutput;
55 kOutput.kPosition = mul(float4(kVertexPosition, 1.0f), kWorldViewProjection);
56 kOutput.kTextureCoords = kTextureCoords;
57 kOutput.kColor = kAmbient + kDiffuse * saturate(dot(-kDirection, kNormal));
58
59 return kOutput;
60 }
61
62 float4 BotPS(float4 kDiffuseColor : COLOR0, float2 kTextureCoords : TEXCOORD0) : COLOR0
63 {
64 float4 kTexture = tex2D(TextureSampler, kTextureCoords);
65 float4 kMask = tex2D(MaskSampler, kTextureCoords);
66
67 float fMaskScale = kMask.r;
68 float fTextureScale = 1.0f - fMaskScale;
69
70 float4 kBaseColor = kTexture;// * fTextureScale;
71 float4 kMaskColor = kColor;// * fMaskScale;
72
73 /*
74 if(mask == 0)
75 {
76 (1 - mask) * kBaseColor.rgb * kDiffuseColor.rgb + mask * kMaskColor.rgb
77 }
78 else
79 {
80 0 * kBaseColor.rgb * kDiffuseColor.rgb + 1 * kMaskColor.rgb
81 }
82 */
83
84 return float4(kDiffuseColor.rgb * (fTextureScale * kBaseColor.rgb + fMaskScale * kMaskColor.rgb), kTexture.a);
85
86 //return float4(kBaseColor.rgb * kDiffuseColor.rgb + kMaskColor, kTexture.a);
87 //return float4(kTexture.rgb * kDiffuseColor.rgb + kMask.r * kColor.rgb, kTexture.a);
88 //return float4(kTexture.rgb * kDiffuseColor.rgb * kColor.rgb, kTexture.a);
89 }
90
91 technique Default
92 {
93 pass Pass0
94 {
95 vertexShader = compile vs_2_0 BotVS();
96 pixelShader = compile ps_2_0 BotPS();
97
98 ZEnable = true;
99 ZWriteEnable = true;
100 ZFunc = LessEqual;
101 }
102 }