2019-08-06 02:50:49 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2020-05-15 12:22:17 +00:00
|
|
|
#include <constants.glsl>
|
|
|
|
|
|
|
|
#define LIGHTING_TYPE (LIGHTING_TYPE_TRANSMISSION | LIGHTING_TYPE_REFLECTION)
|
|
|
|
|
|
|
|
#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-08-06 02:50:49 +00:00
|
|
|
#include <globals.glsl>
|
2019-10-16 11:39:41 +00:00
|
|
|
#include <srgb.glsl>
|
2020-05-15 12:22:17 +00:00
|
|
|
#include <random.glsl>
|
2019-08-06 02:50:49 +00:00
|
|
|
|
|
|
|
in uint v_pos_norm;
|
2020-07-02 20:10:22 +00:00
|
|
|
// in uint v_col_light;
|
2019-08-06 02:50:49 +00:00
|
|
|
|
|
|
|
layout (std140)
|
|
|
|
uniform u_locals {
|
|
|
|
vec3 model_offs;
|
2020-07-02 20:10:22 +00:00
|
|
|
float load_time;
|
|
|
|
ivec4 atlas_offs;
|
2019-08-06 02:50:49 +00:00
|
|
|
};
|
|
|
|
|
2020-07-02 20:10:22 +00:00
|
|
|
// struct ShadowLocals {
|
|
|
|
// mat4 shadowMatrices;
|
|
|
|
// mat4 texture_mat;
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// layout (std140)
|
|
|
|
// uniform u_light_shadows {
|
|
|
|
// ShadowLocals shadowMats[/*MAX_LAYER_FACES*/192];
|
|
|
|
// };
|
|
|
|
|
2019-08-06 02:50:49 +00:00
|
|
|
out vec3 f_pos;
|
2019-10-16 14:05:45 +00:00
|
|
|
flat out uint f_pos_norm;
|
2020-07-02 20:10:22 +00:00
|
|
|
// out vec3 f_col;
|
|
|
|
// out float f_light;
|
|
|
|
// out vec3 light_pos[2];
|
2019-08-06 02:50:49 +00:00
|
|
|
|
2020-07-18 16:55:25 +00:00
|
|
|
const float EXTRA_NEG_Z = 65536.0/*65536.1*/;
|
2020-04-14 23:02:15 +00:00
|
|
|
|
2019-08-06 02:50:49 +00:00
|
|
|
void main() {
|
2020-07-02 20:10:22 +00:00
|
|
|
f_pos = vec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0x1FFFFu)) - vec3(0, 0, EXTRA_NEG_Z) + model_offs - focus_off.xyz;
|
|
|
|
// f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
|
|
|
|
// f_pos.z -= min(32.0, 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0));
|
|
|
|
|
|
|
|
// Small waves
|
|
|
|
// f_pos.xy += 0.01; // Avoid z-fighting
|
|
|
|
// f_pos.x += 0.1 * sin(tick.x / 60 * hash(vec4(f_pos.xyz, 1.0)));
|
|
|
|
// f_pos.y += 0.1 * sin(tick.x / 60 * hash(vec4(f_pos.xyz, 2.0)));
|
2020-05-15 12:22:17 +00:00
|
|
|
#if (FLUID_MODE == FLUID_MODE_SHINY)
|
2020-07-02 20:10:22 +00:00
|
|
|
// f_pos.z -= 0.1 + 0.1 * (sin(tick.x/* / 60.0*/* 2.0 + f_pos.x * 2.0 + f_pos.y * 2.0) + 1.0) * 0.5;
|
2020-05-15 12:22:17 +00:00
|
|
|
#endif
|
2020-03-27 15:13:36 +00:00
|
|
|
|
2020-07-02 20:10:22 +00:00
|
|
|
/* f_col = vec3(
|
|
|
|
float((v_col_light >> 8) & 0xFFu),
|
|
|
|
float((v_col_light >> 16) & 0xFFu),
|
|
|
|
float((v_col_light >> 24) & 0xFFu)
|
2019-10-16 14:05:45 +00:00
|
|
|
) / 255.0;
|
2019-08-06 02:50:49 +00:00
|
|
|
|
2020-07-02 20:10:22 +00:00
|
|
|
f_light = float(v_col_light & 0xFFu) / 255.0; */
|
|
|
|
/* for (uint i = 0u; i < light_shadow_count.z; ++i) {
|
|
|
|
light_pos[i] = vec3(shadowMats[i].texture_mat * vec4(f_pos, 1.0));
|
|
|
|
} */
|
2019-08-06 02:50:49 +00:00
|
|
|
|
2020-07-02 20:10:22 +00:00
|
|
|
f_pos_norm = v_pos_norm;
|
2019-10-16 14:05:45 +00:00
|
|
|
|
2019-08-06 02:50:49 +00:00
|
|
|
gl_Position =
|
2020-07-02 20:10:22 +00:00
|
|
|
all_mat *
|
|
|
|
vec4(f_pos, 1);
|
2020-05-19 15:22:06 +00:00
|
|
|
// gl_Position.z = -gl_Position.z / gl_Position.w;
|
2020-07-02 20:10:22 +00:00
|
|
|
// gl_Position.z = -gl_Position.z / 100.0;
|
|
|
|
// gl_Position.z = -1000.0 / (gl_Position.z + 10000.0);
|
2019-08-14 21:28:37 +00:00
|
|
|
}
|