• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "render/shaders/common/render_post_process_structs_common.h"
8
9#include "common/bloom_common.h"
10
11// sets
12
13layout(set = 0, binding = 0, rgba16f /*r11f_g11f_b10f*/) uniform readonly image2D uRTex;
14layout(set = 0, binding = 0, rgba16f /*r11f_g11f_b10f*/) uniform writeonly image2D uWTex;
15layout(set = 0, binding = 1) uniform texture2D uTex;
16layout(set = 0, binding = 2) uniform sampler uSampler;
17
18layout(push_constant, std430) uniform uPostProcessPushConstant
19{
20    LocalPostProcessPushConstantStruct uPc;
21};
22
23layout(constant_id = 0) const uint CORE_POST_PROCESS_FLAGS = 0;
24
25///////////////////////////////////////////////////////////////////////////////
26// bloom upscale
27
28#define cTgs 8
29
30layout(local_size_x = cTgs, local_size_y = cTgs, local_size_z = 1) in;
31void main()
32{
33    // texSizeInvTexSize needs to be the output resolution
34    const vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * uPc.viewportSizeInvSize.zw;
35    vec3 color = vec3(0.0f);
36    if (uPc.factor.x == CORE_BLOOM_TYPE_NORMAL) {
37        color = BloomUpscale(uv, uPc.viewportSizeInvSize.zw, uTex, uSampler);
38    } else if (uPc.factor.x == CORE_BLOOM_TYPE_HORIZONTAL) {
39        color = BloomUpscaleHorizontal(uv, uPc.viewportSizeInvSize.zw, uTex, uSampler);
40    } else if (uPc.factor.x == CORE_BLOOM_TYPE_VERTICAL) {
41        color = BloomUpscaleVertical(uv, uPc.viewportSizeInvSize.zw, uTex, uSampler);
42    }
43    const ivec2 coords = ivec2(gl_GlobalInvocationID.xy);
44    const vec3 baseColor = imageLoad(uRTex, coords).xyz;
45    const float scatter = uPc.factor.w;
46    color = min((baseColor + color * scatter), CORE_BLOOM_CLAMP_MAX_VALUE);
47    imageStore(uWTex, coords, vec4(color, 1.0));
48}
49