//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   vsa shaderdump19/GDECAL.pso /Fcshaderdump19/GDECAL.pso.dis
//
//
// Parameters:
//
sampler2D DecalMap : register(s1);
float4 PSDecalOffsets : register(c15);

texture2D cust_texDecalNormal < string filename = "effects\blooddecal_n.dds"; >;
sampler2D cust_samplerDecalNormal : register(s2) = sampler_state
{
    Texture = <cust_texDecalNormal>;
    AddressU  = WRAP;
    AddressV  = WRAP;
    MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};

float4 oblv_SunDirection : register(c23);
float4 glob_sunColor : register(c24);
float4 glob_fogColor : register(c25);

//
//
// Registers:
//
//   Name           Reg   Size
//   -------------- ----- ----
//   PSDecalOffsets const_15      1
//   DecalMap       texture_1       1
//


// Structures:

struct VS_OUTPUT {
    float3 DecalUV_0 : TEXCOORD0;
};

struct PS_OUTPUT {
    float4 color_0 : COLOR0;
};

// Code:

PS_OUTPUT main(VS_OUTPUT IN) {
    PS_OUTPUT OUT;

    float4 r0;
    float4 r1;
	float3 norm;
	float3 light;
	
    r1 = tex2D(DecalMap, (PSDecalOffsets.yw * saturate(IN.DecalUV_0.xy)) + PSDecalOffsets.xz);
    r0.rgb = r1.rgb;
    r0.a = IN.DecalUV_0.z;
    r0 = r0 * IN.DecalUV_0.z;
	norm = tex2D(cust_samplerDecalNormal, (PSDecalOffsets.yw * saturate(IN.DecalUV_0.xy)) + PSDecalOffsets.xz).rgb;
	norm = normalize(norm) * 0.5 + 0.5;
	norm.xyz = norm.rgb * 2 - 1;
	light = glob_fogColor.rgb + glob_sunColor.rgb * dot(oblv_SunDirection.xyz,norm.xyz);
	
    OUT.color_0.a = r1.a * r0.a;
    OUT.color_0.rgb = r0.rgb * light;
    return OUT;
};

// approximately 9 instruction slots used (1 texture, 8 arithmetic)
