29 lines
No EOL
989 B
GLSL
29 lines
No EOL
989 B
GLSL
#version 450
|
|
|
|
layout(location = 0) in vec2 inTextCoord;
|
|
layout(location = 0) out vec4 outBloomColour;
|
|
layout(set = 0, binding = 0) uniform sampler2D inputTexture;
|
|
|
|
layout(push_constant) uniform PassConfig {
|
|
int horizontal;
|
|
float GAMMA_CONST;
|
|
float Exposure;
|
|
float blur_radius;
|
|
vec2 bloomSize;
|
|
} config;
|
|
|
|
vec3 extractBloom(vec2 uv) {
|
|
vec3 color = max(texture(inputTexture, uv).rgb, vec3(0.0));
|
|
float brightness = dot(color, vec3(0.2126, 0.7152, 0.0722));
|
|
float contribution = max(brightness - 1.0, 0.0);
|
|
return color * (contribution / (contribution + 0.5));
|
|
}
|
|
|
|
void main() {
|
|
vec2 offset = 0.25 / config.bloomSize;
|
|
vec3 bloom = extractBloom(inTextCoord + vec2(-offset.x, -offset.y))
|
|
+ extractBloom(inTextCoord + vec2( offset.x, -offset.y))
|
|
+ extractBloom(inTextCoord + vec2(-offset.x, offset.y))
|
|
+ extractBloom(inTextCoord + vec2( offset.x, offset.y));
|
|
outBloomColour = vec4(bloom * 0.25, 1.0);
|
|
} |