2019-01-11 20:14:37 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2020-05-15 12:22:17 +00:00
|
|
|
#include <constants.glsl>
|
|
|
|
|
|
|
|
#define LIGHTING_TYPE LIGHTING_TYPE_TRANSMISSION
|
|
|
|
|
|
|
|
#define LIGHTING_REFLECTION_KIND LIGHTING_REFLECTION_KIND_SPECULAR
|
|
|
|
|
|
|
|
#if (FLUID_MODE == FLUID_MODE_CHEAP)
|
|
|
|
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_IMPORTANCE
|
|
|
|
#elif (FLUID_MODE == FLUID_MODE_SHINY)
|
|
|
|
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_RADIANCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LIGHTING_DISTRIBUTION_SCHEME LIGHTING_DISTRIBUTION_SCHEME_MICROFACET
|
|
|
|
|
|
|
|
#define LIGHTING_DISTRIBUTION LIGHTING_DISTRIBUTION_BECKMANN
|
|
|
|
|
2019-05-12 09:10:13 +00:00
|
|
|
#include <globals.glsl>
|
2019-06-05 15:22:06 +00:00
|
|
|
#include <sky.glsl>
|
2020-05-15 12:22:17 +00:00
|
|
|
#include <lod.glsl>
|
2019-05-12 09:10:13 +00:00
|
|
|
|
2019-01-11 20:14:37 +00:00
|
|
|
in vec3 f_pos;
|
|
|
|
|
|
|
|
layout (std140)
|
|
|
|
uniform u_locals {
|
2019-01-11 23:18:34 +00:00
|
|
|
vec4 nul;
|
2019-01-11 20:14:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
out vec4 tgt_color;
|
|
|
|
|
|
|
|
void main() {
|
2019-11-18 12:02:10 +00:00
|
|
|
vec4 _clouds;
|
2020-01-20 00:48:14 +00:00
|
|
|
|
2020-04-02 04:49:27 +00:00
|
|
|
vec3 cam_dir = normalize(f_pos - cam_pos.xyz);
|
2020-05-15 12:22:17 +00:00
|
|
|
|
|
|
|
float cam_alt = alt_at(cam_pos.xy);
|
|
|
|
// float f_alt = alt_at(f_pos.xy);
|
|
|
|
float fluid_alt = medium.x == 1u ? floor(cam_alt + 1) : view_distance.w;
|
|
|
|
// float fluid_alt = max(f_pos.z + 1, floor(f_alt));
|
|
|
|
vec3 mu = medium.x == 1u /* && f_pos.z <= fluid_alt*/ ? MU_WATER : vec3(0.0);
|
|
|
|
// vec3 sun_attenuation = compute_attenuation(wpos, -sun_dir, mu, surface_alt, wpos);
|
|
|
|
vec3 cam_attenuation = compute_attenuation(cam_pos.xyz, -cam_dir, mu, fluid_alt, /*cam_pos.z <= fluid_alt ? cam_pos.xyz : f_pos*//*f_pos*//*vec3(f_pos.xy, fluid_alt)*/cam_pos.xyz);
|
|
|
|
// vec3 cam_attenuation = compute_attenuation_point(f_pos, -view_dir, mu, fluid_alt, cam_pos.xyz);
|
|
|
|
// vec3 cam_attenuation = vec3(1.0);
|
|
|
|
|
|
|
|
|
2020-04-02 04:49:27 +00:00
|
|
|
/* vec3 world_pos = cam_pos.xyz + cam_dir * 500000.0;
|
2020-04-02 02:36:21 +00:00
|
|
|
tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, world_pos, 1.0, true, _clouds), 1.0); */
|
2020-03-27 15:13:36 +00:00
|
|
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
|
|
|
|
|
|
|
float dist = 100000.0;
|
2020-05-01 20:58:55 +00:00
|
|
|
|
|
|
|
float refractionIndex = medium.x == 1u ? 1.0 / 1.3325 : 1.0;
|
2020-04-28 18:49:03 +00:00
|
|
|
/* if (medium.x == 1u) {
|
2020-03-27 15:13:36 +00:00
|
|
|
dist = UNDERWATER_MIST_DIST;
|
2020-04-28 18:49:03 +00:00
|
|
|
} */
|
2020-04-02 04:49:27 +00:00
|
|
|
vec3 wpos = cam_pos.xyz + /*normalize(f_pos)*/cam_dir * dist;
|
2020-03-27 15:13:36 +00:00
|
|
|
|
2020-05-15 12:22:17 +00:00
|
|
|
tgt_color = vec4(cam_attenuation * get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, wpos, 1.0, true, refractionIndex, _clouds), 1.0);
|
2019-01-11 20:14:37 +00:00
|
|
|
}
|