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

Use regular AOVs to export diagnostic AOVs #2121

Merged
merged 13 commits into from
Jul 19, 2018

Conversation

oktomus
Copy link
Member

@oktomus oktomus commented Jul 16, 2018

  • Copy diagnostic AOVs into real AOVs
  • Remove enable_diagnostics option and check whether the use has set the wanted AOV
  • Don't create extra aovs but directly write into regular aovs from the pixel renderers
  • ? Write directly in the AOV
  • Post process in the AOV and not in the renderer
  • ? Use write() to detect invalid samples
  • Check in both regular and internal aovs instead of aov_images -> not required

fix #2068

@oktomus oktomus requested a review from est77 July 16, 2018 10:29
{
const string aov_name = frame.aov_images().get_name(i);

if (aov_name == m_diagnostic_name)
Copy link
Member

Choose a reason for hiding this comment

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

Do the linear search only the first time it is needed. The image does not change while the AOVAccumulator is alive and accumulators are not shared between threads.

const Image* m_image = nullptr;
if (!m_image) { do the search here... }


size_t get_channel_count() const override
{
return 4;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need 4 channels?
Some of the previous AOVs use only one (you can save them using 1 channel called "Y") and the pixel variation is RGB (no need for A).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I will improve that when implementing per-aov post process

@dictoon dictoon changed the title Use regular AOVs to export diagnostic AOVs [WIP] Use regular AOVs to export diagnostic AOVs Jul 17, 2018
@oktomus oktomus changed the title [WIP] Use regular AOVs to export diagnostic AOVs Use regular AOVs to export diagnostic AOVs Jul 17, 2018
@oktomus oktomus changed the title Use regular AOVs to export diagnostic AOVs [WIP] Use regular AOVs to export diagnostic AOVs Jul 17, 2018
@oktomus oktomus changed the title [WIP] Use regular AOVs to export diagnostic AOVs Use regular AOVs to export diagnostic AOVs Jul 17, 2018
@dictoon dictoon added the PR | Squash This PR must be squashed when merged. label Jul 18, 2018
else signal_invalid_sample();
else
{
signal_invalid_sample();
Copy link
Member

Choose a reason for hiding this comment

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

Remove the braces, leave the code as it was before.
Do the same in the other signal_invalid_sample() call a few lines after.

// Diagnostic AOV accumulator.
//

class DiagnosticAOVAccumulator
Copy link
Member

Choose a reason for hiding this comment

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

We are not using this class, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

it is used by PixelVariation and PixelSample

@est77 est77 merged commit 9e3980f into appleseedhq:master Jul 19, 2018
@@ -218,16 +218,14 @@ namespace
m_image->clear(Color<float, 1>(0.0f));
}

void post_process_image() override
void post_process_image(const AABB2u& bbox) override
Copy link
Member

Choose a reason for hiding this comment

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

You must inclde foundation/math/aabb.h in all files that now require it.

@@ -90,7 +91,7 @@ class APPLESEED_DLLSYMBOL AOV
virtual void clear_image();

// Apply any post processing needed to the AOV image.
virtual void post_process_image();
virtual void post_process_image(const foundation::AABB2u& bbox);
Copy link
Member

Choose a reason for hiding this comment

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

I believe bbox should be called crop_window for clarity.

{
public:
static foundation::Dictionary get_params_metadata();
size_t m_invalid_pixel_count;
Copy link
Member

Choose a reason for hiding this comment

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

Make sure to remove header files that are no longer required.

@@ -79,7 +79,7 @@ namespace
ISampleRendererFactory* factory,
const ParamArray& params,
const size_t thread_index)
: PixelRendererBase(frame, thread_index, params)
: PixelRendererBase()
Copy link
Member

Choose a reason for hiding this comment

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

You no longer need to explicitly invoke the constructor here.

@oktomus
Copy link
Member Author

oktomus commented Jul 20, 2018

@dictoon I will address your review in the adaptive PR :)


if (m_sample_aov_tile)
{
value[0] = trackers[0].get_size();
Copy link
Member

Choose a reason for hiding this comment

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

You need a static_cast<> here as in general this will loose precision.

// Inform the AOV accumulators that we are about to render a tile.
m_aov_accumulators.on_tile_begin(
frame,
tile_x,
tile_y,
m_pixel_renderer->get_max_samples_per_pixel());

// Inform the pixel renderer that we are about to render a tile.
m_pixel_renderer->on_tile_begin(
Copy link
Member

Choose a reason for hiding this comment

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

Why did you move this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't remember, I think it was for the first implementation of DiagnosticAOV. I'm going to check if it's still required and why if so.

Copy link
Member Author

Choose a reason for hiding this comment

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

not required anymore.


// todo: mark pixel as faulty in the diagnostic map.
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly this todo is done because we now have a dedicated Invalid Samples AOV?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

register_factory(auto_release_ptr<FactoryType>(new NormalAOVFactory()));
register_factory(auto_release_ptr<FactoryType>(new PixelSampleAOVFactory()));
Copy link
Member

Choose a reason for hiding this comment

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

I feel that this AOV name is ambiguous, I would suggest PixelSampleCountAOV[Factory].


//
// Invalid Sample AOV accumulator.
//
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

You want me to remove the whole block ?

{
}
};

Copy link
Member

@dictoon dictoon Jul 20, 2018

Choose a reason for hiding this comment

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

Always precede block comments by two blank lines.

{
public:
explicit InvalidSampleAOVAccumulator(
Image& image)
Copy link
Member

Choose a reason for hiding this comment

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

Move argument to precedent line, there's no line length problem here.

}

void on_tile_begin(
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.

Fix indentation.

}

void on_tile_end(
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.

Fix indentation.


void on_pixel_end(const Vector2i& pi) override
{
// Store a hint corresping to the sample state in the tile.
Copy link
Member

Choose a reason for hiding this comment

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

Fix typo


m_tile_origin_x = static_cast<int>(tile_x * props.m_tile_width);
m_tile_origin_y = static_cast<int>(tile_y * props.m_tile_height);
m_tile_end_x = static_cast<int>(m_tile_origin_x + m_invalid_sample_tile->get_width() - 1);
Copy link
Member

Choose a reason for hiding this comment

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

Traditionally "end" indices are exclusive, i.e. you don't subtract 1 here, and you change <= to < when checking if pixels fall inside the tile. Simpler math and increased consistency.


const uint8 NoState = 0;
const uint8 InvalidSample = 1;
const uint8 CorrectSample = 2;
Copy link
Member

Choose a reason for hiding this comment

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

CorrectSample -> ValidSample (because "valid" is the opposite of "invalid", while "correct" is the opposite of "incorrect").

: public AOV
{
public:
explicit DiagnosticAOV(const char* name, const ParamArray& params)
Copy link
Member

Choose a reason for hiding this comment

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

Remove explicit.

Copy link
Member

Choose a reason for hiding this comment

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

Why is this AOV named while the others aren't?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because other AOVs inherit from this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why removing explicit ?

Copy link
Member

Choose a reason for hiding this comment

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

Because it's not useful for constructors with more than one argument... Or at least that was true until C++11: https://stackoverflow.com/a/39122237/393756

It seems that it makes sense starting with C++11 to mark all constructors as explicit... Today I learn!

You can leave explicit then. If you already remove it then no big deal, it's fine too.


Color3f color;

for (size_t j = bbox.min.y; j <= bbox.max.y; ++j)
Copy link
Member

Choose a reason for hiding this comment

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

It would be more logical to use x and y to iterate.

return
Dictionary()
.insert("name", Invalid_Sample_Model)
.insert("label", "Invalid Sample");
Copy link
Member

Choose a reason for hiding this comment

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

"Invalid Samples".

The AOV needs to be renamed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR | Squash This PR must be squashed when merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix bad pixels when crop window is overlapping tiles
3 participants