grafika-projekt/cw 9/shaders/shader_5_1_earth.frag
Szymon Bartanowicz 27aa9b51ea init
2023-02-14 22:54:46 +01:00

25 lines
635 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 vertTexCoord;
out vec4 outColor;
void main()
{
vec4 cloudsColor = texture2D(clouds, vec2(vertTexCoord.x, -vertTexCoord.y));
vec4 textureColor = texture2D(colorTexture, vec2(vertTexCoord.x, -vertTexCoord.y));
vec3 lightDir = normalize(lightPos-worldPos);
vec3 normal = normalize(vecNormal);
float diffuse=max(0,dot(normal,lightDir));
outColor = vec4(mix(textureColor.xyz, vec3(1.0, 1.0, 1.0), cloudsColor.r)*min(1,AMBIENT+diffuse), 1.0);
}