#version 410 core uniform sampler2D textureSampler; uniform vec3 lightDir; uniform vec3 cameraPos; uniform vec3 objectColor; in vec3 fragPos; in vec3 interpNormal; in vec2 interpTexCoord; float near = 0.01f; float far = 100.0f; float linearizeDepth(float depth) { return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near)); } float logisticDepth(float depth, float steepness, float offset) { float zVal = linearizeDepth(depth); return (1 / (1 + exp(-steepness * (zVal - offset)))); } void main() { float depth = logisticDepth(gl_FragCoord.z, 0.1f, 3.0f); 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); gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0) * (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f); }