From c56cf50bd0b68ccbdba17fe715278f08a9cef7e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 9 Nov 2021 13:04:37 +0100 Subject: Fix T92876: Cycles incorrect volume emission + absorption handling --- intern/cycles/kernel/film/accumulate.h | 3 +-- intern/cycles/kernel/integrator/shade_background.h | 2 +- intern/cycles/kernel/integrator/shade_light.h | 2 +- intern/cycles/kernel/integrator/shade_surface.h | 2 +- intern/cycles/kernel/integrator/shade_volume.h | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/intern/cycles/kernel/film/accumulate.h b/intern/cycles/kernel/film/accumulate.h index 30e1afea751..33f913a6746 100644 --- a/intern/cycles/kernel/film/accumulate.h +++ b/intern/cycles/kernel/film/accumulate.h @@ -540,11 +540,10 @@ ccl_device_inline void kernel_accum_background(KernelGlobals kg, /* Write emission to render buffer. */ ccl_device_inline void kernel_accum_emission(KernelGlobals kg, ConstIntegratorState state, - const float3 throughput, const float3 L, ccl_global float *ccl_restrict render_buffer) { - float3 contribution = throughput * L; + float3 contribution = L; kernel_accum_clamp(kg, &contribution, INTEGRATOR_STATE(state, path, bounce) - 1); ccl_global float *buffer = kernel_accum_pixel_render_buffer(kg, state, render_buffer); diff --git a/intern/cycles/kernel/integrator/shade_background.h b/intern/cycles/kernel/integrator/shade_background.h index 24482e85b05..31452de1ca4 100644 --- a/intern/cycles/kernel/integrator/shade_background.h +++ b/intern/cycles/kernel/integrator/shade_background.h @@ -175,7 +175,7 @@ ccl_device_inline void integrate_distant_lights(KernelGlobals kg, /* Write to render buffer. */ const float3 throughput = INTEGRATOR_STATE(state, path, throughput); - kernel_accum_emission(kg, state, throughput, light_eval, render_buffer); + kernel_accum_emission(kg, state, throughput * light_eval, render_buffer); } } } diff --git a/intern/cycles/kernel/integrator/shade_light.h b/intern/cycles/kernel/integrator/shade_light.h index 7dad3b4e49d..5abe9e98abc 100644 --- a/intern/cycles/kernel/integrator/shade_light.h +++ b/intern/cycles/kernel/integrator/shade_light.h @@ -90,7 +90,7 @@ ccl_device_inline void integrate_light(KernelGlobals kg, /* Write to render buffer. */ const float3 throughput = INTEGRATOR_STATE(state, path, throughput); - kernel_accum_emission(kg, state, throughput, light_eval, render_buffer); + kernel_accum_emission(kg, state, throughput * light_eval, render_buffer); } ccl_device void integrator_shade_light(KernelGlobals kg, diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index d9006e71ce0..e6fe5a87120 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -101,7 +101,7 @@ ccl_device_forceinline void integrate_surface_emission(KernelGlobals kg, } const float3 throughput = INTEGRATOR_STATE(state, path, throughput); - kernel_accum_emission(kg, state, throughput, L, render_buffer); + kernel_accum_emission(kg, state, throughput * L, render_buffer); } #endif /* __EMISSION__ */ diff --git a/intern/cycles/kernel/integrator/shade_volume.h b/intern/cycles/kernel/integrator/shade_volume.h index 412be289ebe..86d712cdf32 100644 --- a/intern/cycles/kernel/integrator/shade_volume.h +++ b/intern/cycles/kernel/integrator/shade_volume.h @@ -608,7 +608,7 @@ ccl_device_forceinline void volume_integrate_heterogeneous( if (!result.indirect_scatter) { const float3 emission = volume_emission_integrate( &coeff, closure_flag, transmittance, dt); - accum_emission += emission; + accum_emission += result.indirect_throughput * emission; } } @@ -661,7 +661,7 @@ ccl_device_forceinline void volume_integrate_heterogeneous( /* Write accumulated emission. */ if (!is_zero(accum_emission)) { - kernel_accum_emission(kg, state, result.indirect_throughput, accum_emission, render_buffer); + kernel_accum_emission(kg, state, accum_emission, render_buffer); } # ifdef __DENOISING_FEATURES__ -- cgit v1.2.3 From 45bd98d4cff4ff5889595af8cae5d2d94a7868a1 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 9 Nov 2021 13:30:15 +0100 Subject: Fix T92934: crash rendering with wrong image path These null checks were missing in rB0c3b215e7d5456878b155d13440864f49ad1f230. Differential Revision: https://developer.blender.org/D13157 --- source/blender/blenkernel/intern/image.c | 6 ++++++ source/blender/imbuf/intern/moviecache.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index c9ac1f32804..311199f8833 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1304,6 +1304,9 @@ void BKE_image_print_memlist(Main *bmain) static bool imagecache_check_dirty(ImBuf *ibuf, void *UNUSED(userkey), void *UNUSED(userdata)) { + if (ibuf == NULL) { + return false; + } return (ibuf->userflags & IB_BITMAPDIRTY) == 0; } @@ -1347,6 +1350,9 @@ void BKE_image_free_all_textures(Main *bmain) static bool imagecache_check_free_anim(ImBuf *ibuf, void *UNUSED(userkey), void *userdata) { + if (ibuf == NULL) { + return true; + } int except_frame = *(int *)userdata; return (ibuf->userflags & IB_BITMAPDIRTY) == 0 && (ibuf->index != IMA_NO_INDEX) && (except_frame != IMA_INDEX_ENTRY(ibuf->index)); diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 6e7b85a300a..4f316150e10 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -237,6 +237,9 @@ static int get_item_priority(void *item_v, int default_priority) static bool get_item_destroyable(void *item_v) { MovieCacheItem *item = (MovieCacheItem *)item_v; + if (item->ibuf == NULL) { + return true; + } /* IB_BITMAPDIRTY means image was modified from inside blender and * changes are not saved to disk. * -- cgit v1.2.3