28 lines
835 B
GLSL
28 lines
835 B
GLSL
#version 410 core
|
|
|
|
uniform sampler2D textureSampler;
|
|
//uniform vec3 lightDir;
|
|
uniform vec3 lightPos;
|
|
uniform vec3 cameraPos;
|
|
uniform vec3 objectColor;
|
|
|
|
in vec3 fragPos;
|
|
in vec3 interpNormal;
|
|
in vec2 interpTexCoord;
|
|
|
|
|
|
void main()
|
|
{
|
|
vec3 lightDir = normalize(lightPos-fragPos);
|
|
vec3 V = normalize(cameraPos-fragPos);
|
|
vec2 modifiedTexCoord = vec2(interpTexCoord.x, 1.0 - interpTexCoord.y); // Poprawka dla tekstur Ziemi, ktore bez tego wyswietlaja sie 'do gory nogami'
|
|
vec3 color = texture2D(textureSampler, modifiedTexCoord).rgb;
|
|
vec3 normal = normalize(interpNormal);
|
|
float diffuse = max(0,dot(normal,normalize(lightDir)));
|
|
vec3 R = reflect(-normalize(lightDir),normal);
|
|
float ambient = 0.2;
|
|
float specular = pow(max(0,dot(R,V)),1000);
|
|
gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0);
|
|
|
|
}
|