31 b.use_custom_socket_order();
32 b.allow_any_socket_order();
35 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
39 .structure_type(StructureType::Dynamic)
40 .align_with_previous();
45 .structure_type(StructureType::Dynamic);
56 .
description(
"The extension mode applied to the X axis")
61 .
description(
"The extension mode applied to the Y axis")
97 if (this->
context().use_gpu()) {
117 const bool use_bilinear =
ELEM(
154 output.allocate_texture(domain);
163 interpolation, size,
image,
output, displacement, extension_x, extension_y);
171 const Result &displacement,
179 image.sample<
Color>(coordinates, interpolation, extension_mode_x, extension_mode_y));
193 const Result &displacement)
const
198 const int x = base_texel.x * 2;
199 const int y = base_texel.y * 2;
202 const int2 lower_right_texel =
int2(
x + 1,
y);
204 const int2 upper_right_texel =
int2(
x + 1,
y + 1);
207 lower_left_texel, size, displacement);
209 lower_right_texel, size, displacement);
211 upper_left_texel, size, displacement);
213 upper_right_texel, size, displacement);
216 const float2 lower_x_gradient = lower_right_coordinates - lower_left_coordinates;
217 const float2 left_y_gradient = upper_left_coordinates - lower_left_coordinates;
218 const float2 right_y_gradient = upper_right_coordinates - lower_right_coordinates;
219 const float2 upper_x_gradient = upper_right_coordinates - upper_left_coordinates;
222 auto compute_anisotropic_pixel = [&](
const int2 &texel,
223 const float2 &coordinates,
225 const float2 &y_gradient) {
237 compute_anisotropic_pixel(
238 lower_left_texel, lower_left_coordinates, lower_x_gradient, left_y_gradient);
239 if (lower_right_texel.x != size.x) {
240 compute_anisotropic_pixel(
241 lower_right_texel, lower_right_coordinates, lower_x_gradient, right_y_gradient);
243 if (upper_left_texel.y != size.y) {
244 compute_anisotropic_pixel(
245 upper_left_texel, upper_left_coordinates, upper_x_gradient, left_y_gradient);
247 if (upper_right_texel.x != size.x && upper_right_texel.y != size.y) {
248 compute_anisotropic_pixel(
249 upper_right_texel, upper_right_coordinates, upper_x_gradient, right_y_gradient);
264 switch (interpolation) {
266 return "compositor_displace_anisotropic";
268 return "compositor_displace_bicubic";
271 return "compositor_displace";
274 return "compositor_displace";
281 switch (interpolation) {
299 switch (extension_x) {
315 switch (extension_y) {
339 ntype.
ui_description =
"Displace pixel position using an offset vector";
#define NODE_CLASS_DISTORT
#define CMP_NODE_DISPLACE
Read Blender memory allocation and freeing.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
gpu::Shader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
virtual Domain compute_domain()
bool is_single_value() const
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
void unbind_as_texture() const
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
T get_single_value_default() const
T load_pixel_extended(const int2 &texel) const
void unbind_as_image() const
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
const T & get_single_value() const
DeclType::Builder & add_input(UString name, UString identifier=""_ustr)
StructureType structure_type
NodeOperation(Context &context, const bNode &node)
Extension get_extension_mode_y()
void compute_interpolation(const Interpolation &interpolation, const int2 &size, const Result &image, Result &output, const Result &displacement, const Extension &extension_mode_x, const Extension &extension_mode_y) const
Interpolation get_interpolation()
Extension get_extension_mode_x()
float2 compute_coordinates(const int2 &texel, const int2 &size, const Result &displacement) const
const char * get_shader_name(const Interpolation &interpolation) const
void compute_anisotropic(const int2 &size, const Result &image, Result &output, const Result &displacement) const
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void compute_dispatch_threads_at_least(gpu::Shader *shader, int2 threads_range, int2 local_size=int2(16))
ColorSceneLinear4f< eAlpha::Premultiplied > Color
GPUSamplerExtendMode map_extension_mode_to_extend_mode(const Extension &mode)
void parallel_for(const int2 range, const Function &function)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
MatT from_location(const typename MatT::loc_type &location)
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_register()
const EnumPropertyItem rna_enum_node_compositor_extension_items[]
MatBase< float, 2, 2 > float2x2
void GPU_texture_anisotropic_filter(gpu::Texture *texture, bool use_aniso)
void GPU_texture_mipmap_mode(gpu::Texture *texture, bool use_mipmap, bool use_filter)
BMesh const char void * data
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
@ CMP_NODE_EXTENSION_MODE_REPEAT
@ CMP_NODE_EXTENSION_MODE_EXTEND
@ CMP_NODE_EXTENSION_MODE_CLIP
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
@ CMP_NODE_INTERPOLATION_NEAREST
@ CMP_NODE_INTERPOLATION_BICUBIC
@ CMP_NODE_INTERPOLATION_ANISOTROPIC
@ CMP_NODE_INTERPOLATION_BILINEAR
void GPU_texture_extend_mode_x(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode_y(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
const EnumPropertyItem rna_enum_node_compositor_interpolation_items[]
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare