58 lines
1.3 KiB
GLSL
58 lines
1.3 KiB
GLSL
#version 330 core
|
|
|
|
in vec3 normal;
|
|
in vec3 fragmentPosition;
|
|
in vec2 textureCoordinate;
|
|
|
|
flat in mat3 TBN;
|
|
|
|
|
|
uniform float shininess;
|
|
|
|
uniform vec4 ambientLight;
|
|
uniform vec3 lightPosition;
|
|
uniform vec4 lightColor;
|
|
|
|
uniform sampler2D day;
|
|
uniform sampler2D night;
|
|
uniform sampler2D clouds;
|
|
uniform sampler2D ocean;
|
|
uniform sampler2D normalMap;
|
|
|
|
|
|
float emissionStrength = 0.0;
|
|
|
|
|
|
void main() {
|
|
vec4 color = vec4(texture(day, textureCoordinate).rgb, 1.0);
|
|
|
|
float nightBrightness = texture(night, textureCoordinate).r;
|
|
vec4 nightColor = vec4(nightBrightness, nightBrightness * 0.7, nightBrightness * 0.5, 1.0);
|
|
float shininessMultiplier = texture(ocean, textureCoordinate).r;
|
|
|
|
vec4 cloudColor = texture(clouds, textureCoordinate).rgba;
|
|
|
|
vec3 norm = normalize(normal);
|
|
|
|
vec3 lightDir = normalize(lightPosition - fragmentPosition);
|
|
vec3 eyeDir = (-normalize(fragmentPosition));
|
|
|
|
float diff = max(dot(norm, lightDir), 0.0);
|
|
|
|
vec3 halfway = (lightDir + eyeDir) / length(lightDir + eyeDir);
|
|
float specular = pow(max(dot(halfway, norm), 0.0), shininess) * shininessMultiplier;
|
|
|
|
|
|
gl_FragColor =
|
|
// EMISSION
|
|
color * emissionStrength +
|
|
|
|
// // AMBIENT
|
|
ambientLight * color +
|
|
|
|
// DIFFUSION
|
|
mix(nightColor * (vec4(1,1,1,1) - cloudColor) + (cloudColor * ambientLight), color + cloudColor, diff) +
|
|
|
|
// SPECULAR
|
|
specular * lightColor * color;
|
|
} |