Blender  V3.3
COM_MultilayerImageOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 
6 #include "IMB_imbuf.h"
7 
8 namespace blender::compositor {
9 
11  RenderPass *render_pass,
12  int view)
13 {
14  pass_id_ = BLI_findindex(&render_layer->passes, render_pass);
15  view_ = view;
16  render_layer_ = render_layer;
17  render_pass_ = render_pass;
18 }
19 
21 {
22  /* temporarily changes the view to get the right ImBuf */
23  int view = image_user_->view;
24 
25  image_user_->view = view_;
26  image_user_->pass = pass_id_;
27 
31  return ibuf;
32  }
33 
35  return nullptr;
36 }
37 
39  const rcti &area,
41 {
42  output->copy_from(buffer_, area);
43 }
44 
45 std::unique_ptr<MetaData> MultilayerColorOperation::get_meta_data()
46 {
48  MetaDataExtractCallbackData callback_data = {nullptr};
49  RenderResult *render_result = image_->rr;
50  if (render_result && render_result->stamp_data) {
51  RenderLayer *render_layer = render_layer_;
52  RenderPass *render_pass = render_pass_;
53  std::string full_layer_name =
54  std::string(render_layer->name,
55  BLI_strnlen(render_layer->name, sizeof(render_layer->name))) +
56  "." +
57  std::string(render_pass->name, BLI_strnlen(render_pass->name, sizeof(render_pass->name)));
58  blender::StringRef cryptomatte_layer_name =
60  callback_data.set_cryptomatte_keys(cryptomatte_layer_name);
61 
62  BKE_stamp_info_callback(&callback_data,
63  render_result->stamp_data,
65  false);
66  }
67 
68  return std::move(callback_data.meta_data);
69 }
70 
72  float x,
73  float y,
75 {
76  if (image_float_buffer_ == nullptr) {
77  zero_v4(output);
78  }
79  else {
80  if (number_of_channels_ == 4) {
81  switch (sampler) {
84  break;
87  break;
90  break;
91  }
92  }
93  else {
94  int yi = y;
95  int xi = x;
96  if (xi < 0 || yi < 0 || (unsigned int)xi >= this->get_width() ||
97  (unsigned int)yi >= this->get_height()) {
98  zero_v4(output);
99  }
100  else {
101  int offset = (yi * this->get_width() + xi) * 3;
103  }
104  }
105  }
106 }
107 
109  float x,
110  float y,
111  PixelSampler /*sampler*/)
112 {
113  if (image_float_buffer_ == nullptr) {
114  output[0] = 0.0f;
115  }
116  else {
117  int yi = y;
118  int xi = x;
119  if (xi < 0 || yi < 0 || (unsigned int)xi >= this->get_width() ||
120  (unsigned int)yi >= this->get_height()) {
121  output[0] = 0.0f;
122  }
123  else {
124  float result = image_float_buffer_[yi * this->get_width() + xi];
125  output[0] = result;
126  }
127  }
128 }
129 
131  float x,
132  float y,
133  PixelSampler /*sampler*/)
134 {
135  if (image_float_buffer_ == nullptr) {
136  output[0] = 0.0f;
137  }
138  else {
139  int yi = y;
140  int xi = x;
141  if (xi < 0 || yi < 0 || (unsigned int)xi >= this->get_width() ||
142  (unsigned int)yi >= this->get_height()) {
143  output[0] = 0.0f;
144  }
145  else {
146  int offset = (yi * this->get_width() + xi) * 3;
148  }
149  }
150 }
151 
152 } // namespace blender::compositor
struct RenderPass * BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser)
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
#define BLI_assert(a)
Definition: BLI_assert.h:46
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:899
#define UNUSED(x)
static AppView * view
_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 bicubic_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:80
void nearest_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:278
void bilinear_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:128
struct RenderResult * rr
a MemoryBuffer contains access to the data of a chunk
MultilayerBaseOperation(RenderLayer *render_layer, RenderPass *render_pass, int view)
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
std::unique_ptr< MetaData > get_meta_data() override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
StringRef BKE_cryptomatte_extract_layer_name(const StringRef render_pass_name)
Definition: cryptomatte.cc:475
static void area(int d1, int d2, int e1, int e2, float weights[2])
static bNodeSocketTemplate inputs[]
ListBase passes
Definition: RE_pipeline.h:95
char name[RE_MAXNAME]
Definition: RE_pipeline.h:87
char name[64]
Definition: RE_pipeline.h:65
struct StampData * stamp_data
Definition: RE_pipeline.h:141
void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name)
Definition: COM_MetaData.cc:62
static void extract_cryptomatte_meta_data(void *_data, const char *propname, char *propvalue, int UNUSED(len))
Definition: COM_MetaData.cc:72