2016-07-21 12:01:53 +10:00
|
|
|
#version 450
|
|
|
|
|
2016-08-03 15:24:41 +10:00
|
|
|
layout(push_constant) uniform Push
|
|
|
|
{
|
|
|
|
float BLOOM_STRENGTH;
|
|
|
|
float OUTPUT_GAMMA;
|
|
|
|
} param;
|
|
|
|
|
|
|
|
#pragma parameter BLOOM_STRENGTH "Glow Strength" 0.45 0.0 0.8 0.05
|
|
|
|
#pragma parameter OUTPUT_GAMMA "Monitor Gamma" 2.2 1.8 2.6 0.02
|
|
|
|
|
2016-07-21 12:01:53 +10:00
|
|
|
layout(std140, set = 0, binding = 0) uniform UBO
|
|
|
|
{
|
|
|
|
mat4 MVP;
|
|
|
|
vec4 OutputSize;
|
|
|
|
vec4 OriginalSize;
|
|
|
|
vec4 SourceSize;
|
2016-07-27 03:00:03 +10:00
|
|
|
vec4 CRTPassSize;
|
2016-07-21 12:01:53 +10:00
|
|
|
} global;
|
|
|
|
|
|
|
|
#pragma stage vertex
|
|
|
|
layout(location = 0) in vec4 Position;
|
|
|
|
layout(location = 1) in vec2 TexCoord;
|
|
|
|
layout(location = 0) out vec2 vTexCoord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = global.MVP * Position;
|
|
|
|
vTexCoord = TexCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma stage fragment
|
|
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 FragColor;
|
|
|
|
layout(set = 0, binding = 1) uniform sampler2D Source;
|
2016-07-27 03:00:03 +10:00
|
|
|
layout(set = 0, binding = 2) uniform sampler2D CRTPass;
|
2016-07-21 12:01:53 +10:00
|
|
|
|
|
|
|
// For debugging
|
|
|
|
#define BLOOM_ONLY 0
|
|
|
|
|
2016-07-27 03:00:03 +10:00
|
|
|
#define CRT_PASS CRTPass
|
2016-07-21 12:01:53 +10:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
#if BLOOM_ONLY
|
2016-07-27 03:00:03 +10:00
|
|
|
vec3 source = BLOOM_STRENGTH * texture(Source, vTexCoord).rgb;
|
2016-07-21 12:01:53 +10:00
|
|
|
#else
|
|
|
|
|
2016-07-27 03:00:03 +10:00
|
|
|
vec3 source = 1.15 * texture(CRT_PASS, vTexCoord).rgb;
|
|
|
|
vec3 bloom = texture(Source, vTexCoord).rgb;
|
2016-08-03 15:24:41 +10:00
|
|
|
source += param.BLOOM_STRENGTH * bloom;
|
2016-07-21 12:01:53 +10:00
|
|
|
#endif
|
2016-08-03 15:24:41 +10:00
|
|
|
FragColor = vec4(pow(clamp(source, 0.0, 1.0), vec3(1.0 / param.OUTPUT_GAMMA)), 1.0);
|
2016-07-21 12:01:53 +10:00
|
|
|
}
|