Blender  V2.93
COM_GlareThresholdOperation.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 #include "BLI_math.h"
21 
22 #include "IMB_colormanagement.h"
23 
24 namespace blender::compositor {
25 
27 {
30  this->m_inputProgram = nullptr;
31 }
32 
33 void GlareThresholdOperation::determineResolution(unsigned int resolution[2],
34  unsigned int preferredResolution[2])
35 {
36  NodeOperation::determineResolution(resolution, preferredResolution);
37  resolution[0] = resolution[0] / (1 << this->m_settings->quality);
38  resolution[1] = resolution[1] / (1 << this->m_settings->quality);
39 }
40 
42 {
43  this->m_inputProgram = this->getInputSocketReader(0);
44 }
45 
47  float x,
48  float y,
49  PixelSampler sampler)
50 {
51  const float threshold = this->m_settings->threshold;
52 
53  this->m_inputProgram->readSampled(output, x, y, sampler);
54  if (IMB_colormanagement_get_luminance(output) >= threshold) {
55  output[0] -= threshold;
56  output[1] -= threshold;
57  output[2] -= threshold;
58 
59  output[0] = MAX2(output[0], 0.0f);
60  output[1] = MAX2(output[1], 0.0f);
61  output[2] = MAX2(output[2], 0.0f);
62  }
63  else {
64  zero_v3(output);
65  }
66 }
67 
69 {
70  this->m_inputProgram = nullptr;
71 }
72 
73 } // namespace blender::compositor
MINLINE void zero_v3(float r[3])
#define MAX2(a, b)
_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
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
#define output
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) override
determine the resolution of this node
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)
virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
determine the resolution of this node
SocketReader * getInputSocketReader(unsigned int inputSocketindex)
@ FitAny
Fit the width or the height of the input image to the width or height of the working area of the node...
float threshold