Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/denoiser_oidn.cpp
| Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | void denoise_pass(const PassType pass_type) | ||||
| */ | */ | ||||
| oidn::FilterRef oidn_filter = oidn_device.newFilter("RT"); | oidn::FilterRef oidn_filter = oidn_device.newFilter("RT"); | ||||
| set_input_pass(oidn_filter, oidn_color_access_pass); | set_input_pass(oidn_filter, oidn_color_access_pass); | ||||
| set_guiding_passes(oidn_filter, oidn_color_pass); | set_guiding_passes(oidn_filter, oidn_color_pass); | ||||
| set_output_pass(oidn_filter, oidn_output_pass); | set_output_pass(oidn_filter, oidn_output_pass); | ||||
| oidn_filter.setProgressMonitorFunction(oidn_progress_monitor_function, denoiser_); | oidn_filter.setProgressMonitorFunction(oidn_progress_monitor_function, denoiser_); | ||||
| oidn_filter.set("hdr", true); | oidn_filter.set("hdr", true); | ||||
| oidn_filter.set("srgb", false); | oidn_filter.set("srgb", false); | ||||
| if (denoise_params_.prefilter == DENOISER_PREFILTER_NONE || | |||||
| denoise_params_.prefilter == DENOISER_PREFILTER_ACCURATE) { | |||||
| oidn_filter.set("cleanAux", true); | oidn_filter.set("cleanAux", true); | ||||
| } | |||||
| oidn_filter.commit(); | oidn_filter.commit(); | ||||
| filter_guiding_pass_if_needed(oidn_device, oidn_albedo_pass_); | filter_guiding_pass_if_needed(oidn_device, oidn_albedo_pass_); | ||||
| filter_guiding_pass_if_needed(oidn_device, oidn_normal_pass_); | filter_guiding_pass_if_needed(oidn_device, oidn_normal_pass_); | ||||
| /* Filter the beauty image. */ | /* Filter the beauty image. */ | ||||
| oidn_filter.execute(); | oidn_filter.execute(); | ||||
| /* Check for errors. */ | /* Check for errors. */ | ||||
| const char *error_message; | const char *error_message; | ||||
| if (oidn_device.getError(error_message) != oidn::Error::None) { | if (oidn_device.getError(error_message) != oidn::Error::None) { | ||||
| LOG(ERROR) << "OpenImageDenoise error: " << error_message; | LOG(ERROR) << "OpenImageDenoise error: " << error_message; | ||||
| } | } | ||||
| postprocess_output(oidn_color_pass, oidn_output_pass); | postprocess_output(oidn_color_pass, oidn_output_pass); | ||||
| } | } | ||||
| protected: | protected: | ||||
| void filter_guiding_pass_if_needed(oidn::DeviceRef &oidn_device, OIDNPass &oidn_pass) | void filter_guiding_pass_if_needed(oidn::DeviceRef &oidn_device, OIDNPass &oidn_pass) | ||||
| { | { | ||||
| if (!denoise_params_.use_prefilter || !oidn_pass || oidn_pass.is_filtered) { | if (denoise_params_.prefilter != DENOISER_PREFILTER_ACCURATE || !oidn_pass || | ||||
| oidn_pass.is_filtered) { | |||||
| return; | return; | ||||
| } | } | ||||
| oidn::FilterRef oidn_filter = oidn_device.newFilter("RT"); | oidn::FilterRef oidn_filter = oidn_device.newFilter("RT"); | ||||
| set_pass(oidn_filter, oidn_pass); | set_pass(oidn_filter, oidn_pass); | ||||
| set_output_pass(oidn_filter, oidn_pass); | set_output_pass(oidn_filter, oidn_pass); | ||||
| oidn_filter.commit(); | oidn_filter.commit(); | ||||
| oidn_filter.execute(); | oidn_filter.execute(); | ||||
| oidn_pass.is_filtered = true; | oidn_pass.is_filtered = true; | ||||
| } | } | ||||
| /* Make pixels of a guiding pass available by the denoiser. */ | /* Make pixels of a guiding pass available by the denoiser. */ | ||||
| void read_guiding_pass(OIDNPass &oidn_pass) | void read_guiding_pass(OIDNPass &oidn_pass) | ||||
| { | { | ||||
| if (!oidn_pass) { | if (!oidn_pass) { | ||||
| return; | return; | ||||
| } | } | ||||
| DCHECK(!oidn_pass.use_compositing); | DCHECK(!oidn_pass.use_compositing); | ||||
| if (!denoise_params_.use_prefilter && !is_pass_scale_needed(oidn_pass)) { | if (denoise_params_.prefilter != DENOISER_PREFILTER_ACCURATE && | ||||
| !is_pass_scale_needed(oidn_pass)) { | |||||
| /* Pass data is available as-is from the render buffers. */ | /* Pass data is available as-is from the render buffers. */ | ||||
| return; | return; | ||||
| } | } | ||||
| if (allow_inplace_modification_) { | if (allow_inplace_modification_) { | ||||
| scale_pass_in_render_buffers(oidn_pass); | scale_pass_in_render_buffers(oidn_pass); | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 350 Lines • Show Last 20 Lines | |||||