Blender  V2.93
COM_CryptomatteOperation.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 2018, Blender Foundation.
17  */
18 
20 
21 namespace blender::compositor {
22 
24 {
25  inputs.resize(num_inputs);
26  for (size_t i = 0; i < num_inputs; i++) {
28  }
30  this->flags.complex = true;
31 }
32 
34 {
35  for (size_t i = 0; i < inputs.size(); i++) {
36  inputs[i] = this->getInputSocketReader(i);
37  }
38 }
39 
40 void CryptomatteOperation::addObjectIndex(float objectIndex)
41 {
42  if (objectIndex != 0.0f) {
43  m_objectIndex.append(objectIndex);
44  }
45 }
46 
47 void CryptomatteOperation::executePixel(float output[4], int x, int y, void *data)
48 {
49  float input[4];
50  output[0] = output[1] = output[2] = output[3] = 0.0f;
51  for (size_t i = 0; i < inputs.size(); i++) {
52  inputs[i]->read(input, x, y, data);
53  if (i == 0) {
54  /* Write the front-most object as false color for picking. */
55  output[0] = input[0];
56  uint32_t m3hash;
57  ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
58  /* Since the red channel is likely to be out of display range,
59  * setting green and blue gives more meaningful images. */
60  output[1] = ((float)((m3hash << 8)) / (float)UINT32_MAX);
61  output[2] = ((float)((m3hash << 16)) / (float)UINT32_MAX);
62  }
63  for (float hash : m_objectIndex) {
64  if (input[0] == hash) {
65  output[3] += input[1];
66  }
67  if (input[2] == hash) {
68  output[3] += input[3];
69  }
70  }
71  }
72 }
73 
74 } // namespace blender::compositor
typedef float(TangentPoint)[2]
_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
#define output
void append(const T &value)
Definition: BLI_vector.hh:438
void executePixel(float output[4], int x, int y, void *data) override
calculate a single pixel
void addInputSocket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void addOutputSocket(DataType datatype)
SocketReader * getInputSocketReader(unsigned int inputSocketindex)
#define hash
Definition: noise.c:169
unsigned int uint32_t
Definition: stdint.h:83
#define UINT32_MAX
Definition: stdint.h:145