2019-08-06 02:50:49 +00:00
|
|
|
#version 330 core
|
|
|
|
|
|
|
|
#include <globals.glsl>
|
2019-08-15 01:35:56 +00:00
|
|
|
#include <random.glsl>
|
2019-08-06 02:50:49 +00:00
|
|
|
|
|
|
|
in vec3 f_pos;
|
|
|
|
flat in vec3 f_norm;
|
|
|
|
in vec3 f_col;
|
|
|
|
in float f_light;
|
|
|
|
|
|
|
|
layout (std140)
|
|
|
|
uniform u_locals {
|
|
|
|
vec3 model_offs;
|
|
|
|
};
|
|
|
|
|
|
|
|
out vec4 tgt_color;
|
|
|
|
|
|
|
|
#include <sky.glsl>
|
|
|
|
#include <light.glsl>
|
|
|
|
|
|
|
|
void main() {
|
2019-08-16 14:58:14 +00:00
|
|
|
vec3 warped_norm = normalize(f_norm + smooth_rand(f_pos * 0.35, tick.x) * 0.2);
|
|
|
|
|
|
|
|
vec3 light = get_sun_diffuse(warped_norm, time_of_day.x) * f_light + light_at(f_pos, warped_norm);
|
2019-08-16 11:38:59 +00:00
|
|
|
vec3 surf_color = f_col * light;
|
2019-08-06 02:50:49 +00:00
|
|
|
|
2019-08-16 14:58:14 +00:00
|
|
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
2019-08-06 02:50:49 +00:00
|
|
|
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x);
|
2019-08-14 21:28:37 +00:00
|
|
|
|
2019-08-16 10:31:51 +00:00
|
|
|
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
2019-08-16 14:58:14 +00:00
|
|
|
vec3 reflect_color = get_sky_color(reflect(cam_to_frag, warped_norm), time_of_day.x) * f_light;
|
|
|
|
float passthrough = dot(faceforward(warped_norm, warped_norm, cam_to_frag), -cam_to_frag);
|
2019-08-14 21:28:37 +00:00
|
|
|
|
2019-08-16 14:58:14 +00:00
|
|
|
vec4 color = mix(vec4(reflect_color, 1.0), vec4(surf_color, 0.8 / (1.0 + light * 2.0)), passthrough);
|
2019-08-06 02:50:49 +00:00
|
|
|
|
2019-08-16 14:58:14 +00:00
|
|
|
tgt_color = mix(color, vec4(fog_color, 0.0), fog_level);
|
2019-08-06 02:50:49 +00:00
|
|
|
}
|