Fix: Sky models can return negative values
When converting from XYZ to RGB it can happen, in some sky models, that the resulting RGB values are negative. Atm, this is not considered and the returned values for the sky model can be negative. This patch clamps the returned RGB values to be `= 0.f` Reviewed By: brecht, sergey Differential Revision: https://developer.blender.org/D14777
This commit is contained in:
parent
110eb23005
commit
bd327e3bf3
|
@ -55,7 +55,7 @@ ccl_device float3 sky_radiance_preetham(KernelGlobals kg,
|
|||
|
||||
/* convert to RGB */
|
||||
float3 xyz = xyY_to_xyz(x, y, Y);
|
||||
return xyz_to_rgb(kg, xyz);
|
||||
return xyz_to_rgb_clamped(kg, xyz);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -107,7 +107,7 @@ ccl_device float3 sky_radiance_hosek(KernelGlobals kg,
|
|||
float z = sky_radiance_internal(config_z, theta, gamma) * radiance_z;
|
||||
|
||||
/* convert to RGB and adjust strength */
|
||||
return xyz_to_rgb(kg, make_float3(x, y, z)) * (M_2PI_F / 683);
|
||||
return xyz_to_rgb_clamped(kg, make_float3(x, y, z)) * (M_2PI_F / 683);
|
||||
}
|
||||
|
||||
/* Nishita improved sky model */
|
||||
|
@ -194,7 +194,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals kg,
|
|||
}
|
||||
|
||||
/* convert to RGB */
|
||||
return xyz_to_rgb(kg, xyz);
|
||||
return xyz_to_rgb_clamped(kg, xyz);
|
||||
}
|
||||
|
||||
ccl_device_noinline int svm_node_tex_sky(
|
||||
|
|
|
@ -14,6 +14,11 @@ ccl_device float3 xyz_to_rgb(KernelGlobals kg, float3 xyz)
|
|||
dot(float4_to_float3(kernel_data.film.xyz_to_b), xyz));
|
||||
}
|
||||
|
||||
ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, float3 xyz)
|
||||
{
|
||||
return max(xyz_to_rgb(kg, xyz), zero_float3());
|
||||
}
|
||||
|
||||
ccl_device float3 rec709_to_rgb(KernelGlobals kg, float3 rec709)
|
||||
{
|
||||
return (kernel_data.film.is_rec709) ?
|
||||
|
|
Loading…
Reference in New Issue