//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   vsa shaderdump19/SKIN2008.pso /Fcshaderdump19/SKIN2008.pso.dis
//
//
// Parameters:
//
sampler2D AttenuationMap : register(s3);
sampler2D NormalMap : register(s0);
float4 PSLightColor[4] : register(c2);
float4 TESR_SkinData : register(c8);
float4 TESR_SkinColor : register(c9);

float4 TESR_ShadowData : register(c17);

sampler2D TESR_ShadowMapBufferNear : register(s8) = sampler_state { ADDRESSU = CLAMP; ADDRESSV = CLAMP; MAGFILTER = LINEAR; MINFILTER = LINEAR; MIPFILTER = LINEAR; };
sampler2D TESR_ShadowMapBufferFar : register(s9) = sampler_state { ADDRESSU = CLAMP; ADDRESSV = CLAMP; MAGFILTER = LINEAR; MINFILTER = LINEAR; MIPFILTER = LINEAR; };

//
//
// Registers:
//
//   Name           Reg   Size
//   -------------- ----- ----
//   PSLightColor[0]   const_2        1
//   PSLightColor[1]   const_3        1
//   NormalMap      texture_0       1
//   AttenuationMap texture_3       1
//


// Structures:

struct VS_OUTPUT {
    float2 NormalUV : TEXCOORD0;
    float3 texcoord_1 : TEXCOORD1_centroid;
    float3 texcoord_2 : TEXCOORD2_centroid;
    float4 texcoord_4 : TEXCOORD4;
    float4 texcoord_5 : TEXCOORD5;
    float3 texcoord_7 : TEXCOORD7_centroid;  
    
    float4 texcoord_6 : TEXCOORD6;
	  float4 texcoord_8 : TEXCOORD8;
    
};

struct PS_OUTPUT {
    float4 color_0 : COLOR0;
};

// Code:
#include "..\Includes\Skin.hlsl"
#include "..\Includes\Shadow.hlsl"

PS_OUTPUT main(VS_OUTPUT IN) {
    PS_OUTPUT OUT;

#define	expand(v)		(((v) - 0.5) / 0.5)
#define	compress(v)		(((v) * 0.5) + 0.5)
#define	shade(n, l)		max(dot(n, l), 0)
#define	shades(n, l)		saturate(dot(n, l))
#define	weight(v)		dot(v, 1)
#define	sqr(v)			((v) * (v))

    float1 att11;
    float1 att6;
    float1 att7;
    float1 att8;
   
    float3 q12;
    float3 q13;
  
    float1 q4;
    float1 q5;
    float3 q9;
    float3 norm;            
    float3 cam;
    float1 shadow;      
    
    shadow = GetLightAmount(IN.texcoord_6, IN.texcoord_8);
    cam = normalize(IN.texcoord_7.xyz);
    
    
    norm = normalize(expand(tex2D(NormalMap, IN.NormalUV.xy).xyz));
    att8.x = tex2D(AttenuationMap, IN.texcoord_5.zw);
    att6.x = tex2D(AttenuationMap, IN.texcoord_5.xy);
    att7.x = tex2D(AttenuationMap, IN.texcoord_4.zw);
    att11.x = tex2D(AttenuationMap, IN.texcoord_4.xy);
   
    q4.x = 1 - shade(norm.xyz, cam);
    q5.x = q4.x * sqr(q4.x);     
    
    q9.xyz = (shade(norm.xyz, normalize(IN.texcoord_2.xyz)) * PSLightColor[1].rgb) + ((q5.x * PSLightColor[1].rgb) * 0.5);
    q12.xyz = (shade(norm.xyz, normalize(IN.texcoord_1.xyz)) * PSLightColor[0].rgb) + ((q5.x * PSLightColor[0].rgb) * 0.5);   
   
  
    q9 = Skin(q9, PSLightColor[1].rgb, cam, IN.texcoord_2.xyz, norm);
    q12 = shadow * Skin(q12, PSLightColor[0].rgb, cam, IN.texcoord_1.xyz, norm); 
    
    
    q13.xyz = (saturate((1 - att11.x) - att7.x) * q12.xyz) + (saturate((1 - att6.x) - att8.x) * q9.xyz);
    OUT.color_0.a = 1;
    OUT.color_0.rgb = q13.xyz;

    return OUT;
};

// approximately 46 instruction slots used (5 texture, 41 arithmetic)
