grk464933/cw 6/shaders/shader_earth.frag
2024-02-02 11:19:35 +01:00

28 lines
612 B
GLSL

#version 430 core
float AMBIENT = 0.1;
uniform vec3 color;
uniform vec3 lightPos;
uniform sampler2D colorTexture;
uniform sampler2D clouds;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 fragTexCoord;
out vec4 outColor;
void main()
{
vec4 textureColor = texture2D(colorTexture, fragTexCoord);
vec4 cloudsColor = texture2D(clouds, fragTexCoord);
vec3 texcolor = mix(textureColor.rgb, vec3(0.0), cloudsColor.r);
vec3 lightDir = normalize(lightPos-worldPos);
vec3 normal = normalize(vecNormal);
float diffuse=max(0.0, dot(normal,lightDir));
outColor = vec4(texcolor * min(1, AMBIENT + diffuse), 1.0);
}