Blender  V2.93
COM_GlareSimpleStarOperation.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 2011, Blender Foundation.
17  */
18 
20 
21 namespace blender::compositor {
22 
24  MemoryBuffer *inputTile,
25  NodeGlare *settings)
26 {
27  int i, x, y, ym, yp, xm, xp;
28  float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
29  const float f1 = 1.0f - settings->fade;
30  const float f2 = (1.0f - f1) * 0.5f;
31 
32  MemoryBuffer tbuf1(*inputTile);
33  MemoryBuffer tbuf2(*inputTile);
34 
35  bool breaked = false;
36  for (i = 0; i < settings->iter && (!breaked); i++) {
37  // // (x || x-1, y-1) to (x || x+1, y+1)
38  // // F
39  for (y = 0; y < this->getHeight() && (!breaked); y++) {
40  ym = y - i;
41  yp = y + i;
42  for (x = 0; x < this->getWidth(); x++) {
43  xm = x - i;
44  xp = x + i;
45  tbuf1.read(c, x, y);
46  mul_v3_fl(c, f1);
47  tbuf1.read(tc, (settings->star_45 ? xm : x), ym);
48  madd_v3_v3fl(c, tc, f2);
49  tbuf1.read(tc, (settings->star_45 ? xp : x), yp);
50  madd_v3_v3fl(c, tc, f2);
51  c[3] = 1.0f;
52  tbuf1.writePixel(x, y, c);
53 
54  tbuf2.read(c, x, y);
55  mul_v3_fl(c, f1);
56  tbuf2.read(tc, xm, (settings->star_45 ? yp : y));
57  madd_v3_v3fl(c, tc, f2);
58  tbuf2.read(tc, xp, (settings->star_45 ? ym : y));
59  madd_v3_v3fl(c, tc, f2);
60  c[3] = 1.0f;
61  tbuf2.writePixel(x, y, c);
62  }
63  if (isBraked()) {
64  breaked = true;
65  }
66  }
67  // // B
68  for (y = this->getHeight() - 1; y >= 0 && (!breaked); y--) {
69  ym = y - i;
70  yp = y + i;
71  for (x = this->getWidth() - 1; x >= 0; x--) {
72  xm = x - i;
73  xp = x + i;
74  tbuf1.read(c, x, y);
75  mul_v3_fl(c, f1);
76  tbuf1.read(tc, (settings->star_45 ? xm : x), ym);
77  madd_v3_v3fl(c, tc, f2);
78  tbuf1.read(tc, (settings->star_45 ? xp : x), yp);
79  madd_v3_v3fl(c, tc, f2);
80  c[3] = 1.0f;
81  tbuf1.writePixel(x, y, c);
82 
83  tbuf2.read(c, x, y);
84  mul_v3_fl(c, f1);
85  tbuf2.read(tc, xm, (settings->star_45 ? yp : y));
86  madd_v3_v3fl(c, tc, f2);
87  tbuf2.read(tc, xp, (settings->star_45 ? ym : y));
88  madd_v3_v3fl(c, tc, f2);
89  c[3] = 1.0f;
90  tbuf2.writePixel(x, y, c);
91  }
92  if (isBraked()) {
93  breaked = true;
94  }
95  }
96  }
97 
98  for (i = 0; i < this->getWidth() * this->getHeight() * 4; i++) {
99  data[i] = tbuf1.getBuffer()[i] + tbuf2.getBuffer()[i];
100  }
101 }
102 
103 } // 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 generateGlare(float *data, MemoryBuffer *inputTile, 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 writePixel(int x, int y, const float color[4])
float * getBuffer()
get the data of this MemoryBuffer
static unsigned c
Definition: RandGen.cpp:97
char angle star_45