Fix T74572: adaptive sampling not scaling AOVs correctly

This commit is contained in:
Brecht Van Lommel 2020-04-06 22:37:50 +02:00
parent e05552f7c4
commit 10f0e003a9
Notes: blender-bot 2023-02-14 06:00:50 +01:00
Referenced by issue #75480, Instant crash when opening any node editor
Referenced by issue #75464, Screen Space Reflections in EEVEE not working when using a Mix Node.
Referenced by issue #74572, Adaptive sampling breaks value Shader AOV's
3 changed files with 20 additions and 7 deletions

View File

@ -150,6 +150,7 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals *kg,
}
#endif /* __DENOISING_FEATURES__ */
/* Cryptomatte. */
if (kernel_data.film.cryptomatte_passes) {
int num_slots = 0;
num_slots += (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) ? 1 : 0;
@ -162,6 +163,14 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals *kg,
id_buffer[slot].y *= sample_multiplier;
}
}
/* AOVs. */
for (int i = 0; i < kernel_data.film.pass_aov_value_num; i++) {
*(buffer + kernel_data.film.pass_aov_value + i) *= sample_multiplier;
}
for (int i = 0; i < kernel_data.film.pass_aov_color_num; i++) {
*((ccl_global float4 *)(buffer + kernel_data.film.pass_aov_color) + i) *= sample_multiplier;
}
}
/* This is a simple box filter in two passes.

View File

@ -1242,7 +1242,9 @@ typedef struct KernelFilm {
int pass_aov_color;
int pass_aov_value;
int pad1;
int pass_aov_color_num;
int pass_aov_value_num;
int pad1, pad2, pad3;
/* XYZ to rendering color space transform. float4 instead of float3 to
* ensure consistent padding/alignment across devices. */
@ -1265,7 +1267,7 @@ typedef struct KernelFilm {
int use_display_exposure;
int use_display_pass_alpha;
int pad3, pad4, pad5;
int pad4, pad5, pad6;
} KernelFilm;
static_assert_align(KernelFilm, 16);

View File

@ -362,8 +362,10 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->light_pass_flag = 0;
kfilm->pass_stride = 0;
kfilm->use_light_pass = use_light_visibility;
kfilm->pass_aov_value_num = 0;
kfilm->pass_aov_color_num = 0;
bool have_cryptomatte = false, have_aov_color = false, have_aov_value = false;
bool have_cryptomatte = false;
for (size_t i = 0; i < passes.size(); i++) {
Pass &pass = passes[i];
@ -498,16 +500,16 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_sample_count = kfilm->pass_stride;
break;
case PASS_AOV_COLOR:
if (!have_aov_color) {
if (kfilm->pass_aov_value_num == 0) {
kfilm->pass_aov_color = kfilm->pass_stride;
have_aov_color = true;
}
kfilm->pass_aov_value_num++;
break;
case PASS_AOV_VALUE:
if (!have_aov_value) {
if (kfilm->pass_aov_color_num == 0) {
kfilm->pass_aov_value = kfilm->pass_stride;
have_aov_value = true;
}
kfilm->pass_aov_color_num++;
break;
default:
assert(false);