I have a 3D scene with only one sphere in it and I have two textures - one for the night, and one for the day of this planet. In addition I have the a lightSource at (15,15,15) in my scene. For each vertex on the sphere I also have the normal.
Now I want to blend between the two texture so that the fading between day and night seems to be realistic. Therefore I calculate the angle between the normal and the light using dot-product, but with this approach I get hard crossover if I check if the angle is > 0 (which will be the dayside). I need to mix the textures based on the angle, that it is a soft crossover.
Can anyone help me how I can mix the textures? My code so far:
float angle = dot(L,N);
vec4 texture = texture2D(day, textureCoord);
texture = texture2D(night,textureCoord) * (1-angle) + texture * angle;
vec4 light = vec4(ambientTerm + diffuseTerm + specularTerm , 1);
if(angle > 0) {
color = light * texture;
} else if(angle >= -0.25) {
color = texture2D(night,textureCoord)*(angle-1) + texture * (angle);
} else if( angle < -0.25) {
color = texture2D(night,textureCoord);
}