Blender  V2.93
COM_HueSaturationValueCorrectOperation.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
20 
21 #include "BLI_math.h"
22 
23 #include "BKE_colortools.h"
24 
25 namespace blender::compositor {
26 
28 {
31 
32  this->m_inputProgram = nullptr;
33 }
35 {
37  this->m_inputProgram = this->getInputSocketReader(0);
38 }
39 
41  float x,
42  float y,
43  PixelSampler sampler)
44 {
45  float hsv[4], f;
46 
47  this->m_inputProgram->readSampled(hsv, x, y, sampler);
48 
49  /* adjust hue, scaling returned default 0.5 up to 1 */
50  f = BKE_curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
51  hsv[0] += f - 0.5f;
52 
53  /* adjust saturation, scaling returned default 0.5 up to 1 */
54  f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
55  hsv[1] *= (f * 2.0f);
56 
57  /* adjust value, scaling returned default 0.5 up to 1 */
58  f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
59  hsv[2] *= (f * 2.0f);
60 
61  hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
62  CLAMP(hsv[1], 0.0f, 1.0f);
63 
64  output[0] = hsv[0];
65  output[1] = hsv[1];
66  output[2] = hsv[2];
67  output[3] = hsv[3];
68 }
69 
71 {
73  this->m_inputProgram = nullptr;
74 }
75 
76 } // namespace blender::compositor
float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Group RGB to Bright Vector Camera CLAMP
#define output
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
void readSampled(float result[4], float x, float y, PixelSampler sampler)
void addInputSocket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void addOutputSocket(DataType datatype)
SocketReader * getInputSocketReader(unsigned int inputSocketindex)
#define floorf(x)