9 #define USE_FORCE_BILINEAR
18 #ifdef USE_FORCE_BILINEAR
46 float ScaleOperation::get_constant_scale(
const int input_op_idx,
const float factor)
57 float ScaleOperation::get_constant_scale_x(
const float width)
62 float ScaleOperation::get_constant_scale_y(
const float height)
67 bool ScaleOperation::is_scaling_variable()
83 float scale_offset_x, scale_offset_y;
120 const rcti &scale_canvas,
121 float &r_scale_offset_x,
122 float &r_scale_offset_y)
129 const rcti &scale_canvas,
130 const float relative_scale_x,
131 const float relative_scale_y,
132 const rcti &output_area,
137 float scale_offset_x, scale_offset_y;
151 const rcti &output_area,
154 r_input_area = output_area;
155 if (input_idx != 0 || is_scaling_variable()) {
160 const float scale_x = get_constant_scale_x(image_op->
get_width());
161 const float scale_y = get_constant_scale_y(image_op->
get_height());
164 image_op->
get_canvas(), this->get_canvas(), scale_x, scale_y, output_area, r_input_area);
173 const int input_image_width = input_image_op->
get_width();
174 const int input_image_height = input_image_op->
get_height();
177 const float scale_center_x = input_image_width / 2.0f;
178 const float scale_center_y = input_image_height / 2.0f;
179 float from_scale_offset_x, from_scale_offset_y;
181 input_image_op->
get_canvas(), this->get_canvas(), from_scale_offset_x, from_scale_offset_y);
187 for (; !it.is_end(); ++it) {
188 const float rel_scale_x = *it.in(0) * scale_x_factor;
189 const float rel_scale_y = *it.in(1) * scale_y_factor;
191 from_scale_offset_x +
canvas_.
xmin + it.x, scale_center_x, rel_scale_x);
193 from_scale_offset_y +
canvas_.
ymin + it.y, scale_center_y, rel_scale_y);
207 const bool image_determined =
209 if (image_determined) {
210 rcti image_canvas = r_area;
216 if (is_scaling_variable()) {
224 const float scale_x = get_constant_scale_x(input_width);
225 const float scale_y = get_constant_scale_y(input_height);
260 const float scx = scaleX[0];
261 const float scy = scaleY[0];
279 const float scx = scaleX[0];
280 const float scy = scaleY[0];
294 &new_input, read_operation,
output);
310 const float scx = scaleX[0];
311 const float scy = scaleY[0];
316 float relative_xscale = scx /
width;
317 float relative_yscale = scy /
height;
336 const float scx = scaleX[0];
337 const float scy = scaleY[0];
341 float relateve_xscale = scx /
width;
342 float relateve_yscale = scy /
height;
367 input_operation_ =
nullptr;
375 rel_x_ = input_width / (
float)new_width_;
376 rel_y_ = input_height / (
float)new_height_;
379 if (offset_x_ != 0.0f || offset_y_ != 0.0f) {
382 if (new_width_ > new_height_) {
383 offset_x_ *= new_width_;
384 offset_y_ *= new_width_;
387 offset_x_ *= new_height_;
388 offset_y_ *= new_height_;
394 const float w_src = input_width;
395 const float h_src = input_height;
398 const float w_dst = new_width_;
399 const float h_dst = new_height_;
401 const float asp_src = w_src / h_src;
402 const float asp_dst = w_dst / h_dst;
404 if (
fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
405 if ((asp_src > asp_dst) == (is_crop_ ==
true)) {
407 const float div = asp_src / asp_dst;
409 offset_x_ += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
411 int fit_width = new_width_ * div;
416 const int added_width = fit_width - new_width_;
417 new_width_ += added_width;
418 offset_x_ += added_width / 2.0f;
423 const float div = asp_dst / asp_src;
425 offset_y_ += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
427 int fit_height = new_height_ * div;
432 const int added_height = fit_height - new_height_;
433 new_height_ += added_height;
434 offset_y_ += added_height / 2.0f;
451 input_operation_ =
nullptr;
462 float nx = ((
x - offset_x_) * rel_x_);
463 float ny = ((
y - offset_y_) * rel_y_);
476 new_input.
xmax = (
input->xmax - offset_x_) * rel_x_ + 1;
477 new_input.
xmin = (
input->xmin - offset_x_) * rel_x_;
478 new_input.
ymax = (
input->ymax - offset_y_) * rel_y_ + 1;
479 new_input.
ymin = (
input->ymin - offset_y_) * rel_y_;
482 &new_input, read_operation,
output);
487 rcti local_preferred = preferred_area;
488 local_preferred.
xmax = local_preferred.
xmin + new_width_;
489 local_preferred.
ymax = local_preferred.
ymin + new_height_;
493 if (input_determined) {
495 r_area = input_canvas;
497 r_area.
xmin /= rel_x_;
498 r_area.
ymin /= rel_y_;
499 r_area.
xmin += offset_x_;
500 r_area.
ymin += offset_y_;
503 r_area.
xmax = r_area.
xmin + new_width_;
504 r_area.
ymax = r_area.
ymin + new_height_;
509 const rcti &output_area,
515 r_input_area.
xmax =
ceilf((output_area.
xmax - offset_x_) * rel_x_);
516 r_input_area.
xmin =
floorf((output_area.
xmin - offset_x_) * rel_x_);
517 r_input_area.
ymax =
ceilf((output_area.
ymax - offset_y_) * rel_y_);
518 r_input_area.
ymin =
floorf((output_area.
ymin - offset_y_) * rel_y_);
530 for (; !it.is_end(); ++it) {
531 const float nx = (
canvas_.
xmin + it.x - offset_x_) * rel_x_;
537 for (; !it.is_end(); ++it) {
typedef float(TangentPoint)[2]
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
#define UNUSED_VARS_NDEBUG(...)
_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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its and Z components Generates normals with round corners and may slow down renders Vector Displace the surface along an arbitrary direction White Return a random value or color based on an input seed Float Map an input float to a curve and outputs a float value Separate Color
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void set_scale_canvas_max_size(Size2f size)
Size2f max_scale_canvas_size_
PixelSampler get_effective_sampler(PixelSampler sampler)
a MemoryBuffer contains access to the data of a chunk
void read_elem_sampled(float x, float y, PixelSampler sampler, float *out) const
NodeOperation contains calculation logic.
unsigned int get_height() const
void add_output_socket(DataType datatype)
const NodeOperationFlags get_flags() const
SocketReader * get_input_socket_reader(unsigned int index)
unsigned int get_width() const
eExecutionModel execution_model_
const rcti & get_canvas() const
NodeOperation * get_input_operation(int index)
NodeOperationInput * get_input_socket(unsigned 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 add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area)
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void init_execution() override
void deinit_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 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.
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
ScaleFixedSizeOperation()
void deinit_execution() override
SocketReader * input_xoperation_
static constexpr int Y_INPUT_INDEX
static constexpr int IMAGE_INPUT_INDEX
static void get_scale_offset(const rcti &input_canvas, const rcti &scale_canvas, float &r_scale_offset_x, float &r_scale_offset_y)
static void get_scale_area_of_interest(const rcti &input_canvas, const rcti &scale_canvas, float relative_scale_x, float relative_scale_y, const rcti &output_area, rcti &r_input_area)
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.
virtual float get_relative_scale_x_factor(float width)=0
SocketReader * input_yoperation_
static void scale_area(rcti &area, float relative_scale_x, float relative_scale_y)
void init_execution() override
static float scale_coord_inverted(const float coord, const float center, const float relative_scale)
void init_data() override
virtual float get_relative_scale_y_factor(float height)=0
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
SocketReader * input_operation_
static constexpr int X_INPUT_INDEX
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
static void clamp_area_size_max(rcti &area, Size2f max_size)
static float scale_coord(const float coord, const float center, const float relative_scale)
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
DataType
possible data types for sockets
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
static void area(int d1, int d2, int e1, int e2, float weights[2])
void expand_area_for_sampler(rcti &area, PixelSampler sampler)
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
constexpr rcti COM_AREA_NONE
static bNodeSocketTemplate inputs[]
bool is_constant_operation