2019-08-26 20:43:58 +00:00
|
|
|
/* clang-format off */
|
|
|
|
[vertex]
|
|
|
|
|
|
|
|
#version 450
|
|
|
|
|
|
|
|
VERSION_DEFINES
|
|
|
|
|
2019-11-05 11:01:00 +00:00
|
|
|
layout(location = 0) out vec2 uv_interp;
|
|
|
|
/* clang-format on */
|
2019-08-26 20:43:58 +00:00
|
|
|
|
|
|
|
layout(push_constant, binding = 1, std430) uniform Params {
|
|
|
|
mat3 orientation;
|
|
|
|
vec4 proj;
|
2020-03-20 00:32:19 +00:00
|
|
|
vec4 position_multiplier;
|
|
|
|
float time;
|
2020-02-11 13:01:43 +00:00
|
|
|
}
|
|
|
|
params;
|
2019-08-26 20:43:58 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2019-11-05 11:01:00 +00:00
|
|
|
vec2 base_arr[4] = vec2[](vec2(-1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(1.0, -1.0));
|
2019-08-26 20:43:58 +00:00
|
|
|
uv_interp = base_arr[gl_VertexIndex];
|
2020-03-20 00:32:19 +00:00
|
|
|
gl_Position = vec4(uv_interp, 1.0, 1.0);
|
2019-08-26 20:43:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clang-format off */
|
|
|
|
[fragment]
|
|
|
|
|
|
|
|
#version 450
|
|
|
|
|
|
|
|
VERSION_DEFINES
|
|
|
|
|
|
|
|
#define M_PI 3.14159265359
|
|
|
|
|
2019-11-05 11:01:00 +00:00
|
|
|
layout(location = 0) in vec2 uv_interp;
|
|
|
|
/* clang-format on */
|
2019-08-26 20:43:58 +00:00
|
|
|
|
|
|
|
layout(push_constant, binding = 1, std430) uniform Params {
|
|
|
|
mat3 orientation;
|
|
|
|
vec4 proj;
|
2020-03-20 00:32:19 +00:00
|
|
|
vec4 position_multiplier;
|
|
|
|
float time; //TODO consider adding vec2 screen res, and float radiance size
|
2020-02-11 13:01:43 +00:00
|
|
|
}
|
|
|
|
params;
|
2019-08-26 20:43:58 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
layout(set = 0, binding = 0) uniform sampler material_samplers[12];
|
|
|
|
|
2019-09-15 09:58:38 +00:00
|
|
|
#ifdef USE_MATERIAL_UNIFORMS
|
2020-03-20 00:32:19 +00:00
|
|
|
layout(set = 1, binding = 0, std140) uniform MaterialUniforms{
|
2019-09-15 09:58:38 +00:00
|
|
|
/* clang-format off */
|
|
|
|
|
|
|
|
MATERIAL_UNIFORMS
|
|
|
|
|
|
|
|
/* clang-format on */
|
|
|
|
} material;
|
|
|
|
#endif
|
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
layout(set = 2, binding = 0) uniform textureCube radiance;
|
|
|
|
layout(set = 2, binding = 1) uniform texture2D half_res;
|
|
|
|
layout(set = 2, binding = 2) uniform texture2D quarter_res;
|
2019-09-15 09:58:38 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
struct DirectionalLightData {
|
|
|
|
vec3 direction;
|
|
|
|
float energy;
|
|
|
|
vec3 color;
|
|
|
|
bool enabled;
|
|
|
|
};
|
2019-09-15 09:58:38 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
layout(set = 3, binding = 0, std140) uniform DirectionalLights {
|
|
|
|
DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS];
|
|
|
|
}
|
|
|
|
directional_lights;
|
2019-08-26 20:43:58 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
/* clang-format off */
|
2019-08-26 20:43:58 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
FRAGMENT_SHADER_GLOBALS
|
2019-08-26 20:43:58 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
/* clang-format on */
|
2019-08-26 20:43:58 +00:00
|
|
|
|
|
|
|
layout(location = 0) out vec4 frag_color;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
|
|
vec3 cube_normal;
|
2019-09-15 09:58:38 +00:00
|
|
|
cube_normal.z = -1.0;
|
2019-08-26 20:43:58 +00:00
|
|
|
cube_normal.x = (cube_normal.z * (-uv_interp.x - params.proj.x)) / params.proj.y;
|
|
|
|
cube_normal.y = -(cube_normal.z * (-uv_interp.y - params.proj.z)) / params.proj.w;
|
|
|
|
cube_normal = mat3(params.orientation) * cube_normal;
|
|
|
|
cube_normal.z = -cube_normal.z;
|
2020-03-20 00:32:19 +00:00
|
|
|
cube_normal = normalize(cube_normal);
|
|
|
|
|
|
|
|
vec2 uv = uv_interp * 0.5 + 0.5;
|
|
|
|
|
|
|
|
vec2 panorama_coords = vec2(atan(cube_normal.x, cube_normal.z), acos(cube_normal.y));
|
|
|
|
|
|
|
|
if (panorama_coords.x < 0.0) {
|
|
|
|
panorama_coords.x += M_PI * 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
panorama_coords /= vec2(M_PI * 2.0, M_PI);
|
2019-08-26 20:43:58 +00:00
|
|
|
|
2019-09-15 09:58:38 +00:00
|
|
|
vec3 color = vec3(0.0, 0.0, 0.0);
|
2020-03-20 00:32:19 +00:00
|
|
|
float alpha = 1.0; // Only available to subpasses
|
2019-09-15 09:58:38 +00:00
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
// unused, just here to make our compiler happy, make sure we don't execute any light code the user adds in..
|
2019-09-15 09:58:38 +00:00
|
|
|
#ifndef REALLYINCLUDETHIS
|
|
|
|
{
|
|
|
|
/* clang-format off */
|
|
|
|
|
|
|
|
LIGHT_SHADER_CODE
|
|
|
|
|
|
|
|
/* clang-format on */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/* clang-format off */
|
|
|
|
|
|
|
|
FRAGMENT_SHADER_CODE
|
|
|
|
|
|
|
|
/* clang-format on */
|
|
|
|
}
|
|
|
|
|
2020-03-20 00:32:19 +00:00
|
|
|
frag_color.rgb = color * params.position_multiplier.w;
|
|
|
|
frag_color.a = alpha;
|
2019-08-26 20:43:58 +00:00
|
|
|
}
|