//////////////////////////////
// Hair Fx
//////////////////////////////
#define nrm normalize
#define sat saturate
#define dst distance
//////////////////////////////
// Matrix
//////////////////////////////
float4x4 matWorld;
float4x4 matViewProj;
float4x4 matWorldViewProj;
float4 vecViewPos;
float4 vecTime;
//////////////////////////////
// Lighting
//////////////////////////////
float4 vecSunDir;
float4 vecAmbient;
float4 vecLightColor[8];
float4 vecLightPos[8];
int iLights;
//////////////////////////////
// Coloring
//////////////////////////////
//////////////////////////////
// Tweakables
//////////////////////////////
float vecSkill1;
float4 vecSkill41;
float4 vecSkill45;
//////////////////////////////
// Texture Reference
//////////////////////////////
texture entSkin1;
texture entSkin2;
sampler SKIN = sampler_state {texture = <entSkin1>;};
sampler FUR = sampler_state {texture = <entSkin2>;};
//////////////////////////////
// Data Structs
//////////////////////////////
//////////////////////////////
// Additonal Functions
//////////////////////////////
//////////////////////////////
// Vertex Shader
//////////////////////////////
float4 VS ( uniform float O,
in float4 P : POSITION,
in float2 T : TEXCOORD0,
in float3 N : NORMAL,
out float4 tex : TEXCOORD0,
out float3 light : TEXCOORD1) : POSITION
{
tex.xy = T;
tex.z = pow(O / 30,2);
tex.w = 0.5 - (dst(mul(P,matWorld),vecViewPos) > vecSkill1);
P.xyz += vecSkill41.x * O * N + tex.z;
float4 pos = mul(P,matWorld);
//pos.y -= tex.z * vecSkill45.x;
pos.z -= tex.z * vecSkill45.x;
light = vecAmbient;
for (int L=0; L<iLights; L++)
light += (1 - sat(length(pos.xyz - vecLightPos[L].xyz) / vecLightPos[L].w))
* sat(dot(mul(N,matWorld),-nrm(pos - vecLightPos[L])))
* vecLightColor[L] * 10;
return mul(pos,matViewProj);
}
//////////////////////////////
// Pixle Shader
//////////////////////////////
float4 PS ( in float4 tex : TEXCOORD0,
in float3 light : TEXCOORD1) : COLOR
{
clip(tex.w);
float3 skin = tex2D(SKIN,tex.xy);
float len = tex2D(FUR,tex.xy).a;
float4 fur = tex2D(FUR,tex.xy * vecSkill41.w);
fur.a = (fur.rgb * vecSkill41.z - pow(tex.z,4)) * len;
clip (fur.a);
fur.rgb = lerp(fur,skin,vecSkill41.y);
fur.rgb *= light;
return fur;
}
///////////////////////////////////////
/// TECHNIQUES
////////////////////////
technique t
{
pass p
{
ZEnable = true;
ZWriteEnable = true;
AlphaBlendEnable =false;
AlphaTestEnable = TRUE;
VertexShader = compile vs_2_0 VS(1);
PixelShader = compile ps_2_0 PS();
}
pass p {VertexShader = compile vs_2_0 VS(2);PixelShader = compile ps_2_0 PS();}
pass p {VertexShader = compile vs_2_0 VS(3);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(4);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(5);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(6);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(7);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(8);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(9);PixelShader = compile ps_2_0 PS();}
// pass p {VertexShader = compile vs_2_0 VS(10);PixelShader = compile ps_2_0 PS();}
}