Blender  V3.3
hsv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
7 
10  ccl_private float *stack,
11  uint4 node)
12 {
13  uint in_color_offset, fac_offset, out_color_offset;
14  uint hue_offset, sat_offset, val_offset;
15  svm_unpack_node_uchar3(node.y, &in_color_offset, &fac_offset, &out_color_offset);
16  svm_unpack_node_uchar3(node.z, &hue_offset, &sat_offset, &val_offset);
17 
18  float fac = stack_load_float(stack, fac_offset);
19  float3 in_color = stack_load_float3(stack, in_color_offset);
20  float3 color = in_color;
21 
22  float hue = stack_load_float(stack, hue_offset);
23  float sat = stack_load_float(stack, sat_offset);
24  float val = stack_load_float(stack, val_offset);
25 
27 
28  /* Remember: `fmodf` doesn't work for negative numbers here. */
29  color.x = fmodf(color.x + hue + 0.5f, 1.0f);
30  color.y = saturatef(color.y * sat);
31  color.z *= val;
32 
34 
35  color.x = fac * color.x + (1.0f - fac) * in_color.x;
36  color.y = fac * color.y + (1.0f - fac) * in_color.y;
37  color.z = fac * color.z + (1.0f - fac) * in_color.z;
38 
39  /* Clamp color to prevent negative values caused by over saturation. */
40  color.x = max(color.x, 0.0f);
41  color.y = max(color.y, 0.0f);
42  color.z = max(color.z, 0.0f);
43 
44  if (stack_valid(out_color_offset))
45  stack_store_float3(stack, out_color_offset, color);
46 }
47 
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:208
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:13
unsigned int uint
Definition: BLI_sys_types.h:67
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its hue
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_noinline
Definition: cuda/compat.h:40
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
OperationNode * node
const KernelGlobalsCPU *ccl_restrict KernelGlobals
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_hsv(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node)
Definition: hsv.h:8
ccl_device_inline void stack_store_float3(ccl_private float *stack, uint a, float3 f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(ccl_private float *stack, uint a)
ccl_device_forceinline void svm_unpack_node_uchar3(uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_inline float stack_load_float(ccl_private float *stack, uint a)
ccl_device_inline bool stack_valid(uint a)
ShaderData
Definition: kernel/types.h:925
#define fmodf(x, y)
Definition: metal/compat.h:230
float z
float y
float x
float max
ccl_device_inline float saturatef(float a)
Definition: util/math.h:404