Blender V5.3
hsv.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8#include "kernel/svm/util.h"
9
10#include "util/color.h"
11
13
16{
17 const float fac = stack_load(stack, node.fac);
18 const float3 in_color = stack_load(stack, node.color);
19 float3 color = in_color;
20
21 const float hue = stack_load(stack, node.hue);
22 const float sat = stack_load(stack, node.sat);
23 const float val = stack_load(stack, node.val);
24
25 color = rgb_to_hsv(color);
26
27 color.x = fractf(color.x + hue + 0.5f);
28 color.y = saturatef(color.y * sat);
29 color.z *= val;
30
31 color = hsv_to_rgb(color);
32
33 color.x = fac * color.x + (1.0f - fac) * in_color.x;
34 color.y = fac * color.y + (1.0f - fac) * in_color.y;
35 color.z = fac * color.z + (1.0f - fac) * in_color.z;
36
37 /* Clamp color to prevent negative values caused by over saturation. */
38 color.x = max(color.x, 0.0f);
39 color.y = max(color.y, 0.0f);
40 color.z = max(color.z, 0.0f);
41
42 if (stack_valid(node.out_color_offset)) {
43 stack_store_float3(stack, node.out_color_offset, color);
44 }
45}
46
btScalar max
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline bool stack_valid(const uint a)
ccl_device_inline T stack_load(const ccl_private float *stack, const uint a)
#define ccl_restrict
#define ccl_private
#define ccl_global
#define ccl_device_noinline
#define CCL_NAMESPACE_END
#define saturatef(x)
void rgb_to_hsv(float4 rgb, float4 &outcol)
void hsv_to_rgb(float4 hsv, float4 &outcol)
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_hsv(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeHSV &ccl_restrict node)
Definition hsv.h:14
#define fractf
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136