// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u); const UVec2 WORKGROUP_SIZE = UVec2(16, 16); #pragma anki start comp #include #include layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in; // Vars layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler; layout(set = 0, binding = 1) uniform texture2D u_tex; ///< Its the IS RT layout(push_constant) uniform pc_ { Vec4 u_thresholdScalePad2; }; layout(set = 0, binding = 2, std140) readonly buffer ss0_ { Vec4 u_averageLuminancePad3; }; layout(set = 0, binding = 3) writeonly uniform image2D u_outImg; void main() { if((FB_SIZE.x % WORKGROUP_SIZE.x) != 0u || (FB_SIZE.y % WORKGROUP_SIZE.y) != 0u) // This check is free { if(gl_GlobalInvocationID.x >= FB_SIZE.x || gl_GlobalInvocationID.y >= FB_SIZE.y) { return; } } const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / Vec2(FB_SIZE); Vec3 color = textureLod(u_tex, u_linearAnyClampSampler, uv, 0.0).rgb; color += textureLodOffset(sampler2D(u_tex, u_linearAnyClampSampler), uv, 0.0, IVec2(+1, +1)).rgb; color += textureLodOffset(sampler2D(u_tex, u_linearAnyClampSampler), uv, 0.0, IVec2(-1, -1)).rgb; color += textureLodOffset(sampler2D(u_tex, u_linearAnyClampSampler), uv, 0.0, IVec2(-1, +1)).rgb; color += textureLodOffset(sampler2D(u_tex, u_linearAnyClampSampler), uv, 0.0, IVec2(+1, -1)).rgb; color *= (1.0 / 5.0); color = tonemap(color, u_averageLuminancePad3.x, u_thresholdScalePad2.x) * u_thresholdScalePad2.y; imageStore(u_outImg, IVec2(gl_GlobalInvocationID.xy), Vec4(color, 0.0)); } #pragma anki end