Blender  V3.3
COM_CryptomatteOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2018 Blender Foundation. */
3 
5 
6 namespace blender::compositor {
7 
9 {
10  inputs.resize(num_inputs);
11  for (size_t i = 0; i < num_inputs; i++) {
13  }
15  flags_.complex = true;
16 }
17 
19 {
20  for (size_t i = 0; i < inputs.size(); i++) {
21  inputs[i] = this->get_input_socket_reader(i);
22  }
23 }
24 
26 {
27  if (object_index != 0.0f) {
28  object_index_.append(object_index);
29  }
30 }
31 
32 void CryptomatteOperation::execute_pixel(float output[4], int x, int y, void *data)
33 {
34  float input[4];
35  output[0] = output[1] = output[2] = output[3] = 0.0f;
36  for (size_t i = 0; i < inputs.size(); i++) {
37  inputs[i]->read(input, x, y, data);
38  if (i == 0) {
39  /* Write the front-most object as false color for picking. */
40  output[0] = input[0];
41  uint32_t m3hash;
42  ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
43  /* Since the red channel is likely to be out of display range,
44  * setting green and blue gives more meaningful images. */
45  output[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
46  output[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
47  }
48  for (float hash : object_index_) {
49  if (input[0] == hash) {
50  output[3] += input[1];
51  }
52  if (input[2] == hash) {
53  output[3] += input[3];
54  }
55  }
56  }
57 }
58 
60  const rcti &area,
62 {
63  for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
64  zero_v4(it.out);
65  for (int i = 0; i < it.get_num_inputs(); i++) {
66  const float *input = it.in(i);
67  if (i == 0) {
68  /* Write the front-most object as false color for picking. */
69  it.out[0] = input[0];
70  uint32_t m3hash;
71  ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
72  /* Since the red channel is likely to be out of display range,
73  * setting green and blue gives more meaningful images. */
74  it.out[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
75  it.out[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
76  }
77  for (const float hash : object_index_) {
78  if (input[0] == hash) {
79  it.out[3] += input[1];
80  }
81  if (input[2] == hash) {
82  it.out[3] += input[3];
83  }
84  }
85  }
86  }
87 }
88 
89 } // namespace blender::compositor
typedef float(TangentPoint)[2]
MINLINE void zero_v4(float r[4])
_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
void append(const T &value)
Definition: BLI_vector.hh:433
void execute_pixel(float output[4], int x, int y, void *data) override
calculate a single pixel
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
a MemoryBuffer contains access to the data of a chunk
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
static void area(int d1, int d2, int e1, int e2, float weights[2])
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
static bNodeSocketTemplate inputs[]
#define hash
Definition: noise.c:153
unsigned int uint32_t
Definition: stdint.h:80
#define UINT32_MAX
Definition: stdint.h:142