Cycles: restore Denoising Depth pass, when enabling Denoising Data passes

This is still useful in some cases even if not used by OpenImageDenoise. In
the future this may be replaced with a more generic system to control render
passes and filtering, but for now this just does what it did before.
This commit is contained in:
Brecht Van Lommel 2021-10-25 19:30:19 +02:00
parent 16a8d0fab0
commit eb1fed9d60
5 changed files with 23 additions and 2 deletions

View File

@ -541,6 +541,7 @@ static PassType get_blender_pass_type(BL::RenderPass &b_pass)
MAP_PASS("Denoising Normal", PASS_DENOISING_NORMAL);
MAP_PASS("Denoising Albedo", PASS_DENOISING_ALBEDO);
MAP_PASS("Denoising Depth", PASS_DENOISING_DEPTH);
MAP_PASS("Shadow Catcher", PASS_SHADOW_CATCHER);
MAP_PASS("Noisy Shadow Catcher", PASS_SHADOW_CATCHER);
@ -670,6 +671,9 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
b_engine.add_pass("Denoising Albedo", 3, "RGB", b_view_layer.name().c_str());
pass_add(scene, PASS_DENOISING_ALBEDO, "Denoising Albedo", PassMode::NOISY);
b_engine.add_pass("Denoising Depth", 1, "Z", b_view_layer.name().c_str());
pass_add(scene, PASS_DENOISING_DEPTH, "Denoising Depth", PassMode::NOISY);
}
/* Custom AOV passes. */

View File

@ -52,6 +52,14 @@ ccl_device_forceinline void kernel_write_denoising_features_surface(
ccl_global float *buffer = kernel_pass_pixel_render_buffer(kg, state, render_buffer);
if (kernel_data.film.pass_denoising_depth != PASS_UNUSED) {
const float3 denoising_feature_throughput = INTEGRATOR_STATE(
state, path, denoising_feature_throughput);
const float denoising_depth = ensure_finite(average(denoising_feature_throughput) *
sd->ray_length);
kernel_write_pass_float(buffer + kernel_data.film.pass_denoising_depth, denoising_depth);
}
float3 normal = zero_float3();
float3 diffuse_albedo = zero_float3();
float3 specular_albedo = zero_float3();

View File

@ -384,6 +384,7 @@ typedef enum PassType {
PASS_MIST,
PASS_DENOISING_NORMAL,
PASS_DENOISING_ALBEDO,
PASS_DENOISING_DEPTH,
/* PASS_SHADOW_CATCHER accumulates contribution of shadow catcher object which is not affected by
* any other object. The pass accessor will divide the combined pass by the shadow catcher. The
@ -1031,6 +1032,7 @@ typedef struct KernelFilm {
int pass_denoising_normal;
int pass_denoising_albedo;
int pass_denoising_depth;
int pass_aov_color;
int pass_aov_value;
@ -1047,7 +1049,7 @@ typedef struct KernelFilm {
int use_approximate_shadow_catcher;
int pad1, pad2, pad3;
int pad1, pad2;
} KernelFilm;
static_assert_align(KernelFilm, 16);

View File

@ -339,6 +339,9 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
case PASS_DENOISING_ALBEDO:
kfilm->pass_denoising_albedo = kfilm->pass_stride;
break;
case PASS_DENOISING_DEPTH:
kfilm->pass_denoising_depth = kfilm->pass_stride;
break;
case PASS_SHADOW_CATCHER:
kfilm->pass_shadow_catcher = kfilm->pass_stride;
@ -665,7 +668,7 @@ uint Film::get_kernel_features(const Scene *scene) const
const PassMode pass_mode = pass->get_mode();
if (pass_mode == PassMode::DENOISED || pass_type == PASS_DENOISING_NORMAL ||
pass_type == PASS_DENOISING_ALBEDO) {
pass_type == PASS_DENOISING_ALBEDO || pass_type == PASS_DENOISING_DEPTH) {
kernel_features |= KERNEL_FEATURE_DENOISING;
}

View File

@ -100,6 +100,7 @@ const NodeEnum *Pass::get_type_enum()
pass_type_enum.insert("mist", PASS_MIST);
pass_type_enum.insert("denoising_normal", PASS_DENOISING_NORMAL);
pass_type_enum.insert("denoising_albedo", PASS_DENOISING_ALBEDO);
pass_type_enum.insert("denoising_depth", PASS_DENOISING_DEPTH);
pass_type_enum.insert("shadow_catcher", PASS_SHADOW_CATCHER);
pass_type_enum.insert("shadow_catcher_sample_count", PASS_SHADOW_CATCHER_SAMPLE_COUNT);
@ -294,6 +295,9 @@ PassInfo Pass::get_info(const PassType type, const bool include_albedo)
case PASS_DENOISING_ALBEDO:
pass_info.num_components = 3;
break;
case PASS_DENOISING_DEPTH:
pass_info.num_components = 1;
break;
case PASS_SHADOW_CATCHER:
pass_info.num_components = 3;