LumixEngine/data/pipelines/bloom.shd
2020-09-23 01:09:09 +02:00

46 lines
No EOL
1 KiB
Text

include "pipelines/common.glsl"
vertex_shader [[
layout (location = 0) out vec2 v_uv;
void main()
{
gl_Position = fullscreenQuad(gl_VertexID, v_uv);
}
]]
fragment_shader [[
layout (binding=0) uniform sampler2D u_input;
layout (location = 0) in vec2 v_uv;
layout (location = 0) out vec4 o_color;
#ifdef EXTRACT
layout (binding = 5, std430) readonly buffer LuminanceData {
uint b_histogram[256];
float b_accum;
};
layout(std140, binding = 4) uniform Data {
float u_avg_lum_multiplier;
};
void main() {
float avg_lum = b_accum;
vec3 c = texture(u_input, v_uv).rgb;
o_color.rgb = c * saturate(1 + luminance(c) - avg_lum * u_avg_lum_multiplier);
o_color.a = 1;
}
#elif defined DOWNSCALE
void main() {
o_color = texture(u_input, v_uv) ;
o_color += textureOffset(u_input, v_uv, ivec2(1, 0)) ;
o_color += textureOffset(u_input, v_uv, ivec2(1, 1)) ;
o_color += textureOffset(u_input, v_uv, ivec2(0, 1)) ;
o_color *= 0.25;
}
#else
void main() {
o_color = texture(u_input, v_uv);
}
#endif
]]