Skip to content

Commit

Permalink
Add mechanism to pass along sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesterKing committed Sep 27, 2024
1 parent 6598bb6 commit 00a2626
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
24 changes: 18 additions & 6 deletions src/ccycles/ccsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,21 @@ bool CCyclesOutputDriver::write_or_update_render_tile(const Tile &tile)
#if 0
const int width = tile.size.x;
const int height = tile.size.y;
vector<float> pixels(width * height * 4);
if (tile.get_pass_pixels("combined", 4, pixels.data())) {
vector<float> pixels(width * height * 1);

if (tile.get_sample() < 2 && tile.get_pass_pixels("depth", 1, pixels.data())) {
//// !!!!!!!!!!!!! Remember to change path to something useful on dev machine
fs::path save_path = "C:/Users/jesterKing/check_cycles_output.png";
//fs::path save_path = "C:/Users/jesterKing/check_cycles_output.png";
fs::path save_path = "/Users/jesterking/check_cycles_output.exr";
//// !!!!!!!!!!!!! Remember to change path to something useful on dev machine
unique_ptr<ImageOutput> image_output(ImageOutput::create("png"));
ImageSpec spec(width, height, 4, TypeDesc::FLOAT);
unique_ptr<ImageOutput> image_output(ImageOutput::create("exr"));
ImageSpec spec(width, height, 1, TypeDesc::FLOAT);
if(nullptr != image_output &&image_output->open(save_path.string(), spec))
{
ImageBuf image_buffer(spec,
pixels.data(),
AutoStride,
width * 4 * sizeof(float),
width * 1 * sizeof(float),
AutoStride);
/* Write to disk and close */
image_buffer.set_write_format(TypeDesc::FLOAT);
Expand Down Expand Up @@ -237,6 +239,11 @@ bool CCyclesOutputDriver::write_or_update_render_tile(const Tile &tile)
auto &tile_pass = tile_passes[i];
auto &full_pass = (*full_passes)[i];

if(full_pass->get_pass_type() == PASS_DEPTH && tile.get_sample() > 1)
{
continue;
}

full_pass->lock();

PassInfo pass_info = Pass::get_info(full_pass->get_pass_type());
Expand Down Expand Up @@ -271,6 +278,11 @@ bool CCyclesOutputDriver::write_or_update_render_tile(const Tile &tile)
}
else {
for (auto &pass : *full_passes) {
if(pass->get_pass_type() == PASS_DEPTH && tile.get_sample() > 1)
{
continue;
}

pass->lock();

PassInfo pass_info = Pass::get_info(pass->get_pass_type());
Expand Down
1 change: 1 addition & 0 deletions src/integrator/path_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class PathTrace {
struct {
RenderBuffers *render_buffers = nullptr;
} full_frame_state_;

};

CCL_NAMESPACE_END
8 changes: 7 additions & 1 deletion src/integrator/path_trace_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ PathTraceTile::PathTraceTile(PathTrace &path_trace)
path_trace.get_render_size(),
path_trace.get_render_tile_params().layer,
path_trace.get_render_tile_params().view,
path_trace.get_resolution_divider()),
path_trace.get_resolution_divider(),
path_trace.get_num_render_tile_samples()),
path_trace_(path_trace),
copied_from_device_(false)
{
Expand Down Expand Up @@ -92,4 +93,9 @@ bool PathTraceTile::set_pass_pixels(const string_view pass_name,
return path_trace_.set_render_tile_pixels(pass_accessor, source);
}

int PathTraceTile::get_sample() const
{
return sample;
}

CCL_NAMESPACE_END
1 change: 1 addition & 0 deletions src/integrator/path_trace_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PathTraceTile : public OutputDriver::Tile {
bool set_pass_pixels(const string_view pass_name,
const int num_channels,
const float *pixels) const;
int get_sample() const;

private:
PathTrace &path_trace_;
Expand Down
7 changes: 5 additions & 2 deletions src/session/output_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class OutputDriver {
const int2 full_size,
const string_view layer,
const string_view view,
const int resolution_divider)
: offset(offset), size(size), full_size(full_size), layer(layer), view(view), resolution_divider(resolution_divider)
const int resolution_divider,
const int sample)
: offset(offset), size(size), full_size(full_size), layer(layer), view(view), resolution_divider(resolution_divider), sample(sample)
{
}
virtual ~Tile() = default;
Expand All @@ -40,13 +41,15 @@ class OutputDriver {
const string layer;
const string view;
const int resolution_divider;
const int sample;

virtual bool get_pass_pixels(const string_view pass_name,
const int num_channels,
float *pixels) const = 0;
virtual bool set_pass_pixels(const string_view pass_name,
const int num_channels,
const float *pixels) const = 0;
virtual int get_sample() const = 0;
};

/* Write tile once it has finished rendering. */
Expand Down

0 comments on commit 00a2626

Please sign in to comment.