Begin histogram
This commit is contained in:
parent
4066143af8
commit
44f1e115e9
|
@ -20,7 +20,7 @@ uniform sampler2D lensTexture;
|
|||
uniform sampler2D lutTexture;
|
||||
#endif
|
||||
|
||||
#ifdef _Hist
|
||||
#ifdef _AutoExposure
|
||||
uniform sampler2D histogram;
|
||||
#endif
|
||||
|
||||
|
@ -288,8 +288,12 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef _AutoExposure
|
||||
vec3 expo = textureLod(tex, vec2(0,0), 100).rgb;
|
||||
fragColor.rgb *= vec3(1.0) - min(expo, vec3(autoExposureStrength));
|
||||
vec3 expo = textureLod(histogram, vec2(0.5, 0.5), 0).rgb +
|
||||
textureLod(histogram, vec2(0.1, 0.9), 0).rgb +
|
||||
textureLod(histogram, vec2(0.9, 0.9), 0).rgb +
|
||||
textureLod(histogram, vec2(0.9, 0.1), 0).rgb +
|
||||
textureLod(histogram, vec2(0.9, 0.9), 0).rgb;
|
||||
fragColor.rgb *= 1.0 - min(length(expo) / 5, autoExposureStrength);
|
||||
#endif
|
||||
#ifdef _Hist // Auto-exposure
|
||||
if (texCoord.x < 0.1) fragColor.rgb = textureLod(histogram, vec2(0, 0), 9.0).rrr; // 512x512
|
||||
|
|
|
@ -67,14 +67,7 @@ class RenderPathDeferred {
|
|||
t.format = Inc.getHdrFormat();
|
||||
t.scale = Inc.getSuperSampling();
|
||||
t.depth_buffer = "main";
|
||||
#if rp_autoexposure
|
||||
t.mipmaps = true;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
#if rp_autoexposure
|
||||
// Texture lod is fetched manually, prevent mipmap filtering
|
||||
t.mipmaps = false;
|
||||
#end
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -278,6 +271,58 @@ class RenderPathDeferred {
|
|||
}
|
||||
#end
|
||||
|
||||
#if rp_autoexposure
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "histogram0";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.scale = 1 / 4;
|
||||
t.format = Inc.getHdrFormat();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "histogram1";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.scale = 1 / 8;
|
||||
t.format = Inc.getHdrFormat();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "histogram2";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.scale = 1 / 16;
|
||||
t.format = Inc.getHdrFormat();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "histogram3";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.scale = 1 / 32;
|
||||
t.format = Inc.getHdrFormat();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "histogram4";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.scale = 1 / 64;
|
||||
t.format = Inc.getHdrFormat();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
|
||||
{
|
||||
path.loadShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_sss
|
||||
{
|
||||
path.loadShader("shader_datas/sss_pass/sss_pass_x");
|
||||
|
@ -762,7 +807,22 @@ class RenderPathDeferred {
|
|||
// Begin compositor
|
||||
#if rp_autoexposure
|
||||
{
|
||||
path.generateMipmaps("tex");
|
||||
// path.generateMipmaps("tex");
|
||||
path.setTarget("histogram0");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
path.setTarget("histogram1");
|
||||
path.bindTarget("histogram0", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
path.setTarget("histogram2");
|
||||
path.bindTarget("histogram1", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
path.setTarget("histogram3");
|
||||
path.bindTarget("histogram2", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
path.setTarget("histogram4");
|
||||
path.bindTarget("histogram3", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
|
@ -793,6 +853,12 @@ class RenderPathDeferred {
|
|||
}
|
||||
#end
|
||||
|
||||
#if rp_autoexposure
|
||||
{
|
||||
path.bindTarget("histogram4", "histogram");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_compositornodes
|
||||
{
|
||||
if (!path.isProbe) path.drawShader("shader_datas/compositor_pass/compositor_pass");
|
||||
|
|
|
@ -302,6 +302,7 @@ def build():
|
|||
|
||||
if rpdat.rp_compositornodes and rpdat.rp_autoexposure:
|
||||
assets.add_khafile_def('rp_autoexposure')
|
||||
assets.add_shader_pass('copy_pass')
|
||||
|
||||
if rpdat.rp_dynres:
|
||||
assets.add_khafile_def('rp_dynres')
|
||||
|
|
Loading…
Reference in a new issue