Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a diagnostic AOV for invalid samples #1888

Merged
merged 1 commit into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/appleseed.studio/mainwindow/renderingsettingswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ namespace
create_direct_link("uniform_sampler.samples", "uniform_pixel_renderer.samples");
create_direct_link("uniform_sampler.force_antialiasing", "uniform_pixel_renderer.force_antialiasing");
create_direct_link("uniform_sampler.decorrelate_pixels", "uniform_pixel_renderer.decorrelate_pixels");
create_direct_link("uniform_sampler.enable_diagnostics", "uniform_pixel_renderer.enable_diagnostics");

create_direct_link("adaptive_sampler.min_samples", "adaptive_pixel_renderer.min_samples");
create_direct_link("adaptive_sampler.max_samples", "adaptive_pixel_renderer.max_samples");
Expand Down Expand Up @@ -551,6 +552,10 @@ namespace
m_uniform_sampler_decorrelate_pixels->setToolTip(m_params_metadata.get_path("uniform_pixel_renderer.decorrelate_pixels.help"));
layout->addWidget(m_uniform_sampler_decorrelate_pixels);

QCheckBox* enable_diagnostics = create_checkbox("uniform_sampler.enable_diagnostics", "Enable Diagnostic AOVs");
enable_diagnostics->setToolTip(m_params_metadata.get_path("uniform_pixel_renderer.enable_diagnostics.help"));
layout->addWidget(enable_diagnostics);

connect(
m_image_plane_sampler_passes, SIGNAL(valueChanged(const int)),
SLOT(slot_changed_image_plane_sampler_passes(const int)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ namespace
ISampleRendererFactory* factory,
const ParamArray& params,
const size_t thread_index)
: m_params(params)
: PixelRendererBase(frame, thread_index, params)
, m_params(params)
, m_sample_renderer(factory->create(thread_index))
{
if (m_params.m_diagnostics)
if (are_diagnostics_enabled())
{
m_variation_aov_index = frame.create_extra_aov_image("variation");
m_samples_aov_index = frame.create_extra_aov_image("samples");
Expand All @@ -116,7 +117,7 @@ namespace
m_params.m_min_samples,
m_params.m_max_samples,
m_params.m_max_variation,
m_params.m_diagnostics ? "on" : "off");
are_diagnostics_enabled() ? "on" : "off");
}

void release() override
Expand All @@ -125,10 +126,12 @@ namespace
}

void on_tile_begin(
const Frame& frame,
Tile& tile,
TileStack& aov_tiles) override
const Frame& frame,
Tile& tile,
TileStack& aov_tiles) override
{
PixelRendererBase::on_tile_begin(frame, tile, aov_tiles);

m_scratch_fb_half_width = truncate<int>(ceil(frame.get_filter().get_xradius()));
m_scratch_fb_half_height = truncate<int>(ceil(frame.get_filter().get_yradius()));

Expand All @@ -139,16 +142,21 @@ namespace
frame.aov_images().size(),
frame.get_filter()));

if (m_params.m_diagnostics)
m_diagnostics.reset(new Tile(tile.get_width(), tile.get_height(), 2, PixelFormatFloat));
if (are_diagnostics_enabled())
{
m_diagnostics.reset(new Tile(
tile.get_width(), tile.get_height(), 2, PixelFormatFloat));
}
}

void on_tile_end(
const Frame& frame,
Tile& tile,
TileStack& aov_tiles) override
const Frame& frame,
Tile& tile,
TileStack& aov_tiles) override
{
if (m_params.m_diagnostics)
PixelRendererBase::on_tile_end(frame, tile, aov_tiles);

if (are_diagnostics_enabled())
{
const size_t width = tile.get_width();
const size_t height = tile.get_height();
Expand Down Expand Up @@ -183,7 +191,7 @@ namespace
{
const size_t aov_count = frame.aov_images().size();

on_pixel_begin(pi, aov_accumulators);
on_pixel_begin(pi, pt, tile_bbox, aov_accumulators);

m_scratch_fb->clear();

Expand Down Expand Up @@ -285,7 +293,7 @@ namespace
}

// Store diagnostics values in the diagnostics tile.
if (m_params.m_diagnostics && tile_bbox.contains(pt))
if (are_diagnostics_enabled() && tile_bbox.contains(pt))
{
Color<float, 2> values;

Expand All @@ -309,7 +317,7 @@ namespace
m_diagnostics->set_pixel(pt.x, pt.y, values);
}

on_pixel_end(pi, aov_accumulators);
on_pixel_end(pi, pt, tile_bbox, aov_accumulators);
}

StatisticsVector get_statistics() const override
Expand All @@ -329,14 +337,12 @@ namespace
const size_t m_min_samples;
const size_t m_max_samples;
const float m_max_variation;
const bool m_diagnostics;

explicit Parameters(const ParamArray& params)
: m_sampling_mode(get_sampling_context_mode(params))
, m_min_samples(params.get_required<size_t>("min_samples", 16))
, m_max_samples(params.get_required<size_t>("max_samples", 256))
, m_max_variation(pow(10.0f, -params.get_optional<float>("quality", 2.0f)))
, m_diagnostics(params.get_optional<bool>("enable_diagnostics", false))
{
}
};
Expand Down Expand Up @@ -391,7 +397,7 @@ IPixelRenderer* AdaptivePixelRendererFactory::create(

Dictionary AdaptivePixelRendererFactory::get_params_metadata()
{
Dictionary metadata;
Dictionary metadata = PixelRendererBaseFactory::get_params_metadata();

metadata.dictionaries().insert(
"min_samples",
Expand All @@ -417,16 +423,6 @@ Dictionary AdaptivePixelRendererFactory::get_params_metadata()
.insert("label", "Quality")
.insert("help", "Quality factor"));

metadata.dictionaries().insert(
"enable_diagnostics",
Dictionary()
.insert("type", "bool")
.insert("default", "false")
.insert("label", "Enable Diagnostics")
.insert(
"help",
"Enable adaptive sampling diagnostics"));

return metadata;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define APPLESEED_RENDERER_KERNEL_RENDERING_FINAL_ADAPTIVEPIXELRENDERER_H

// appleseed.renderer headers.
#include "renderer/kernel/rendering/ipixelrenderer.h"
#include "renderer/kernel/rendering/pixelrendererbase.h"
#include "renderer/utility/paramarray.h"

// appleseed.foundation headers.
Expand All @@ -53,7 +53,7 @@ namespace renderer
//

class AdaptivePixelRendererFactory
: public IPixelRendererFactory
: public PixelRendererBaseFactory
{
public:
// Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@
// Standard headers.
#include <cmath>

// Forward declarations.
namespace foundation { class Tile; }
namespace renderer { class TileStack; }

using namespace foundation;
using namespace std;

namespace renderer
{
Expand All @@ -80,10 +75,12 @@ namespace
{
public:
UniformPixelRenderer(
const Frame& frame,
ISampleRendererFactory* factory,
const ParamArray& params,
const size_t thread_index)
: m_params(params)
: PixelRendererBase(frame, thread_index, params)
, m_params(params)
, m_sample_renderer(factory->create(thread_index))
, m_sample_count(m_params.m_samples)
, m_sqrt_sample_count(round<int>(sqrt(static_cast<double>(m_params.m_samples))))
Expand Down Expand Up @@ -112,11 +109,13 @@ namespace
" sampling mode %s\n"
" samples " FMT_SIZE_T "\n"
" force antialiasing %s\n"
" decorrelate pixels %s",
" decorrelate pixels %s\n"
" diagnostics %s",
m_params.m_sampling_mode == SamplingContext::Mode::QMCMode ? "qmc" : "rng",
m_params.m_samples,
m_params.m_force_aa ? "on" : "off",
m_params.m_decorrelate ? "on" : "off");
m_params.m_decorrelate ? "on" : "off",
are_diagnostics_enabled() ? "on" : "off");
}

void release() override
Expand All @@ -137,7 +136,7 @@ namespace
{
const size_t aov_count = frame.aov_images().size();

on_pixel_begin(pi, aov_accumulators);
on_pixel_begin(pi, pt, tile_bbox, aov_accumulators);

if (m_params.m_decorrelate)
{
Expand Down Expand Up @@ -251,7 +250,7 @@ namespace
}
}

on_pixel_end(pi, aov_accumulators);
on_pixel_end(pi, pt, tile_bbox, aov_accumulators);
}

StatisticsVector get_statistics() const override
Expand Down Expand Up @@ -303,9 +302,11 @@ namespace
//

UniformPixelRendererFactory::UniformPixelRendererFactory(
const Frame& frame,
ISampleRendererFactory* factory,
const ParamArray& params)
: m_factory(factory)
: m_frame(frame)
, m_factory(factory)
, m_params(params)
{
}
Expand All @@ -318,12 +319,12 @@ void UniformPixelRendererFactory::release()
IPixelRenderer* UniformPixelRendererFactory::create(
const size_t thread_index)
{
return new UniformPixelRenderer(m_factory, m_params, thread_index);
return new UniformPixelRenderer(m_frame, m_factory, m_params, thread_index);
}

Dictionary UniformPixelRendererFactory::get_params_metadata()
{
Dictionary metadata;
Dictionary metadata = PixelRendererBaseFactory::get_params_metadata();

metadata.dictionaries().insert(
"samples",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define APPLESEED_RENDERER_KERNEL_RENDERING_FINAL_UNIFORMPIXELRENDERER_H

// appleseed.renderer headers.
#include "renderer/kernel/rendering/ipixelrenderer.h"
#include "renderer/kernel/rendering/pixelrendererbase.h"
#include "renderer/utility/paramarray.h"

// appleseed.foundation headers.
Expand All @@ -42,6 +42,7 @@

// Forward declarations.
namespace foundation { class Dictionary; }
namespace renderer { class Frame; }
namespace renderer { class ISampleRendererFactory; }

namespace renderer
Expand All @@ -52,11 +53,12 @@ namespace renderer
//

class UniformPixelRendererFactory
: public IPixelRendererFactory
: public PixelRendererBaseFactory
{
public:
// Constructor.
UniformPixelRendererFactory(
const Frame& frame,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to forward declare Frame.

ISampleRendererFactory* factory,
const ParamArray& params);

Expand All @@ -71,6 +73,7 @@ class UniformPixelRendererFactory
static foundation::Dictionary get_params_metadata();

private:
const Frame& m_frame;
ISampleRendererFactory* m_factory;
ParamArray m_params;
};
Expand Down
Loading