Blender  V3.3
COM_AlphaOverMixedOperation.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 namespace blender::compositor {
7 
9 {
10  x_ = 0.0f;
11  flags_.can_be_constant = true;
12 }
13 
15  float x,
16  float y,
18 {
19  float input_color1[4];
20  float input_over_color[4];
21  float value[4];
22 
25  input_color2_operation_->read_sampled(input_over_color, x, y, sampler);
26 
27  if (input_over_color[3] <= 0.0f) {
28  copy_v4_v4(output, input_color1);
29  }
30  else if (value[0] == 1.0f && input_over_color[3] >= 1.0f) {
31  copy_v4_v4(output, input_over_color);
32  }
33  else {
34  float addfac = 1.0f - x_ + input_over_color[3] * x_;
35  float premul = value[0] * addfac;
36  float mul = 1.0f - value[0] * input_over_color[3];
37 
38  output[0] = (mul * input_color1[0]) + premul * input_over_color[0];
39  output[1] = (mul * input_color1[1]) + premul * input_over_color[1];
40  output[2] = (mul * input_color1[2]) + premul * input_over_color[2];
41  output[3] = (mul * input_color1[3]) + value[0] * input_over_color[3];
42  }
43 }
44 
46 {
47  for (; p.out < p.row_end; p.next()) {
48  const float *color1 = p.color1;
49  const float *over_color = p.color2;
50  const float value = *p.value;
51 
52  if (over_color[3] <= 0.0f) {
53  copy_v4_v4(p.out, color1);
54  }
55  else if (value == 1.0f && over_color[3] >= 1.0f) {
56  copy_v4_v4(p.out, over_color);
57  }
58  else {
59  const float addfac = 1.0f - x_ + over_color[3] * x_;
60  const float premul = value * addfac;
61  const float mul = 1.0f - value * over_color[3];
62 
63  p.out[0] = (mul * color1[0]) + premul * over_color[0];
64  p.out[1] = (mul * color1[1]) + premul * over_color[1];
65  p.out[2] = (mul * color1[2]) + premul * over_color[2];
66  p.out[3] = (mul * color1[3]) + value * over_color[3];
67  }
68  }
69 }
70 
71 } // namespace blender::compositor
MINLINE void copy_v4_v4(float r[4], const float a[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
static void mul(btAlignedObjectArray< T > &items, const Q &value)
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output