Blender  V3.3
COM_GlareSimpleStarOperation.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  MemoryBuffer *input_tile,
10  NodeGlare *settings)
11 {
12  int i, x, y, ym, yp, xm, xp;
13  float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
14  const float f1 = 1.0f - settings->fade;
15  const float f2 = (1.0f - f1) * 0.5f;
16 
17  MemoryBuffer tbuf1(*input_tile);
18  MemoryBuffer tbuf2(*input_tile);
19 
20  bool breaked = false;
21  for (i = 0; i < settings->iter && (!breaked); i++) {
22  // // (x || x-1, y-1) to (x || x+1, y+1)
23  // // F
24  for (y = 0; y < this->get_height() && (!breaked); y++) {
25  ym = y - i;
26  yp = y + i;
27  for (x = 0; x < this->get_width(); x++) {
28  xm = x - i;
29  xp = x + i;
30  tbuf1.read(c, x, y);
31  mul_v3_fl(c, f1);
32  tbuf1.read(tc, (settings->star_45 ? xm : x), ym);
33  madd_v3_v3fl(c, tc, f2);
34  tbuf1.read(tc, (settings->star_45 ? xp : x), yp);
35  madd_v3_v3fl(c, tc, f2);
36  c[3] = 1.0f;
37  tbuf1.write_pixel(x, y, c);
38 
39  tbuf2.read(c, x, y);
40  mul_v3_fl(c, f1);
41  tbuf2.read(tc, xm, (settings->star_45 ? yp : y));
42  madd_v3_v3fl(c, tc, f2);
43  tbuf2.read(tc, xp, (settings->star_45 ? ym : y));
44  madd_v3_v3fl(c, tc, f2);
45  c[3] = 1.0f;
46  tbuf2.write_pixel(x, y, c);
47  }
48  if (is_braked()) {
49  breaked = true;
50  }
51  }
52  // // B
53  for (y = this->get_height() - 1; y >= 0 && (!breaked); y--) {
54  ym = y - i;
55  yp = y + i;
56  for (x = this->get_width() - 1; x >= 0; x--) {
57  xm = x - i;
58  xp = x + i;
59  tbuf1.read(c, x, y);
60  mul_v3_fl(c, f1);
61  tbuf1.read(tc, (settings->star_45 ? xm : x), ym);
62  madd_v3_v3fl(c, tc, f2);
63  tbuf1.read(tc, (settings->star_45 ? xp : x), yp);
64  madd_v3_v3fl(c, tc, f2);
65  c[3] = 1.0f;
66  tbuf1.write_pixel(x, y, c);
67 
68  tbuf2.read(c, x, y);
69  mul_v3_fl(c, f1);
70  tbuf2.read(tc, xm, (settings->star_45 ? yp : y));
71  madd_v3_v3fl(c, tc, f2);
72  tbuf2.read(tc, xp, (settings->star_45 ? ym : y));
73  madd_v3_v3fl(c, tc, f2);
74  c[3] = 1.0f;
75  tbuf2.write_pixel(x, y, c);
76  }
77  if (is_braked()) {
78  breaked = true;
79  }
80  }
81  }
82 
83  for (i = 0; i < this->get_width() * this->get_height() * 4; i++) {
84  data[i] = tbuf1.get_buffer()[i] + tbuf2.get_buffer()[i];
85  }
86 }
87 
88 } // namespace blender::compositor
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v3_fl(float r[3], float f)
_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 generate_glare(float *data, MemoryBuffer *input_tile, NodeGlare *settings) override
a MemoryBuffer contains access to the data of a chunk
void read(float *result, int x, int y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip)
void write_pixel(int x, int y, const float color[4])
float * get_buffer()
get the data of this MemoryBuffer
static unsigned c
Definition: RandGen.cpp:83
char angle star_45