2023-10-28 15:53:35 +00:00
|
|
|
#version 440 core
|
2020-12-08 18:02:08 +00:00
|
|
|
// #extension ARB_texture_storage : enable
|
|
|
|
|
|
|
|
#include <constants.glsl>
|
|
|
|
|
|
|
|
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION
|
|
|
|
|
|
|
|
#define LIGHTING_REFLECTION_KIND LIGHTING_REFLECTION_KIND_GLOSSY
|
|
|
|
|
2022-10-23 19:03:21 +00:00
|
|
|
#if (FLUID_MODE == FLUID_MODE_LOW)
|
2020-12-08 18:02:08 +00:00
|
|
|
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_IMPORTANCE
|
2022-09-23 14:04:47 +00:00
|
|
|
#elif (FLUID_MODE >= FLUID_MODE_MEDIUM)
|
2020-12-08 18:02:08 +00:00
|
|
|
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_RADIANCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LIGHTING_DISTRIBUTION_SCHEME LIGHTING_DISTRIBUTION_SCHEME_MICROFACET
|
|
|
|
|
|
|
|
#define LIGHTING_DISTRIBUTION LIGHTING_DISTRIBUTION_BECKMANN
|
|
|
|
|
|
|
|
// Currently, we only need globals for focus_off.
|
|
|
|
#include <globals.glsl>
|
|
|
|
|
|
|
|
/* Accurate packed shadow maps for many lights at once!
|
|
|
|
*
|
|
|
|
* Ideally, we would just write to a bitmask...
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
|
2020-12-15 20:02:58 +00:00
|
|
|
layout(location = 0) in uint v_pos_norm;
|
|
|
|
// layout(location = 1) in uint v_atlas_pos;
|
2020-12-08 18:02:08 +00:00
|
|
|
// in uint v_col_light;
|
|
|
|
// in vec4 v_pos;
|
|
|
|
|
|
|
|
// Light projection matrices.
|
|
|
|
layout (std140, set = 1, binding = 0)
|
|
|
|
uniform u_locals {
|
2023-05-05 18:13:49 +00:00
|
|
|
mat4 model_mat;
|
2020-12-08 18:02:08 +00:00
|
|
|
ivec4 atlas_offs;
|
2023-02-22 08:52:40 +00:00
|
|
|
float load_time;
|
2020-12-08 18:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// out vec4 shadowMapCoord;
|
|
|
|
|
2022-01-08 23:04:35 +00:00
|
|
|
const float EXTRA_NEG_Z = 32768.0;
|
2020-12-08 18:02:08 +00:00
|
|
|
|
|
|
|
layout( push_constant ) uniform PointLightMatrix {
|
2020-12-13 04:01:07 +00:00
|
|
|
mat4 lightShadowMatrix;
|
2020-12-08 18:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void main() {
|
2022-01-08 23:04:35 +00:00
|
|
|
vec3 f_chunk_pos = vec3(v_pos_norm & 0x3Fu, (v_pos_norm >> 6) & 0x3Fu, float((v_pos_norm >> 12) & 0xFFFFu) - EXTRA_NEG_Z);
|
2023-02-22 10:32:21 +00:00
|
|
|
vec3 f_pos = (model_mat * vec4(f_chunk_pos, 1.0)).xyz - focus_off.xyz;
|
2020-12-08 18:02:08 +00:00
|
|
|
// f_pos = v_pos;
|
|
|
|
|
|
|
|
// gl_Position = /*all_mat * */vec4(f_pos/*, 1.0*/, /*float(((f_pos_norm >> 29) & 0x7u) ^ 0x1)*//*uintBitsToFloat(v_pos_norm)*/1.0);
|
|
|
|
// shadowMapCoord = lights[gl_InstanceID].light_pos * gl_Vertex;
|
|
|
|
// vec4(v_pos, 0.0, 1.0);
|
|
|
|
gl_Position = lightShadowMatrix * vec4(f_pos, 1.0);
|
|
|
|
}
|