Getting denoising to work on standalone app

Hi everyone!

I’m trying to make denoising on Cycles to work on my own application (somewhat based on the standalone app).
Most of what I’ve done so far has been inspired on the Blender source code and the standalone app, but I can’t seem to get denoising to work at all. On the Blender source code, the parameters for the session seem to be very different (the SessionParams and DenoiseParams structures seem to be very different from the one in the standalone app), and the standalone app doesn’t have the options for this.

I’ve tried two ways of making it work:

DenoiseParams denoising;
denoising.use = true;
denoising.store_passes = true;
denoising.type = DenoiserType::DENOISER_OPENIMAGEDENOISE;
denoising.start_sample = 1;

_session = new Session(session_params);

This doesn’t seem to have any effect whatsoever on the output image.

session_params.denoising.use = true;
session_params.denoising.store_passes = true;
session_params.denoising.type = DenoiserType::DENOISER_OPENIMAGEDENOISE;
session_params.denoising.start_sample = 1;

_session = new Session(session_params);

This one renders up until 98% (according to session progress), and then just stands there, nothing happening…

Anybody has any ideas? I’m I missing an initialization somewhere?

The rest of the session initialization code is as follows in both cases:

std::vector<DeviceInfo> devices = Device::available_devices((DeviceTypeMask)(1 << DEVICE_CPU));

SessionParams session_params;
session_params.write_render_cb = [this](const unsigned char* pixels, int width, int height, int channels) { return this->write_pixels(pixels, width, height, channels); };
session_params.device = devices.front();
session_params.device.add_denoising_devices(DenoiserType::DENOISER_OPENIMAGEDENOISE); = true;
session_params.start_resolution = 64;
session_params.tile_size = make_int2(64, 64);

Best regards,

Still trying to get this to work.
I’ve had some extremely limited sucess by going to the standalone application again (instead of my own application), and adding the following code to the end of options parse:

  DenoiseParams denoising_params;
  denoising_params.use = true;
  denoising_params.start_sample = 0;
  denoising_params.store_passes = false;
  denoising_params.type = DENOISER_OPENIMAGEDENOISE;

  options.session_params.denoising = denoising_params;
  options.session_params.denoising_start_sample = denoising_params.start_sample;

This by itself does nothing different in the output, but if I call:


in scene_init, denoising works (although it appears too blurry, but I’ll cross that bridge later…)

The problem is that the application crashes while rendering:

It seems like the buffer gets corrupted (or the pointer to it overruns the size), but to be honest I don’t understand enough of the whole system to be able to understand the error.

My test was done by pulling the latest version and changing the code as indicated above, no additional changes.
Application is being ran with “…/examples/scene_monkey.xml --samples 1” as parameters.

Does anyone have any idea on what the problem might be? This is driving me nuts, and it’s the only missing part from having a Cycles integration with our CAD product.

As a suggestion, I’d add some command line parameters for denoising on the standalone app to help guide the integration of Cycles into other packages. For other components of the integration I could use the Blender source code as a guide, but this part is very different from Blender.

Best regards,

Sorry to tag you directly @brecht but as far as I can see, you’re usually who can help… If not, sorry about the bother!

Any idea/thoughts on this?

Best regards,

Hi everyone!

As usual in this sort of thing, while I was trying something completely different I figured out what was wrong with denoising and I got it to work.

I was initializing the passes with


But I wasn’t activating denoising on the BufferParams structure, and that was causing the crash.
Now that I have it set it correctly:

BufferParams   session_buffer_params;
session_buffer_params.width = _width;
session_buffer_params.height = _height;
session_buffer_params.full_width = _width;
session_buffer_params.full_height = _height;
session_buffer_params.passes = _scene->passes;
session_buffer_params.denoising_data_pass = _scene->film->get_denoising_data_pass();
session_buffer_params.denoising_clean_pass = _scene->film->get_denoising_clean_pass();
session_buffer_params.denoising_prefiltered_pass = _scene->film->get_denoising_prefiltered_pass();

I get denoising working properly!

Hopefully this explanation will help someone in the future!

Best regards,

1 Like

in Cycles 3.1 Source

  //turn on the denoiser
  //see the DenoiserType,any support your device

no thanks :grinning:

Does this also require us to add a denoise and albedo pass or does this do it automatically?

Also can we get denoise to work per bucket or is it a final pass on the full render?