-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
@@ -73,6 +73,10 @@ namespace renderer | |||
|
|||
namespace | |||
{ | |||
|
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 will 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.
I like your approach, it's very sound architecturally. Clean code too! I've made a number of remarks which need to be addressed.
Thanks!
|
||
// Forward declarations. | ||
namespace foundation { class Tile; } | ||
namespace renderer { class AOVAccumulatorContainer; } | ||
namespace renderer { class Frame; } | ||
namespace renderer { class TileStack; } | ||
|
||
using namespace foundation; |
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 completely forbid using
declarations in header files since this defeats the point of namespaces entirely. Please use fully qualified names.
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.
That makes sense, we should change that also on the adaptive pixel renderer
|
||
// appleseed.foundation headers. | ||
#include "foundation/image/tile.h" |
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 presume you need this for std::unique_ptr<>
? If you do, then please remove the Tile
forward declaration below.
@@ -32,20 +32,26 @@ | |||
|
|||
// appleseed.renderer headers. | |||
#include "renderer/kernel/rendering/ipixelrenderer.h" | |||
#include "renderer/modeling/frame/frame.h" |
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.
There's already a Frame
forward declaration so this seems redundant.
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, my bad
@@ -60,6 +66,8 @@ class PixelRendererBase | |||
// Constructor. |
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.
Change to plural now that there are two constructors.
@@ -60,6 +66,8 @@ class PixelRendererBase | |||
// Constructor. | |||
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.
Remove this blank line so that the comment applies to both constructors.
@@ -41,6 +42,8 @@ using namespace foundation; | |||
|
|||
namespace renderer | |||
{ | |||
const uint8 InvalidSampleHint = 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.
Move after the "PixelRendererBase class implementation" block comment since this is technically part of the implementation of PixelRendererBase
.
@@ -32,6 +32,7 @@ | |||
|
|||
// appleseed.renderer headers. | |||
#include "renderer/kernel/rendering/ipixelrenderer.h" | |||
#include "renderer/modeling/frame/frame.h" |
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.
Prefer forward decls whenever possible (to reduce coupling and compile times).
@@ -181,7 +183,7 @@ namespace | |||
m_total_sampling_dim.insert(child_sampling_context.get_total_dimension()); | |||
|
|||
// Merge the sample into the framebuffer. | |||
if (shading_result.is_valid()) | |||
if (shading_result.is_valid() && shading_result.m_main.r < 0.8f) |
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.
Shouldn't be part of the PR :)
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.
Woops, that's weird, I used --patch
`to add and was careful.
@@ -148,6 +150,7 @@ namespace | |||
Tile& tile, | |||
TileStack& aov_tiles) override | |||
{ | |||
PixelRendererBase::on_tile_end(frame, tile, aov_tiles); |
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'd suggest adding a blank line after this to make it stand out.
@@ -129,6 +130,7 @@ namespace | |||
Tile& tile, | |||
TileStack& aov_tiles) override | |||
{ | |||
PixelRendererBase::on_tile_begin(frame, tile, aov_tiles); |
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'd suggest adding a blank line after this to make it stand out.
Thanks for the review @dictoon. Regarding different colors for different kind of errors, I was thinking of:
|
That sounds good, my only concerns are about complexity and especially performance. Let's try it (in a separate PR) and see how it goes! |
@@ -58,7 +62,7 @@ class PixelRendererBase | |||
{ | |||
public: | |||
// Constructor. | |||
PixelRendererBase(); | |||
PixelRendererBase(const Frame& frame, const size_t thread_index, 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.
You can make this more readable by having one parameter per line.
protected: | ||
const Parameters m_base_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.
Add a second blank line before block comments. That's the only case where we use two blank lines.
size_t m_invalid_pixel_count; | ||
struct Parameters | ||
{ | ||
const bool m_diagnostics; |
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 look nicer to forget about trying to align this to anything. There's no hard rule here, we're clearly in the domain of aesthetics :)
, m_sample_renderer(factory->create(thread_index)) | ||
{ | ||
if (m_params.m_diagnostics) | ||
if (m_base_params.m_diagnostics) |
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's quite problematic to have parameters in two places, m_base_params
and m_params
. I would suggest simply keeping m_base_params
in the base class, and renaming it to m_params
.
@@ -126,11 +124,13 @@ namespace | |||
|
|||
void on_tile_begin( | |||
const Frame& frame, | |||
Tile& tile, | |||
foundation::Tile& 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.
You're in the .cpp file and there's a using namespace foundation
statement so you can remove the qualification here (and everywhere in the file).
@@ -139,16 +139,19 @@ 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 (m_base_params.m_diagnostics) |
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.
Wrap the body of multiline if
statements with braces:
if (m_base_params.m_diagnostics)
{
...
}
tile.get_pixel(x, y, color); | ||
// 20% of luminance | ||
color.rgb().set(foundation::luminance(color.rgb())); | ||
color.rgb().set(color.r * 0.2f); |
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.
That looks a bit weird. Why not simply
color.rgb().set(0.2f * luminance(color.rgb()));
@@ -107,4 +176,25 @@ void PixelRendererBase::signal_invalid_sample() | |||
++m_invalid_sample_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.
Add another blank line here too.
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.
Thanks! A few very minor changes left and it's good to merge.
Impressed with the quality of your code!
} | ||
|
||
// Invalid samples diagnostic | ||
if (tile_bbox.contains(pt) && m_params.m_diagnostics) |
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 make sense to swap the conditions to avoid calling AABB::contains()
if m_params.m_diagnostics
is false.
{ | ||
public: | ||
// Constructor. | ||
UniformPixelRendererFactory( | ||
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.
Need to forward declare Frame
.
@@ -41,8 +41,7 @@ | |||
#include <cstddef> | |||
|
|||
// Forward declarations. | |||
namespace foundation { class Dictionary; } | |||
namespace renderer { class 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.
You need to restore the forward decl of Frame
.
@@ -139,16 +142,19 @@ 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 (PixelRendererBase::m_params.m_diagnostics) |
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.
Add braces around multiline body.
Thanks, I'm happy to know that my code is of quality 😄 |
e7df980
to
14da087
Compare
This implements #1815.