#version 450 layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in; layout(set = 0, binding = 0) uniform sampler2D hdr; layout(set = 0, binding = 1) uniform sampler2D ui; layout(set = 0, binding = 2) uniform writeonly image2D ldr_output; vec3 reinhard(vec3 original) { return original / (original+vec3(1.0)); } vec3 aces_filmic(vec3 original) { float a = 2.51f; float b = 0.03f; float c = 2.43f; float d = 0.59f; float e = 0.14f; return clamp((original*(a*original+b))/(original*(c*original+d)+e), 0.0, 1.0); } vec3 u2_filmic(vec3 x) { float A = 0.22f, B = 0.30f, C = 0.10f, D = 0.20f, E = 0.01f, F = 0.30; return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F)) - E/F; } vec3 gamma_correction(vec3 original) { return pow(original, vec3(1.0 / 2.2)); } void main() { ivec2 res = textureSize(hdr, 0); if(gl_GlobalInvocationID.x > res.x || gl_GlobalInvocationID.y > res.y) return; ivec2 p_coords = ivec2(gl_GlobalInvocationID.xy); vec4 ldr = vec4(gamma_correction(u2_filmic(texelFetch(hdr, p_coords, 0).xyz)), 1.0); //vec4 ui = texelFetch(ui, p_coords, 0).xyzw; imageStore(ldr_output, p_coords, /*mix(ui, ldr, ui.w)*/ldr); }