Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-05-27 21:11:23 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-05-27 21:14:15 +0300
commit967f96ee2e2ed454034f3e6be53fc7259f9016d0 (patch)
treefe425bc5b7d63a900d21e71673d45c7a8ca4589c /intern
parentb45f410b3157cb13e7ff4d88dcf5557d2621b9c3 (diff)
Fix T98270: Cycles shows black with color values > 65K in GPU render
After recent changes to Nishita sky to clamp negative colors, the pixels ended up a bit brighter which lead to them exceeding the half float max value. The CUDA float to half function seems to need clamping.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/util/half.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/intern/cycles/util/half.h b/intern/cycles/util/half.h
index 59ed652b346..434bc12d670 100644
--- a/intern/cycles/util/half.h
+++ b/intern/cycles/util/half.h
@@ -74,9 +74,9 @@ struct half4 {
ccl_device_inline half float_to_half_image(float f)
{
#if defined(__KERNEL_METAL__)
- return half(f);
+ return half(min(f, 65504.0f));
#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
- return __float2half(f);
+ return __float2half(min(f, 65504.0f));
#else
const uint u = __float_as_uint(f);
/* Sign bit, shifted to its position. */
@@ -137,9 +137,9 @@ ccl_device_inline float4 half4_to_float4_image(const half4 h)
ccl_device_inline half float_to_half_display(const float f)
{
#if defined(__KERNEL_METAL__)
- return half(f);
+ return half(min(f, 65504.0f));
#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
- return __float2half(f);
+ return __float2half(min(f, 65504.0f));
#else
const int x = __float_as_int((f > 0.0f) ? ((f < 65504.0f) ? f : 65504.0f) : 0.0f);
const int absolute = x & 0x7FFFFFFF;