|
|
@@ -5,7 +5,6 @@
|
|
|
|
|
|
#pragma anki mutator SHARPEN 0 1 2 // 0: disabled, 1: vertical, 2: horizontal
|
|
|
#pragma anki mutator VARIANCE_CLIPPING 0 1
|
|
|
-#pragma anki mutator TONEMAP_FIX 0 1
|
|
|
#pragma anki mutator YCBCR 0 1
|
|
|
|
|
|
ANKI_SPECIALIZATION_CONSTANT_F32(VARIANCE_CLIPPING_GAMMA, 0u);
|
|
|
@@ -14,8 +13,8 @@ ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 2u);
|
|
|
|
|
|
#pragma anki start comp
|
|
|
#include <AnKi/Shaders/Functions.glsl>
|
|
|
-#include <AnKi/Shaders/Pack.glsl>
|
|
|
-#include <AnKi/Shaders/Tonemapping.glsl>
|
|
|
+#include <AnKi/Shaders/PackFunctions.glsl>
|
|
|
+#include <AnKi/Shaders/TonemappingFunctions.glsl>
|
|
|
|
|
|
const UVec2 WORKGROUP_SIZE = UVec2(8, 8);
|
|
|
layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
|
|
|
@@ -27,12 +26,6 @@ layout(set = 0, binding = 3) uniform texture2D u_historyRt;
|
|
|
layout(set = 0, binding = 4) uniform texture2D u_motionVectorsTex;
|
|
|
layout(set = 0, binding = 5) writeonly uniform image2D u_outImg;
|
|
|
|
|
|
-#if TONEMAP_FIX
|
|
|
-# define TONEMAPPING_SET 0
|
|
|
-# define TONEMAPPING_BINDING 6
|
|
|
-# include <AnKi/Shaders/TonemappingResources.glsl>
|
|
|
-#endif
|
|
|
-
|
|
|
#if YCBCR
|
|
|
# define sample(s, uv) rgbToYCbCr(textureLod(s, u_linearAnyClampSampler, uv, 0.0).rgb)
|
|
|
# define sampleOffset(s, uv, x, y) \
|
|
|
@@ -59,12 +52,9 @@ Vec3 sharpen(Vec2 uv)
|
|
|
|
|
|
void main()
|
|
|
{
|
|
|
- if((FB_SIZE.x % WORKGROUP_SIZE.x) != 0u || (FB_SIZE.y % WORKGROUP_SIZE.y) != 0u) // This check is free
|
|
|
+ if(skipOutOfBoundsInvocations(WORKGROUP_SIZE, FB_SIZE))
|
|
|
{
|
|
|
- if(gl_GlobalInvocationID.x >= FB_SIZE.x || gl_GlobalInvocationID.y >= FB_SIZE.y)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / Vec2(FB_SIZE);
|
|
|
@@ -108,15 +98,10 @@ void main()
|
|
|
const F32 lum0 = crntCol.r;
|
|
|
const F32 lum1 = historyCol.r;
|
|
|
const F32 maxLum = boxMax.r;
|
|
|
-#elif TONEMAP_FIX
|
|
|
- const F32 lum0 = computeLuminance(tonemap(crntCol, u_exposureThreshold0));
|
|
|
- const F32 lum1 = computeLuminance(tonemap(historyCol, u_exposureThreshold0));
|
|
|
- // F32 maxLum = computeLuminance(tonemap(boxMax, u_exposureThreshold0));
|
|
|
- const F32 maxLum = 1.0;
|
|
|
#else
|
|
|
- const F32 lum0 = computeLuminance(crntCol);
|
|
|
- const F32 lum1 = computeLuminance(historyCol);
|
|
|
- const F32 maxLum = computeLuminance(boxMax);
|
|
|
+ const F32 lum0 = computeLuminance(invertibleTonemap(crntCol));
|
|
|
+ const F32 lum1 = computeLuminance(invertibleTonemap(historyCol));
|
|
|
+ const F32 maxLum = 1.0;
|
|
|
#endif
|
|
|
|
|
|
F32 diff = abs(lum0 - lum1) / max(lum0, max(lum1, maxLum + EPSILON));
|
|
|
@@ -125,10 +110,9 @@ void main()
|
|
|
const F32 feedback = mix(0.0, BLEND_FACTOR, diff);
|
|
|
|
|
|
// Write result
|
|
|
+ Vec3 outColor = mix(historyCol, crntCol, feedback);
|
|
|
#if YCBCR
|
|
|
- const Vec3 outColor = yCbCrToRgb(mix(historyCol, crntCol, feedback));
|
|
|
-#else
|
|
|
- const Vec3 outColor = mix(historyCol, crntCol, feedback);
|
|
|
+ outColor = yCbCrToRgb(outColor);
|
|
|
#endif
|
|
|
imageStore(u_outImg, IVec2(gl_GlobalInvocationID.xy), Vec4(outColor, 0.0));
|
|
|
}
|