#define sat saturate
#define dst distance
#define vlc vecLightColor
#define vlp vecLightPos
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecLightColor[8];
float4 vecLightPos[8];
int iLights;
texture entSkin1;
texture entSkin2;
sampler SKIN = sampler_state { texture = <entSkin1>;};
sampler LIGHT = sampler_state { texture = <entSkin2>;};
float4 VS ( in float4 P : position,
in float2 T1 : texcoord0,
in float2 T2 : texcoord1,
out float4 tex : texcoord0,
out float3 pos : texcoord1) : position {
tex.xy = T1;
tex.zw = T2;
pos = mul(P,matWorld).xyz;
return mul(P,matWorldViewProj);}
float4 PS ( in float4 tex : texcoord0,
in float3 pos : texcoord1) : color {
float4 color = tex2D(SKIN,tex.xy);
float4 L = 0;
for (int i=0; i<iLights; i++) L += vlc[i] * sat((vlp[i].w - dst(vlp[i].xyz,pos)) / vlp[i].w);
color = lerp (color,color * (tex2D(LIGHT,tex.zw) + L),color.a);
return color;}
technique t{ pass p{
zWriteEnable = 1;
AlphaBlendEnable = 0;
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_3_0 PS(); }}