//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   vsa shaderdump19/PAR2016.pso /Fcshaderdump19/PAR2016.pso.dis
//
//
// Parameters:
//
float4 AmbientColor : register(c1);
sampler2D AttenuationMap : register(s4);
sampler2D BaseMap : register(s0);
sampler2D NormalMap : register(s1);
float4 PSLightColor[4] : register(c2);

float4 TESR_ShadowData : register(c8);

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




//
//
// Registers:
//
//   Name           Reg   Size
//   -------------- ----- ----
//   AmbientColor   const_1       1
//   PSLightColor[0]   const_2        1
//   PSLightColor[1]   const_3        1
//   PSLightColor[2]   const_4        1
//   BaseMap        texture_0       1
//   NormalMap      texture_1       1
//   AttenuationMap texture_4       1
//


// Structures:

struct VS_OUTPUT {
    float4 BaseUV : TEXCOORD0;
    float4 texcoord_1 : TEXCOORD1_centroid;
    float4 texcoord_2 : TEXCOORD2_centroid;
    float3 texcoord_3 : TEXCOORD3_centroid;
    float4 texcoord_4 : TEXCOORD4;
    float4 texcoord_5 : TEXCOORD5;
    float3 texcoord_7 : TEXCOORD7_centroid;  
    float4 texcoord_6 : TEXCOORD6;
};

struct PS_OUTPUT {
    float4 color_0 : COLOR0;
};

// Code:
#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	uvtile(w)		(((w) * 0.04) - 0.02)
#define	shade(n, l)		max(dot(n, l), 0)
#define	shades(n, l)		saturate(dot(n, l))

    float1 att0;
    float1 att1;
    float1 att4;
    float1 att5;
    float3 q17;
    float3 q2;
    float3 q3;
    float4 r0;
    float4 r4;
    float2 uv12;
                                  
    
      float4 ShadowNear = IN.texcoord_6;
    float4 ShadowFar = float4(IN.BaseUV.zw, IN.texcoord_1.w, IN.texcoord_2.w);     
    float Shadow = GetLightAmount(ShadowNear, ShadowFar);
    
    r0.xyzw = tex2D(BaseMap, IN.BaseUV.xy);
    att5.x = tex2D(AttenuationMap, IN.texcoord_5.zw);
    att4.x = tex2D(AttenuationMap, IN.texcoord_5.xy);
    att1.x = tex2D(AttenuationMap, IN.texcoord_4.zw);
    att0.x = tex2D(AttenuationMap, IN.texcoord_4.xy);
    uv12.xy = (uvtile(r0.w) * (IN.texcoord_7.xy / length(IN.texcoord_7.xyz))) + IN.BaseUV.xy;
    r4.xyzw = tex2D(NormalMap, uv12.xy);
    r0.w = saturate((1 - att4.x) - att5.x);
    q2.xyz = normalize(expand(r4.xyz));
    r0.xyz = shades(q2.xyz, normalize(IN.texcoord_3.xyz)) * PSLightColor[2].rgb;
    q3.xyz = saturate((1 - att0.x) - att1.x) * (shades(q2.xyz, normalize(IN.texcoord_2.xyz)) * PSLightColor[1].rgb);
    q17.xyz = (r0.w * r0.xyz) + ((shades(q2.xyz, IN.texcoord_1.xyz) * PSLightColor[0].rgb * Shadow) + q3.xyz);
    OUT.color_0.a = 1;
    OUT.color_0.rgb = q17.xyz + AmbientColor.rgb;

    return OUT;
};

// approximately 41 instruction slots used (6 texture, 35 arithmetic)
