
Texture2D		u_sTexture0;
SamplerState	SampleType0;
Texture2D		u_sTexture1;
SamplerState	SampleType1;

vec3		u_vNormalizedLightDir;
vec4		u_vSpecularColor;
float		u_fSpecularPower;
float		u_fSpecularStrength;
float		u_fEffectsInterpolation;
vec4		u_vColor;

vec3		hu_vNormalizedViewDir;

struct PIn
{
    vec4	v_vPosition: SV_POSITION;
	vec2	v_vTexCoord: TEXCOORD;
	vec3	v_vNormal: NORMAL;
};

vec4 main(PIn input): SV_TARGET
{
	vec4 vTexture = u_sTexture0.Sample(SampleType0, input.v_vTexCoord);
	vec4 vColor = vTexture * u_vColor;
	vec4 vSpecular = u_sTexture1.Sample(SampleType1, input.v_vTexCoord);
	
	vec3 normal = normalize(input.v_vNormal);
	
	// Compute N.L
	float nDotL = dot(normal, u_vNormalizedLightDir);
	
	// Compute reflection vector
	vec3 reflection = (2.0 * normal * nDotL) - u_vNormalizedLightDir;
	
	// Compute R.V
	float rDotV = max(0.0, dot(reflection, hu_vNormalizedViewDir));
	
	// Compute Specular term
	vec4 specular = u_vSpecularColor * vSpecular * pow(rDotV, u_fSpecularPower);

	float f = clamp(-nDotL, 0.04, 1.0);

	vec4 c0 = f*(vColor + u_fSpecularStrength*specular);
	vec4 v = lerp(vColor, c0, u_fEffectsInterpolation);
	return v;
}

