Blender
V4.3
source
blender
compositor
operations
COM_GlareSimpleStarOperation.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#include "
COM_GlareSimpleStarOperation.h
"
6
7
namespace
blender::compositor
{
8
9
void
GlareSimpleStarOperation::generate_glare
(
float
*
data
,
10
MemoryBuffer
*input_tile,
11
const
NodeGlare
*settings)
12
{
13
int
i,
x
,
y
, ym, yp, xm, xp;
14
float
c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
15
const
float
f1 = 1.0f - settings->
fade
;
16
const
float
f2 = (1.0f - f1) * 0.5f;
17
18
MemoryBuffer
tbuf1(*input_tile);
19
MemoryBuffer
tbuf2(*input_tile);
20
21
bool
breaked =
false
;
22
for
(i = 0; i < settings->
iter
&& (!breaked); i++) {
23
// // (x || x-1, y-1) to (x || x+1, y+1)
24
// // F
25
for
(
y
= 0;
y
< this->
get_height
() && (!breaked);
y
++) {
26
ym =
y
- i;
27
yp =
y
+ i;
28
for
(
x
= 0;
x
< this->
get_width
(); x++) {
29
xm =
x
- i;
30
xp =
x
+ i;
31
tbuf1.
read
(c,
x
,
y
);
32
mul_v3_fl
(c, f1);
33
tbuf1.
read
(tc, (settings->
star_45
? xm :
x
), ym);
34
madd_v3_v3fl
(c, tc, f2);
35
tbuf1.
read
(tc, (settings->
star_45
? xp :
x
), yp);
36
madd_v3_v3fl
(c, tc, f2);
37
c[3] = 1.0f;
38
tbuf1.
write_pixel
(
x
,
y
, c);
39
40
tbuf2.
read
(c,
x
,
y
);
41
mul_v3_fl
(c, f1);
42
tbuf2.
read
(tc, xm, (settings->
star_45
? yp :
y
));
43
madd_v3_v3fl
(c, tc, f2);
44
tbuf2.
read
(tc, xp, (settings->
star_45
? ym :
y
));
45
madd_v3_v3fl
(c, tc, f2);
46
c[3] = 1.0f;
47
tbuf2.
write_pixel
(
x
,
y
, c);
48
}
49
if
(
is_braked
()) {
50
breaked =
true
;
51
}
52
}
53
// // B
54
for
(
y
= this->
get_height
() - 1; y >= 0 && (!breaked);
y
--) {
55
ym =
y
- i;
56
yp =
y
+ i;
57
for
(
x
= this->
get_width
() - 1; x >= 0;
x
--) {
58
xm =
x
- i;
59
xp =
x
+ i;
60
tbuf1.
read
(c,
x
,
y
);
61
mul_v3_fl
(c, f1);
62
tbuf1.
read
(tc, (settings->
star_45
? xm :
x
), ym);
63
madd_v3_v3fl
(c, tc, f2);
64
tbuf1.
read
(tc, (settings->
star_45
? xp :
x
), yp);
65
madd_v3_v3fl
(c, tc, f2);
66
c[3] = 1.0f;
67
tbuf1.
write_pixel
(
x
,
y
, c);
68
69
tbuf2.
read
(c,
x
,
y
);
70
mul_v3_fl
(c, f1);
71
tbuf2.
read
(tc, xm, (settings->
star_45
? yp :
y
));
72
madd_v3_v3fl
(c, tc, f2);
73
tbuf2.
read
(tc, xp, (settings->
star_45
? ym :
y
));
74
madd_v3_v3fl
(c, tc, f2);
75
c[3] = 1.0f;
76
tbuf2.
write_pixel
(
x
,
y
, c);
77
}
78
if
(
is_braked
()) {
79
breaked =
true
;
80
}
81
}
82
}
83
84
for
(i = 0; i < this->
get_width
() * this->
get_height
() * 4; i++) {
85
data
[i] = tbuf1.
get_buffer
()[i] + tbuf2.
get_buffer
()[i];
86
}
87
}
88
89
}
// namespace blender::compositor
x
x
Definition
BLI_expr_pylike_eval_test.cc:345
madd_v3_v3fl
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
Definition
math_vector_inline.c:673
mul_v3_fl
MINLINE void mul_v3_fl(float r[3], float f)
Definition
math_vector_inline.c:546
COM_GlareSimpleStarOperation.h
data
data
Definition
bmesh_operator_api_inline.hh:159
blender::compositor::GlareSimpleStarOperation::generate_glare
void generate_glare(float *data, MemoryBuffer *input_tile, const NodeGlare *settings) override
Definition
COM_GlareSimpleStarOperation.cc:9
blender::compositor::MemoryBuffer
a MemoryBuffer contains access to the data
Definition
COM_MemoryBuffer.h:35
blender::compositor::MemoryBuffer::read
void read(float *result, float x, float y, PixelSampler sampler=PixelSampler::Nearest, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip) const
Definition
COM_MemoryBuffer.h:424
blender::compositor::MemoryBuffer::write_pixel
void write_pixel(int x, int y, const float color[4])
Definition
COM_MemoryBuffer.cc:408
blender::compositor::MemoryBuffer::get_buffer
float * get_buffer()
get the data of this MemoryBuffer
Definition
COM_MemoryBuffer.h:367
blender::compositor::NodeOperation::get_height
unsigned int get_height() const
Definition
COM_NodeOperation.h:465
blender::compositor::NodeOperation::get_width
unsigned int get_width() const
Definition
COM_NodeOperation.h:460
blender::compositor::NodeOperation::is_braked
bool is_braked() const
Definition
COM_NodeOperation.h:448
y
y
Definition
compositor_morphological_blur_info.hh:15
blender::compositor
Definition
COM_JumpFloodingAlgorithm.cc:20
NodeGlare
Definition
DNA_node_types.h:1215
NodeGlare::iter
char iter
Definition
DNA_node_types.h:1216
NodeGlare::star_45
char angle star_45
Definition
DNA_node_types.h:1219
NodeGlare::fade
float fade
Definition
DNA_node_types.h:1220
Generated on Sat Oct 4 2025 05:32:23 for Blender by
doxygen
1.14.0