25 input_vector_width_ =
vector->get_width();
26 input_vector_height_ =
vector->get_height();
29bool DisplaceOperation::read_displacement(
30 float x,
float y,
float xscale,
float yscale,
const float origin[2],
float &r_u,
float &r_v)
32 float width = input_vector_width_;
33 float height = input_vector_height_;
41 vector_read_fn_(x, y,
col);
42 r_u = origin[0] -
col[0] * xscale;
43 r_v = origin[1] -
col[1] * yscale;
53 scale_x_read_fn_(
xy[0],
xy[1],
col);
55 scale_y_read_fn_(
xy[0],
xy[1],
col);
59 CLAMP(xs, -width_x4_, width_x4_);
60 CLAMP(ys, -height_x4_, height_x4_);
63 read_displacement(
xy[0],
xy[1], xs, ys,
xy, r_uv[0], r_uv[1]);
66 const float epsilon[2] = {1.0f, 1.0f};
72 if (read_displacement(
xy[0] + epsilon[0],
xy[1], xs, ys,
xy, uv[0], uv[1])) {
73 r_deriv[0][0] += uv[0] - r_uv[0];
74 r_deriv[1][0] += uv[1] - r_uv[1];
77 if (read_displacement(
xy[0] - epsilon[0],
xy[1], xs, ys,
xy, uv[0], uv[1])) {
78 r_deriv[0][0] += r_uv[0] - uv[0];
79 r_deriv[1][0] += r_uv[1] - uv[1];
83 float numinv = 1.0f /
float(num);
84 r_deriv[0][0] *= numinv;
85 r_deriv[1][0] *= numinv;
89 if (read_displacement(
xy[0],
xy[1] + epsilon[1], xs, ys,
xy, uv[0], uv[1])) {
90 r_deriv[0][1] += uv[0] - r_uv[0];
91 r_deriv[1][1] += uv[1] - r_uv[1];
94 if (read_displacement(
xy[0],
xy[1] - epsilon[1], xs, ys,
xy, uv[0], uv[1])) {
95 r_deriv[0][1] += r_uv[0] - uv[0];
96 r_deriv[1][1] += r_uv[1] - uv[1];
100 float numinv = 1.0f /
float(num);
101 r_deriv[0][1] *= numinv;
102 r_deriv[1][1] *= numinv;
107 const rcti &output_area,
116 r_input_area = output_area;
121 r_input_area = output_area;
134 vector_read_fn_ = [=](
float x,
float y,
float *out) {
vector->read_elem_bilinear(x, y, out); };
135 scale_x_read_fn_ = [=](
float x,
float y,
float *out) { scale_x->
read_elem_checked(x, y, out); };
136 scale_y_read_fn_ = [=](
float x,
float y,
float *out) { scale_y->
read_elem_checked(x, y, out); };
MINLINE bool is_zero_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
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.
void pixel_transform(const float xy[2], float r_uv[2], float r_deriv[2][2])
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void init_execution() override
void update_memory_buffer_started(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
a MemoryBuffer contains access to the data
void read_elem_checked(int x, int y, float *out) const
void read_elem_bilinear(float x, float y, float *out) const
void read_elem_filtered(float x, float y, float dx[2], float dy[2], bool extend_boundary, 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
NodeOperationFlags flags_
const rcti & get_canvas() const
NodeOperation * get_input_operation(int index)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
draw_view in_light_buf[] float
@ Vector
Vector data type.
void expand_area_for_sampler(rcti &area, PixelSampler sampler)
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator