From 726bc3a46b2fcf6ba36c3e3484b344340f83e53e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 24 Nov 2021 17:06:32 +0100 Subject: Fix T93155: Approximate shadow catcher displayed wrong on CPU and GPU Was happening during rendering, causing visual artifacts when doing CPU+GPU rendering, and giving different in-progress results on different devices. The root of the issue comes to the fact that math used in the approximate shadow catcher calculation might have resulted in negative alpha channel, and negative values for display are handled differently on CPU and GPU. Such difference in handling is caused by an approximate conversion used on the CPU for the performance reasons. This change makes it so no negative alpha is generated by the approximate shadow catcher. Not sure if we need some explicit clamping somewhere to deal with possible negative values coming from somewhere else. The shadow catcher cornell box tests are to be updated for the new code, but the new result seems to be more accurate. Differential Revision: https://developer.blender.org/D13354 --- intern/cycles/kernel/film/read.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h index d308a9818e2..18a593a75b1 100644 --- a/intern/cycles/kernel/film/read.h +++ b/intern/cycles/kernel/film/read.h @@ -460,7 +460,7 @@ ccl_device_inline float4 film_calculate_shadow_catcher_matte_with_shadow( const float transparency = in_matte[3] * scale; const float alpha = saturatef(1.0f - transparency); - const float alpha_matte = (1.0f - alpha) * (1.0f - average(shadow_catcher)) + alpha; + const float alpha_matte = (1.0f - alpha) * (1.0f - saturatef(average(shadow_catcher))) + alpha; if (kfilm_convert->use_approximate_shadow_catcher_background) { kernel_assert(kfilm_convert->pass_background != PASS_UNUSED); -- cgit v1.2.3