Fix T42391: HSV correction shader node gives negative values
This mainly happens when over-saturating already saturated color. After some discussion with Campbell and loads of tests we decided to clamp the result RGB color. As an alternative we might want to clamp corrected HSV values instead, but that would lead to some larger changes in the render results. TODO: The same is to be done for compositor nodes.
This commit is contained in:
parent
a6a3989617
commit
f9688d88ff
Notes:
blender-bot
2023-02-14 10:29:30 +01:00
Referenced by issue #42391, render output different from Viewport Rendered shading output.
|
@ -35,6 +35,11 @@ shader node_hsv(
|
|||
|
||||
Color = hsv_to_rgb(Color);
|
||||
|
||||
// Clamp color to prevent negative values cauzed by oversaturation.
|
||||
Color[0] = max(Color[0], 0.0);
|
||||
Color[1] = max(Color[1], 0.0);
|
||||
Color[2] = max(Color[2], 0.0);
|
||||
|
||||
ColorOut = mix(ColorIn, Color, Fac);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@ ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, ui
|
|||
color.y = fac*color.y + (1.0f - fac)*in_color.y;
|
||||
color.z = fac*color.z + (1.0f - fac)*in_color.z;
|
||||
|
||||
/* Clamp color to prevent negative values cauzed by oversaturation. */
|
||||
color.x = max(color.x, 0.0f);
|
||||
color.y = max(color.y, 0.0f);
|
||||
color.z = max(color.z, 0.0f);
|
||||
|
||||
if (stack_valid(out_color_offset))
|
||||
stack_store_float3(stack, out_color_offset, color);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue