1#version 460 core
2#extension GL_ARB_separate_shader_objects : enable
3#extension GL_ARB_shading_language_420pack : enable
4
5// includes
6
7#include "common/bloom_common.h"
8
9// sets
10
11#include "render/shaders/common/render_post_process_layout_common.h"
12
13layout(set = 1, binding = 0, rgba16f/*r11f_g11f_b10f*/) uniform readonly image2D uRTex;
14layout(set = 1, binding = 0, rgba16f/*r11f_g11f_b10f*/) uniform writeonly image2D uWTex;
15
16layout(set = 1, binding = 1) uniform texture2D uTex;
17layout(set = 1, binding = 2) uniform sampler uSampler;
18
19///////////////////////////////////////////////////////////////////////////////
20// bloom upscale
21
22#define cTgs 8
23
24layout(local_size_x = cTgs, local_size_y = cTgs, local_size_z = 1) in;
25void main()
26{
27    // texSizeInvTexSize needs to be the output resolution
28    const vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * uPc.viewportSizeInvSize.zw;
29
30    vec3 color = bloomUpscale(uv, uPc.viewportSizeInvSize.zw, uTex, uSampler);
31
32    const ivec2 coords = ivec2(gl_GlobalInvocationID.xy);
33    const vec3 baseColor = imageLoad(uRTex, coords).xyz;
34    color = min((color + baseColor), CORE_BLOOM_CLAMP_MAX_VALUE);
35    imageStore(uWTex, coords, vec4(color, 1.0));
36}
37
38