summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2022-12-23 23:41:44 +1100
committerBastiaan Olij <mux213@gmail.com>2023-01-07 14:40:42 +1100
commit9b549231e4b4287ab9dcf1c1e6322314f3088e8c (patch)
tree76c49c3be75ebdc143f606e4d095e93b3fa92392 /servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl
parent163f6f5fe87d11645e94cd49f41226ab03063e53 (diff)
Move luminance effect into its own class and use new buffers system
Diffstat (limited to 'servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl')
-rw-r--r--servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl74
1 files changed, 0 insertions, 74 deletions
diff --git a/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl b/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl
deleted file mode 100644
index 29ebd74a90..0000000000
--- a/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl
+++ /dev/null
@@ -1,74 +0,0 @@
-/* clang-format off */
-#[vertex]
-
-#version 450
-
-#VERSION_DEFINES
-
-#include "luminance_reduce_raster_inc.glsl"
-
-layout(location = 0) out vec2 uv_interp;
-/* clang-format on */
-
-void main() {
- vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
- uv_interp = base_arr[gl_VertexIndex];
-
- gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
-}
-
-/* clang-format off */
-#[fragment]
-
-#version 450
-
-#VERSION_DEFINES
-
-#include "luminance_reduce_raster_inc.glsl"
-
-layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
-
-layout(set = 0, binding = 0) uniform sampler2D source_exposure;
-
-#ifdef FINAL_PASS
-layout(set = 1, binding = 0) uniform sampler2D prev_luminance;
-#endif
-
-layout(location = 0) out highp float luminance;
-
-void main() {
- ivec2 dest_pos = ivec2(uv_interp * settings.dest_size);
- ivec2 src_pos = ivec2(uv_interp * settings.source_size);
-
- ivec2 next_pos = (dest_pos + ivec2(1)) * settings.source_size / settings.dest_size;
- next_pos = max(next_pos, src_pos + ivec2(1)); //so it at least reads one pixel
-
- highp vec3 source_color = vec3(0.0);
- for (int i = src_pos.x; i < next_pos.x; i++) {
- for (int j = src_pos.y; j < next_pos.y; j++) {
- source_color += texelFetch(source_exposure, ivec2(i, j), 0).rgb;
- }
- }
-
- source_color /= float((next_pos.x - src_pos.x) * (next_pos.y - src_pos.y));
-
-#ifdef FIRST_PASS
- luminance = max(source_color.r, max(source_color.g, source_color.b));
-
- // This formula should be more "accurate" but gave an overexposed result when testing.
- // Leaving it here so we can revisit it if we want.
- // luminance = source_color.r * 0.21 + source_color.g * 0.71 + source_color.b * 0.07;
-#else
- luminance = source_color.r;
-#endif
-
-#ifdef FINAL_PASS
- // Obtain our target luminance
- luminance = clamp(luminance, settings.min_luminance, settings.max_luminance);
-
- // Now smooth to our transition
- highp float prev_lum = texelFetch(prev_luminance, ivec2(0, 0), 0).r; //1 pixel previous luminance
- luminance = prev_lum + (luminance - prev_lum) * clamp(settings.exposure_adjust, 0.0, 1.0);
-#endif
-}