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.
This commit is contained in:
parent
b45f410b31
commit
967f96ee2e
Notes:
blender-bot
2023-02-14 00:13:36 +01:00
Referenced by issue #98270, Regression: Nishita Sky - Black Sun Disc(Cycles)
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue