Grafika2023/PlanetCreator/cw 6/shaders/shader_5_1_tex.frag
2024-01-11 17:57:31 +01:00

24 lines
548 B
GLSL

#version 430 core
float AMBIENT = 0.1;
uniform vec3 color;
uniform vec3 lightPos;
uniform sampler2D colorTexture;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 texCoord;
out vec4 outColor;
vec3 textureColorTemp;
void main()
{
vec3 lightDir = normalize(lightPos-worldPos);
vec3 normal = normalize(vecNormal);
float diffuse=max(0,dot(normal,lightDir));
vec4 textureColor = texture2D(colorTexture,texCoord);
textureColorTemp=vec3(textureColor.r,textureColor.g,textureColor.b);
outColor = vec4(textureColorTemp*min(1,AMBIENT+diffuse), 1.0);
}