//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   psa shaderdump19/SLS2081.pso /Fcshaderdump19/SLS2081.pso.dis
//
//
// Parameters:
//
sampler2D BaseMap : register(s0);
float4 PSLightColor[4] : register(c2);
sampler2D ShadowMap : register(s6);
//
//
// Registers:
//
//   Name         Reg   Size
//   ------------ ----- ----
//   PSLightColor[0] const_2        1
//   BaseMap      texture_0       1
//   ShadowMap    texture_6       1
//


// Structures:

struct VS_OUTPUT {
    float2 BaseUV : TEXCOORD0;
    float3 texcoord_6 : TEXCOORD6_centroid;
    float4 texcoord_1 : TEXCOORD1_centroid;
    float4 texcoord_2 : TEXCOORD2_centroid;
    float4 texcoord_3 : TEXCOORD3;
};

struct PS_OUTPUT {
    float4 color_0 : COLOR0;
};

// Code:

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	weight(v)		dot(v, 1)
#define	sqr(v)			((v) * (v))

    const float4 const_3 = {1, -1, 0, 1};
    const float4 const_4 = {-0.02, 0.02, -0.03, 0.03};
    const float4 const_5 = {-0.01, 0.01, -0.015, 0.015};
	const float bias = -0.000195312503;
	
    float q1;
	float q2;
    float q4;
    float q5;
    float q6;
	float r0;
    float r1;
    float r2;
    float r3;
    float r4;
    float r5;
    float r6;
    float r7;
	float r8;
	float r9;
	float2 q3;
	float2 SCoord0;
	float2 SCoord1;
	
    q1 = saturate(length(IN.texcoord_6.xyz - IN.texcoord_2.xyz) / (IN.texcoord_2.w * 0.5));
    SCoord0.xy = compress(IN.texcoord_1.xy / IN.texcoord_1.w);
    SCoord1.x = saturate(SCoord0.x >= 0.0 ? SCoord0.x : 0);
    SCoord1.y = saturate(1 >= SCoord0.y ? (1 - SCoord0.y) : 0);
	
	q2 = IN.texcoord_1.z / IN.texcoord_2.w;
	q3.xy = (const_3.xy * SCoord0.xy) + const_3.zw;
	q4 = 1.0 / ((sqrt(q1) <= 0.0 ? 1 : (1 - sqrt(q1))) * 15);

	r0 = tex2D(ShadowMap, saturate(q3.xy - (q4 * const_4.y))).x;
	r1 = tex2D(ShadowMap, saturate(q3.xy - (q4 * const_5.y))).x;
	r2 = tex2D(ShadowMap, saturate(q3.xy - (q4 * const_4.xy))).x;
    r3 = tex2D(ShadowMap, saturate(q3.xy - (q4 * const_5.xy))).x;
    r4 = tex2D(ShadowMap, saturate(q3.xy + (q4 * const_4.xy))).x;
    r5 = tex2D(ShadowMap, saturate(q3.xy + (q4 * const_5.xy))).x;
    r6 = tex2D(ShadowMap, saturate(q3.xy + (q4 * const_4.y))).x;
    r7 = tex2D(ShadowMap, saturate(q3.xy + (q4 * const_5.y))).x;
	r8 = tex2D(ShadowMap, SCoord1.xy).x;
    r9 = tex2D(BaseMap, IN.BaseUV.xy).w;
    q5 =      ((bias - (r8 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r7 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r6 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r5 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r4 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r3 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r2 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r1 - q2)) >= 0.0 ? 0.5 : 1);
    q5 = q5 + ((bias - (r0 - q2)) >= 0.0 ? 0.5 : 1);

    q6 = 1 - ((PSLightColor[0].a * (saturate(q5 / 7) - 1)) + 1);
    OUT.color_0.a = min(min(r9, 1), q6);
    OUT.color_0.rgb = lerp(lerp(((q6 * IN.texcoord_3.z) * -PSLightColor[0].rgb) + 1, 1, sqr(q1)), 1, IN.texcoord_3.w);

    return OUT;
};

// approximately 92 instruction slots used (10 texture, 82 arithmetic)
