This is a huge change, and basically breaks everything (as per usual!) First of, this includes stuff like shaders so anything involving those are broken and then fixed. A new BuildAssets cmake file is added to aid in running AssetCompiler, and it seems to work fine on the engine base assets. The File API will eventually be revamped to handle this new way of organizing the files and domains will eventually be gotten rid of all together since I probably will replace it with game directory priorities. As it stands right now, there isn't a way to easily replace say - render_options.cfg with your own game-specific version. Apple builds are probably broken by this commit (since I'm moving around content and shader directories) to be fixed later.
44 lines
1.4 KiB
GLSL
44 lines
1.4 KiB
GLSL
#include "common.nocompile.glsl"
|
|
|
|
layout(local_size_x = 256, local_size_y = 1) in;
|
|
|
|
layout(r16f, binding = 0) uniform image2D target_image;
|
|
|
|
// adapated from https://bruop.github.io/exposure/ and http://www.alextardif.com/HistogramLuminance.html
|
|
|
|
shared uint histogram_shared[256];
|
|
|
|
layout(std430, binding = 1) buffer HistogramBuffer {
|
|
uint histogram[];
|
|
};
|
|
|
|
layout(push_constant) uniform readonly PushConstant{
|
|
vec4 params;
|
|
};
|
|
|
|
void main() {
|
|
uint count_for_this_bin = histogram[gl_LocalInvocationIndex];
|
|
histogram_shared[gl_LocalInvocationIndex] = count_for_this_bin * gl_LocalInvocationIndex;
|
|
|
|
groupMemoryBarrier();
|
|
|
|
histogram[gl_LocalInvocationIndex] = 0;
|
|
|
|
for(uint cutoff = (256 >> 1); cutoff > 0; cutoff >>= 1) {
|
|
if(uint(gl_LocalInvocationIndex) < cutoff) {
|
|
histogram_shared[gl_LocalInvocationIndex] += histogram_shared[gl_LocalInvocationIndex + cutoff];
|
|
}
|
|
|
|
groupMemoryBarrier();
|
|
}
|
|
|
|
if(gl_LocalInvocationIndex == 0) {
|
|
float weightedLogAverage = (histogram_shared[0] / max(params.w - float(count_for_this_bin), 1.0)) - 1.0;
|
|
|
|
float weightedAvgLum = exp2(weightedLogAverage / 254.0 * params.y + params.x);
|
|
|
|
float lumLastFrame = imageLoad(target_image, ivec2(0, 0)).x;
|
|
float adaptedLum = lumLastFrame + (weightedAvgLum - lumLastFrame) * params.z;
|
|
imageStore(target_image, ivec2(0, 0), vec4(adaptedLum, 0.0, 0.0, 0.0));
|
|
}
|
|
}
|