
// ------- UNIFORMS (SHADER CONSTS) -------
Texture2D	u_sTexture0; // Earth lights
SamplerState SampleType0;

vec4		u_vAmbientColor;

vec3		u_vNormalizedLightDir;
float		u_fEffectsInterpolation;

// ------- INTERPOLATORS (SHADER INPUTS) -------
struct PIn
{
	vec4	v_vPosition: SV_POSITION;
	vec2	v_vTex0UV: TEXCOORD;
	vec3	v_vNormal: NORMAL;
};

// ------- FUNCTIONS ------- 

vec4 main(PIn input): SV_TARGET
{
	vec4 colColor = u_vAmbientColor;
		
	vec3 vNormal = normalize(input.v_vNormal);
	float nDotL = dot(vNormal, u_vNormalizedLightDir); // [0.0, 1.0] away from sun, [-1.0, 0.0] toward sun
	float f = saturate(-nDotL); // 0.0 away from sun, [1.0, 0.0] toward sun
		
	vec4 colEarthLights = u_sTexture0.Sample(SampleType0, input.v_vTex0UV);

	float fLights = saturate(1.0 - f*12.0 + 0.1);
	colEarthLights *= 0.5*u_fEffectsInterpolation*fLights;
	vec4 c0 = lerp(colColor, colEarthLights, 1.0 - f - 0.04);

	return lerp(colColor, c0, u_fEffectsInterpolation);
}
