From cd435d81669f845216696c4426bce9b2e423e834 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 1 Oct 2013 12:21:21 +0200 Subject: [PATCH] fix an issue where the reinhard tonemapper reacted to the rendering progress indicators --- src/mtsgui/mainwindow.cpp | 28 ++++++++++++++++++---------- src/mtsgui/shaders/logluminance.frag | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index c96c2366..fa5305b1 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -1727,6 +1727,9 @@ void MainWindow::onWorkBegin(const RenderJob *job, const RectangularWorkUnit *wu void MainWindow::drawVisualWorkUnit(SceneContext *context, const VisualWorkUnit &vwu) { int ox = vwu.offset.x, oy = vwu.offset.y, ex = ox + vwu.size.x, ey = oy + vwu.size.y; + if (vwu.size.x < 3 || vwu.size.y < 3) + return; + const float *color = NULL; /* Use desaturated colors to highlight the host @@ -1754,17 +1757,22 @@ void MainWindow::drawVisualWorkUnit(SceneContext *context, const VisualWorkUnit break; } - if (vwu.size.x < 3 || vwu.size.y < 3) - return; + float scale = .7f * (color[0] * 0.212671f + color[1] * 0.715160f + color[2] * 0.072169f); - drawHLine(context, ox, oy, ox + 3, color); - drawHLine(context, ex - 4, oy, ex - 1, color); - drawHLine(context, ox, ey - 1, ox + 3, color); - drawHLine(context, ex - 4, ey - 1, ex - 1, color); - drawVLine(context, ox, oy, oy + 3, color); - drawVLine(context, ex - 1, oy, oy + 3, color); - drawVLine(context, ex - 1, ey - 4, ey - 1, color); - drawVLine(context, ox, ey - 4, ey - 1, color); + float ncol[3] = { + color[0]*scale, + color[1]*scale, + color[2]*scale + }; + + drawHLine(context, ox, oy, ox + 3, ncol); + drawHLine(context, ex - 4, oy, ex - 1, ncol); + drawHLine(context, ox, ey - 1, ox + 3, ncol); + drawHLine(context, ex - 4, ey - 1, ex - 1, ncol); + drawVLine(context, ox, oy, oy + 3, ncol); + drawVLine(context, ex - 1, oy, oy + 3, ncol); + drawVLine(context, ex - 1, ey - 4, ey - 1, ncol); + drawVLine(context, ox, ey - 4, ey - 1, ncol); } void MainWindow::onWorkCanceled(const RenderJob *job, const Point2i &offset, const Vector2i &size) { diff --git a/src/mtsgui/shaders/logluminance.frag b/src/mtsgui/shaders/logluminance.frag index 1f6a9d5e..071968be 100644 --- a/src/mtsgui/shaders/logluminance.frag +++ b/src/mtsgui/shaders/logluminance.frag @@ -3,9 +3,10 @@ uniform float multiplier; void main() { vec4 color = texture2D(source, gl_TexCoord[0].xy); - float luminance = multiplier * (color.r * 0.212671 + color.g * 0.715160 + color.b * 0.072169); - if (luminance < 0.0 || luminance != luminance || luminance == 1024.0) + float luminance = color.r * 0.212671 + color.g * 0.715160 + color.b * 0.072169; + if (luminance < 0.0 || luminance != luminance || luminance == 1024.0 || abs(luminance-.7) < 1e-4) luminance = 0.0; // catch NaNs, negatives, and the Mitsuba banner + luminance = luminance * multiplier; float logLuminance = log(1e-3 + luminance); gl_FragColor = vec4(logLuminance, luminance, 0.0, 1.0); }