28 sizeavailable_ =
false;
29 input_program_ =
nullptr;
30 input_bokeh_program_ =
nullptr;
31 input_bounding_box_reader_ =
nullptr;
33 extend_bounds_ =
false;
48 bokeh_mid_x_ =
width / 2.0f;
49 bokeh_mid_y_ =
height / 2.0f;
50 bokehDimension_ = dimension / 2.0f;
56 if (!sizeavailable_) {
78 float temp_bounding_box[4];
82 if (temp_bounding_box[0] > 0.0f) {
83 float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
87 int bufferwidth = input_buffer->
get_width();
88 int bufferstartx = input_rect.
xmin;
89 int bufferstarty = input_rect.
ymin;
91 int pixel_size = size_ * max_dim / 100.0f;
96 multiplier_accum[0] = 1.0f;
97 multiplier_accum[1] = 1.0f;
98 multiplier_accum[2] = 1.0f;
99 multiplier_accum[3] = 1.0f;
101 int miny =
y - pixel_size;
102 int maxy =
y + pixel_size;
103 int minx =
x - pixel_size;
104 int maxx =
x + pixel_size;
113 float m = bokehDimension_ / pixel_size;
114 for (
int ny = miny;
ny < maxy;
ny += step) {
117 for (
int nx = minx; nx < maxx; nx += step) {
118 float u = bokeh_mid_x_ - (nx -
x) * m;
119 float v = bokeh_mid_y_ - (
ny -
y) * m;
123 bufferindex += offsetadd;
126 output[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
127 output[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
128 output[2] = color_accum[2] * (1.0f / multiplier_accum[2]);
129 output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
139 input_program_ =
nullptr;
140 input_bokeh_program_ =
nullptr;
141 input_bounding_box_reader_ =
nullptr;
152 if (sizeavailable_) {
153 new_input.
xmax =
input->xmax + (size_ * max_dim / 100.0f);
154 new_input.
xmin =
input->xmin - (size_ * max_dim / 100.0f);
155 new_input.
ymax =
input->ymax + (size_ * max_dim / 100.0f);
156 new_input.
ymin =
input->ymin - (size_ * max_dim / 100.0f);
159 new_input.
xmax =
input->xmax + (10.0f * max_dim / 100.0f);
160 new_input.
xmin =
input->xmin - (10.0f * max_dim / 100.0f);
161 new_input.
ymax =
input->ymax + (10.0f * max_dim / 100.0f);
162 new_input.
ymin =
input->ymin - (10.0f * max_dim / 100.0f);
167 bokeh_input.
xmin = 0;
169 bokeh_input.
ymin = 0;
181 if (!sizeavailable_) {
197 cl_mem cl_output_buffer,
199 std::list<cl_mem> *cl_mem_to_clean_up,
200 std::list<cl_kernel> * )
203 if (!sizeavailable_) {
207 cl_int radius = size_ * max_dim / 100.0f;
211 kernel, 0, -1, cl_mem_to_clean_up, input_memory_buffers, input_bounding_box_reader_);
213 kernel, 1, 4, cl_mem_to_clean_up, input_memory_buffers, input_program_);
215 kernel, 2, -1, cl_mem_to_clean_up, input_memory_buffers, input_bokeh_program_);
218 clSetKernelArg(
kernel, 6,
sizeof(cl_int), &radius);
219 clSetKernelArg(
kernel, 7,
sizeof(cl_int), &step);
225 void BokehBlurOperation::update_size()
227 if (sizeavailable_) {
236 CLAMP(size_, 0.0f, 10.0f);
241 if (size_input->get_flags().is_constant_operation) {
242 size_ = *
static_cast<ConstantOperation *
>(size_input)->get_constant_elem();
243 CLAMP(size_, 0.0f, 10.0f);
248 sizeavailable_ =
true;
253 if (!extend_bounds_) {
262 r_area.
xmax += 2 * size_ * max_dim / 100.0f;
263 r_area.
ymax += 2 * size_ * max_dim / 100.0f;
270 float add_size =
round_to_even(2 * size_ * max_dim / 100.0f);
271 canvas.
xmax += add_size;
272 canvas.
ymax += add_size;
281 const rcti &output_area,
287 const float add_size = size_ * max_dim / 100.0f;
288 r_input_area.
xmin = output_area.
xmin - add_size;
289 r_input_area.
xmax = output_area.
xmax + add_size;
290 r_input_area.
ymin = output_area.
ymin - add_size;
291 r_input_area.
ymax = output_area.
ymax + add_size;
300 r_input_area = output_area;
314 const int pixel_size = size_ * max_dim / 100.0f;
315 const float m = bokehDimension_ / pixel_size;
322 for (; !it.is_end(); ++it) {
325 const float bounding_box = *it.in(0);
326 if (bounding_box <= 0.0f) {
331 float color_accum[4] = {0};
332 float multiplier_accum[4] = {0};
333 if (pixel_size < 2) {
335 multiplier_accum[0] = 1.0f;
336 multiplier_accum[1] = 1.0f;
337 multiplier_accum[2] = 1.0f;
338 multiplier_accum[3] = 1.0f;
340 const int miny =
MAX2(
y - pixel_size, image_rect.
ymin);
341 const int maxy =
MIN2(
y + pixel_size, image_rect.
ymax);
342 const int minx =
MAX2(
x - pixel_size, image_rect.
xmin);
343 const int maxx =
MIN2(
x + pixel_size, image_rect.
xmax);
345 const int elem_stride = image_input->
elem_stride * step;
346 const int row_stride = image_input->
row_stride * step;
347 const float *row_color = image_input->
get_elem(minx, miny);
348 for (
int ny = miny;
ny < maxy;
ny += step, row_color += row_stride) {
349 const float *
color = row_color;
350 const float v = bokeh_mid_y_ - (
ny -
y) * m;
351 for (
int nx = minx; nx < maxx; nx += step,
color += elem_stride) {
352 const float u = bokeh_mid_x_ - (nx -
x) * m;
359 it.out[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
360 it.out[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
361 it.out[2] = color_accum[2] * (1.0f / multiplier_accum[2]);
362 it.out[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
MINLINE float round_to_even(float f)
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4])
MINLINE void zero_v4(float r[4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble ny
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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
_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 GLsizei width
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void * initialize_tile_data(rcti *rect) override
void execute_pixel(float output[4], int x, int y, void *data) override
void deinit_execution() override
void init_execution() override
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
void execute_opencl(OpenCLDevice *device, MemoryBuffer *output_memory_buffer, cl_mem cl_output_buffer, MemoryBuffer **input_memory_buffers, std::list< cl_mem > *cl_mem_to_clean_up, std::list< cl_kernel > *cl_kernels_to_clean_up) override
custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevic...
void init_data() override
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override
Get input operation area being read by this operation on rendering given output area.
a MemoryBuffer contains access to the data of a chunk
void read_elem_checked(int x, int y, float *out) const
const rcti & get_rect() const
get the rect of this MemoryBuffer
float * get_elem(int x, int y)
const int get_width() const
get the width of this MemoryBuffer
float * get_buffer()
get the data of this MemoryBuffer
void read_elem(int x, int y, float *out) const
NodeOperation contains calculation logic.
unsigned int get_height() const
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
unsigned int get_width() const
eExecutionModel execution_model_
NodeOperationFlags flags_
const rcti & get_canvas() const
NodeOperation * get_input_operation(int index)
virtual bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output)
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
void set_determined_canvas_modifier(std::function< void(rcti &canvas)> fn)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
virtual void * initialize_tile_data(rcti *)
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area)
device representing an GPU OpenCL device. an instance of this class represents a single cl_device
void COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel, int offset_index, NodeOperation *operation)
cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel, int parameter_index, int offset_index, std::list< cl_mem > *cleanup, MemoryBuffer **input_memory_buffers, SocketReader *reader)
void COM_cl_attach_output_memory_buffer_to_kernel_parameter(cl_kernel kernel, int parameter_index, cl_mem cl_output_memory_buffer)
void COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer)
cl_kernel COM_cl_create_kernel(const char *kernelname, std::list< cl_kernel > *cl_kernels_to_clean_up)
void COM_cl_attach_memory_buffer_offset_to_kernel_parameter(cl_kernel kernel, int offset_index, MemoryBuffer *memory_buffers)
int get_offset_add() const
void init_execution(QualityHelper helper)
SyclQueue void void size_t num_bytes SyclQueue void const char void *memory_device_pointer KernelContext int kernel
ccl_global float * buffer
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
constexpr int IMAGE_INPUT_INDEX
static void area(int d1, int d2, int e1, int e2, float weights[2])
constexpr int COM_DATA_TYPE_COLOR_CHANNELS
constexpr int BOKEH_INPUT_INDEX
constexpr int BOUNDING_BOX_INPUT_INDEX
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
constexpr rcti COM_CONSTANT_INPUT_AREA_OF_INTEREST
constexpr int SIZE_INPUT_INDEX
static bNodeSocketTemplate inputs[]