Mercurial > LightClone
view Data/Shaders/Bot.fx @ 74:40c0b5305de8
Work on removing ScreenManager
author | koryspansel |
---|---|
date | Tue, 18 Oct 2011 11:56:49 -0700 |
parents | 41980ff0607d |
children |
line wrap: on
line source
extern uniform float4x4 kWorld; extern uniform float4x4 kView; extern uniform float4x4 kProjection; extern uniform float4 kColor; extern uniform texture kTexture; extern uniform texture kTextureMask; sampler TextureSampler = sampler_state { Texture = <kTexture>; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; sampler MaskSampler = sampler_state { Texture = <kTextureMask>; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; struct VertexOutput { /* * kPosition */ float4 kPosition : POSITION0; /* * kTextureCoords */ float2 kTextureCoords : TEXCOORD0; /* * kNormal */ float3 kColor : COLOR0; }; VertexOutput BotVS(float3 kVertexPosition : POSITION0, float3 kVertexNormal : NORMAL, float2 kTextureCoords : TEXCOORD0) { float4x4 kWorldViewProjection = mul(mul(kWorld, kView), kProjection); float4 kDiffuse = float4(0.8f, 0.8f, 0.8f, 1.0f); float4 kAmbient = float4(0.4f, 0.4f, 0.4f, 1.0f); float3 kDirection = normalize(float3(-1.0f, -0.60f, -0.3f)); float3 kNormal = normalize(mul(kVertexNormal, (float3x3)kWorld)); VertexOutput kOutput; kOutput.kPosition = mul(float4(kVertexPosition, 1.0f), kWorldViewProjection); kOutput.kTextureCoords = kTextureCoords; kOutput.kColor = kAmbient + kDiffuse * saturate(dot(-kDirection, kNormal)); return kOutput; } float4 BotPS(float4 kDiffuseColor : COLOR0, float2 kTextureCoords : TEXCOORD0) : COLOR0 { float4 kTexture = tex2D(TextureSampler, kTextureCoords); float4 kMask = tex2D(MaskSampler, kTextureCoords); float fMaskScale = kMask.r; float fTextureScale = 1.0f - fMaskScale; float4 kBaseColor = kTexture;// * fTextureScale; float4 kMaskColor = kColor;// * fMaskScale; /* if(mask == 0) { (1 - mask) * kBaseColor.rgb * kDiffuseColor.rgb + mask * kMaskColor.rgb } else { 0 * kBaseColor.rgb * kDiffuseColor.rgb + 1 * kMaskColor.rgb } */ return float4(kDiffuseColor.rgb * (fTextureScale * kBaseColor.rgb + fMaskScale * kMaskColor.rgb), kTexture.a); //return float4(kBaseColor.rgb * kDiffuseColor.rgb + kMaskColor, kTexture.a); //return float4(kTexture.rgb * kDiffuseColor.rgb + kMask.r * kColor.rgb, kTexture.a); //return float4(kTexture.rgb * kDiffuseColor.rgb * kColor.rgb, kTexture.a); } technique Default { pass Pass0 { vertexShader = compile vs_2_0 BotVS(); pixelShader = compile ps_2_0 BotPS(); ZEnable = true; ZWriteEnable = true; ZFunc = LessEqual; } }