-
Notifications
You must be signed in to change notification settings - Fork 334
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
Use regular AOVs to export diagnostic AOVs #2121
Conversation
{ | ||
const string aov_name = frame.aov_images().get_name(i); | ||
|
||
if (aov_name == m_diagnostic_name) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
else signal_invalid_sample(); | ||
else | ||
{ | ||
signal_invalid_sample(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@@ -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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
@dictoon I will address your review in the adaptive PR :) |
|
||
if (m_sample_aov_tile) | ||
{ | ||
value[0] = trackers[0].get_size(); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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. | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
There was a problem hiding this comment.
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 ?
{ | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove explicit
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing explicit ?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
enable_diagnostics
option and check whether the use has set the wanted AOVaov_images
-> not requiredfix #2068