#include "includes.cg.px"
#include "CustomizeOutColor.cg.px"

float u_zeRedBoost = 0.5;
float u_zeGreenBoost = 0.5;
float u_zeBlueBoost = 0.5;
float2 u_uvDecal = float2(0,0);

sampler2D u_zobTexture;

void TexPixel1(in sampler2D inTexture, in float2 inUVs, out float4 outClr)
{
outClr = tex2D(inTexture, inUVs);
}

#define MultiplyColor2(c1, c2, r) r = c1 * c2;

void TexPixel3(in sampler2D inTexture, in float2 inUVs, out float4 outClr)
{
outClr = tex2D(inTexture, inUVs);
}

void TexPixel4(in sampler2D inTexture, in float2 inUVs, out float4 outClr)
{
outClr = tex2D(inTexture, inUVs);
}

void MaterialPixelShader(in sampler2D inTexture, in float2 inUVs, in float3 inWorldPos, in float3 inNormal3, in float4 inColor, in sampler2D normalTexture, in sampler2D specularTexture, in float time, in float HeroDistance, out float4 outDiffuse, out float4 outNormal, out float4 outSpec)
{
float4 TexPixel1_outClr;
TexPixel1(inTexture, inUVs, TexPixel1_outClr);

float4 MultiplyColor2_R;
MultiplyColor2(inColor, TexPixel1_outClr, MultiplyColor2_R);

float4 TexPixel3_outClr;
TexPixel3(normalTexture, inUVs, TexPixel3_outClr);

float4 TexPixel4_outClr;
TexPixel4(specularTexture, inUVs, TexPixel4_outClr);

outDiffuse = MultiplyColor2_R;
outNormal = TexPixel3_outClr;
outSpec = TexPixel4_outClr;
}


void main_f(
	float2 inTexCoord:TEXCOORD0
	, float4 oWorldPosition:TEXCOORD1
	, float4 inNormal:TEXCOORD2
	, float4 inColor:TEXCOORD3
	, float3 inTangent:TEXCOORD4
	, float2 inTexCoord2:TEXCOORD5
	, out float4 outColor:COLOR
	, uniform sampler2D Texture0
	, uniform float time
	, uniform float HeroDistance
	)
{
float4 userColor;
float2 inUVs = inTexCoord.xy + u_uvDecal;
sampler2D inTexture = u_zobTexture;
float3 inWorldPos = oWorldPosition.xyz;
float3 inNormal3 = inNormal.xyz;
float4 userNormal;
float4 userSpec;
MaterialPixelShader(inTexture, inUVs, inWorldPos, inNormal3, inColor, normalTexture, specularTexture, time, HeroDistance, userColor
//#ifdef SH_NORMALMAP
, userNormal
//#endif
//#ifdef SH_SPECULAR
, userSpec
//#endif
);
ComputeLightingParams params;
params.oWorldPosition = oWorldPosition;
params.inNormal = inNormal;
params.userColor = userColor;
#ifdef SH_NORMALMAP
params.userNormal = userNormal;
params.tangent = inTangent.xyz;
#endif

params.uvs = inUVs;
params.uv2s = inTexCoord2.xy;

#ifdef SH_SPECULAR
params.userSpec = userSpec;
#endif
outColor = ComputeLightning(params);
outColor = ComputeFog(outColor, oWorldPosition);

outColor.r += u_zeRedBoost;
outColor.g += u_zeGreenBoost;
outColor.b += u_zeBlueBoost;

#ifdef SH_CUSTOMIZEOUTCLR
outColor = UserCustomizeOutColor(outColor);
#endif // SH_CUSTOMIZEOUTCLR

}
