2023-06-14 06:52:36 +00:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
#ifndef __DENOISING_H__
|
|
|
|
#define __DENOISING_H__
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
/* TODO(sergey): Make it explicit and clear when something is a denoiser, its pipeline or
|
|
|
|
* parameters. Currently it is an annoying mixture of terms used interchangeably. */
|
2019-02-06 11:57:10 +00:00
|
|
|
|
2022-01-04 20:39:54 +00:00
|
|
|
#include "device/device.h"
|
|
|
|
#include "integrator/denoiser.h"
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
2022-01-04 20:39:54 +00:00
|
|
|
#include "util/string.h"
|
|
|
|
#include "util/unique_ptr.h"
|
|
|
|
#include "util/vector.h"
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
|
2022-01-04 20:39:54 +00:00
|
|
|
#include <OpenImageIO/imageio.h>
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
OIIO_NAMESPACE_USING
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
/* Denoiser pipeline */
|
2019-02-06 11:57:10 +00:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
class DenoiserPipeline {
|
2019-02-06 11:57:10 +00:00
|
|
|
public:
|
2024-06-03 20:41:25 +00:00
|
|
|
DenoiserPipeline(DeviceInfo &denoiser_device_info, const DenoiseParams ¶ms);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
~DenoiserPipeline();
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
bool run();
|
|
|
|
|
|
|
|
/* Error message after running, in case of failure. */
|
|
|
|
string error;
|
|
|
|
|
|
|
|
/* Sequential list of frame filepaths to denoise. */
|
|
|
|
vector<string> input;
|
|
|
|
/* Sequential list of frame filepaths to write result to. Empty entries
|
|
|
|
* are skipped, so only a subset of the sequence can be denoised while
|
|
|
|
* taking into account all input frames. */
|
|
|
|
vector<string> output;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class DenoiseTask;
|
|
|
|
|
|
|
|
Stats stats;
|
|
|
|
Profiler profiler;
|
|
|
|
Device *device;
|
2024-06-03 20:41:25 +00:00
|
|
|
Device *cpu_device;
|
2022-01-04 20:39:54 +00:00
|
|
|
std::unique_ptr<Denoiser> denoiser;
|
2019-02-06 11:57:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Denoise Image Layer */
|
|
|
|
|
|
|
|
struct DenoiseImageLayer {
|
|
|
|
string name;
|
|
|
|
/* All channels belonging to this DenoiseImageLayer. */
|
|
|
|
vector<string> channels;
|
|
|
|
/* Layer to image channel mapping. */
|
|
|
|
vector<int> layer_to_image_channel;
|
|
|
|
|
|
|
|
/* Sample amount that was used for rendering this layer. */
|
|
|
|
int samples;
|
|
|
|
|
|
|
|
/* Device input channel will be copied from image channel input_to_image_channel[i]. */
|
|
|
|
vector<int> input_to_image_channel;
|
|
|
|
|
2019-05-01 11:14:11 +00:00
|
|
|
/* Write i-th channel of the processing output to output_to_image_channel[i]-th channel of the
|
|
|
|
* file. */
|
2019-02-06 11:57:10 +00:00
|
|
|
vector<int> output_to_image_channel;
|
|
|
|
|
2022-01-04 20:39:54 +00:00
|
|
|
/* output_to_image_channel of the previous frame, if used. */
|
|
|
|
vector<int> previous_output_to_image_channel;
|
|
|
|
|
2019-05-01 11:14:11 +00:00
|
|
|
/* Detect whether this layer contains a full set of channels and set up the offsets accordingly.
|
|
|
|
*/
|
2019-02-06 11:57:10 +00:00
|
|
|
bool detect_denoising_channels();
|
|
|
|
|
|
|
|
/* Map the channels of a secondary frame to the channels that are required for processing,
|
2019-05-01 11:14:11 +00:00
|
|
|
* fill neighbor_input_to_image_channel if all are present or return false if a channel are
|
|
|
|
* missing. */
|
2022-01-04 20:39:54 +00:00
|
|
|
bool match_channels(const std::vector<string> &channelnames,
|
2019-02-06 11:57:10 +00:00
|
|
|
const std::vector<string> &neighbor_channelnames);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Denoise Image Data */
|
|
|
|
|
|
|
|
class DenoiseImage {
|
|
|
|
public:
|
|
|
|
DenoiseImage();
|
|
|
|
~DenoiseImage();
|
|
|
|
|
|
|
|
/* Dimensions */
|
|
|
|
int width, height, num_channels;
|
|
|
|
|
|
|
|
/* Samples */
|
|
|
|
int samples;
|
|
|
|
|
|
|
|
/* Pixel buffer with interleaved channels. */
|
|
|
|
array<float> pixels;
|
|
|
|
|
|
|
|
/* Image file handles */
|
2019-02-14 12:57:28 +00:00
|
|
|
ImageSpec in_spec;
|
2022-01-04 20:39:54 +00:00
|
|
|
unique_ptr<ImageInput> in_previous;
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
/* Render layers */
|
|
|
|
vector<DenoiseImageLayer> layers;
|
|
|
|
|
|
|
|
void free();
|
|
|
|
|
2019-05-01 11:14:11 +00:00
|
|
|
/* Open the input image, parse its channels, open the output image and allocate the output
|
|
|
|
* buffer. */
|
2019-02-06 11:57:10 +00:00
|
|
|
bool load(const string &in_filepath, string &error);
|
|
|
|
|
|
|
|
/* Load neighboring frames. */
|
2022-01-04 20:39:54 +00:00
|
|
|
bool load_previous(const string &in_filepath, string &error);
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
/* Load subset of pixels from file buffer into input buffer, as needed for denoising
|
|
|
|
* on the device. Channels are reshuffled following the provided mapping. */
|
2022-01-04 20:39:54 +00:00
|
|
|
void read_pixels(const DenoiseImageLayer &layer,
|
|
|
|
const BufferParams ¶ms,
|
|
|
|
float *input_pixels);
|
|
|
|
bool read_previous_pixels(const DenoiseImageLayer &layer,
|
|
|
|
const BufferParams ¶ms,
|
|
|
|
float *input_pixels);
|
2019-02-06 11:57:10 +00:00
|
|
|
|
|
|
|
bool save_output(const string &out_filepath, string &error);
|
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:14:11 +00:00
|
|
|
/* Parse input file channels, separate them into DenoiseImageLayers,
|
|
|
|
* detect DenoiseImageLayers with full channel sets,
|
2019-02-06 11:57:10 +00:00
|
|
|
* fill layers and set up the output channels and passthrough map. */
|
|
|
|
bool parse_channels(const ImageSpec &in_spec, string &error);
|
|
|
|
|
|
|
|
void close_input();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Denoise Task */
|
|
|
|
|
|
|
|
class DenoiseTask {
|
|
|
|
public:
|
2022-01-04 20:39:54 +00:00
|
|
|
DenoiseTask(Device *device, DenoiserPipeline *denoiser, int frame);
|
2019-02-06 11:57:10 +00:00
|
|
|
~DenoiseTask();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
/* Task stages */
|
|
|
|
bool load();
|
|
|
|
bool exec();
|
|
|
|
bool save();
|
|
|
|
void free();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
string error;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
protected:
|
|
|
|
/* Denoiser parameters and device */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 15:59:20 +00:00
|
|
|
DenoiserPipeline *denoiser;
|
2019-02-06 11:57:10 +00:00
|
|
|
Device *device;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
/* Frame number to be denoised */
|
|
|
|
int frame;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
/* Image file data */
|
|
|
|
DenoiseImage image;
|
|
|
|
int current_layer;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2022-01-04 20:39:54 +00:00
|
|
|
RenderBuffers buffers;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2019-02-06 11:57:10 +00:00
|
|
|
/* Task handling */
|
|
|
|
bool load_input_pixels(int layer);
|
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __DENOISING_H__ */
|