Created
May 5, 2012 15:36
-
-
Save Eugeny/2603399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DIFFUSE LIGHT | |
float4x4 wvp : WorldViewProjection; | |
float4x4 world : World; | |
float AmbientIntensity = 0.01; | |
float4 AmbientColor : AMBIENT = float4(1,1,1,1); | |
float3 LightDirection : Direction = float3(100,-100,100); | |
texture ColorMap : Diffuse; | |
sampler ColorMapSampler = sampler_state | |
{ | |
texture = <ColorMap>; | |
MipFilter = Anisotropic; | |
MinFilter = Anisotropic; | |
MagFilter = Anisotropic; | |
}; | |
struct VS_IN | |
{ | |
float4 Position : POSITION; | |
float2 TexCoord : TEXCOORD0; | |
float3 Normal : NORMAL; | |
}; | |
struct VS_OUT | |
{ | |
float4 Position : POSITION; | |
float2 TexCoord : TEXCOORD0; | |
float3 Light : TEXCOORD1; | |
float3 Normal : TEXCOORD2; | |
}; | |
struct PS_OUT | |
{ | |
float4 Color : COLOR; | |
}; | |
VS_OUT VS_ColorMap(VS_IN input) | |
{ | |
VS_OUT output = (VS_OUT)0; | |
output.Position = mul(input.Position,wvp); | |
output.Light = LightDirection; | |
output.TexCoord = input.TexCoord; | |
output.Normal = mul(input.Normal,world); | |
return output; | |
} | |
PS_OUT PS_ColorMap(VS_OUT input) | |
{ | |
PS_OUT output = (PS_OUT)0; | |
float3 LightDir = normalize(input.Light); | |
float Diffuse = saturate(dot(LightDir,normalize(input.Normal))); | |
float4 texCol = tex2D(ColorMapSampler,input.TexCoord); | |
float4 Ambient = AmbientIntensity * AmbientColor; | |
texCol *= Diffuse; | |
output.Color = Ambient + texCol; | |
return output; | |
} | |
technique def | |
{ | |
pass p0 | |
{ | |
VertexShader = compile vs_1_1 VS_ColorMap(); | |
PixelShader = compile ps_2_0 PS_ColorMap(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment