31 b.use_custom_socket_order();
32 b.allow_any_socket_order();
35 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
38 b.add_output<
decl::Color>(
"Image").structure_type(StructureType::Dynamic).align_with_previous();
43 .structure_type(StructureType::Dynamic);
54 .
description(
"The extension mode applied to the X axis")
59 .
description(
"The extension mode applied to the Y axis")
95 if (this->
context().use_gpu()) {
115 const bool use_bilinear =
ELEM(
161 interpolation,
size, image,
output, displacement, extension_x, extension_y);
169 const Result &displacement,
177 image.
sample(coordinates, interpolation, extension_mode_x, extension_mode_y));
191 const Result &displacement)
const
196 const int x = base_texel.x * 2;
197 const int y = base_texel.y * 2;
200 const int2 lower_right_texel =
int2(
x + 1,
y);
202 const int2 upper_right_texel =
int2(
x + 1,
y + 1);
205 lower_left_texel,
size, displacement);
207 lower_right_texel,
size, displacement);
209 upper_left_texel,
size, displacement);
211 upper_right_texel,
size, displacement);
215 const float2 lower_x_gradient = (lower_right_coordinates - lower_left_coordinates) /
size.x;
216 const float2 left_y_gradient = (upper_left_coordinates - lower_left_coordinates) /
size.y;
217 const float2 right_y_gradient = (upper_right_coordinates - lower_right_coordinates) /
size.y;
218 const float2 upper_x_gradient = (upper_right_coordinates - upper_left_coordinates) /
size.x;
221 auto compute_anisotropic_pixel = [&](
const int2 &texel,
222 const float2 &coordinates,
224 const float2 &y_gradient) {
230 compute_anisotropic_pixel(
231 lower_left_texel, lower_left_coordinates, lower_x_gradient, left_y_gradient);
232 if (lower_right_texel.x !=
size.x) {
233 compute_anisotropic_pixel(
234 lower_right_texel, lower_right_coordinates, lower_x_gradient, right_y_gradient);
236 if (upper_left_texel.y !=
size.y) {
237 compute_anisotropic_pixel(
238 upper_left_texel, upper_left_coordinates, upper_x_gradient, left_y_gradient);
240 if (upper_right_texel.x !=
size.x && upper_right_texel.y !=
size.y) {
241 compute_anisotropic_pixel(
242 upper_right_texel, upper_right_coordinates, upper_x_gradient, right_y_gradient);
257 switch (interpolation) {
259 return "compositor_displace_anisotropic";
261 return "compositor_displace_bicubic";
264 return "compositor_displace";
267 return "compositor_displace";
274 const MenuValue menu_value =
input.get_single_value_default(default_menu_value);
276 switch (interpolation) {
294 const MenuValue menu_value =
input.get_single_value_default(default_menu_value);
296 switch (extension_x) {
312 const MenuValue menu_value =
input.get_single_value_default(default_menu_value);
314 switch (extension_y) {
342 ntype.
ui_description =
"Displace pixel position using an offset vector";
345 ntype.
declare = file_ns::cmp_node_displace_declare;
346 ntype.
initfunc = file_ns::cmp_node_init_displace;
#define NODE_CLASS_DISTORT
#define CMP_NODE_DISPLACE
@ CMP_NODE_INTERPOLATION_NEAREST
@ CMP_NODE_INTERPOLATION_BILINEAR
@ CMP_NODE_INTERPOLATION_BICUBIC
@ CMP_NODE_INTERPOLATION_ANISOTROPIC
@ CMP_NODE_EXTENSION_MODE_EXTEND
@ CMP_NODE_EXTENSION_MODE_CLIP
@ CMP_NODE_EXTENSION_MODE_REPEAT
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_extend_mode_y(blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode_x(blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_anisotropic_filter(blender::gpu::Texture *texture, bool use_aniso)
void GPU_texture_mipmap_mode(blender::gpu::Texture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_filter_mode(blender::gpu::Texture *texture, bool use_filter)
Read Guarded memory(de)allocation.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
gpu::Shader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
virtual Domain compute_domain()
RealizationOptions & get_realization_options()
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
void unbind_as_texture() const
float4 sample(const float2 &coordinates, const Interpolation &interpolation, const ExtensionMode &extend_mode_x, const ExtensionMode &extend_mode_y) const
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
T load_pixel_extended(const int2 &texel) const
void unbind_as_image() const
float4 sample_ewa_zero(const float2 &coordinates, const float2 &x_gradient, const float2 &y_gradient) const
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
bool is_single_value() const
const T & get_single_value() const
DeclType::Builder & add_input(StringRef name, StringRef identifier="")
StructureType structure_type
ExtensionMode get_extension_mode_x()
Interpolation get_interpolation()
float2 compute_coordinates(const int2 &texel, const int2 &size, const Result &displacement) const
const char * get_shader_name(const Interpolation &interpolation) const
void compute_interpolation(const Interpolation &interpolation, const int2 &size, const Result &image, Result &output, const Result &displacement, const ExtensionMode &extension_mode_x, const ExtensionMode &extension_mode_y) const
void compute_anisotropic(const int2 &size, const Result &image, Result &output, const Result &displacement) const
ExtensionMode get_extension_mode_y()
NodeOperation(Context &context, DNode node)
void * MEM_callocN(size_t len, const char *str)
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))
GPUSamplerExtendMode map_extension_mode_to_extend_mode(const ExtensionMode &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 cmp_node_displace_declare(NodeDeclarationBuilder &b)
static void cmp_node_init_displace(bNodeTree *, bNode *node)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static void register_node_type_cmp_displace()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
const EnumPropertyItem rna_enum_node_compositor_extension_items[]
const EnumPropertyItem rna_enum_node_compositor_interpolation_items[]
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
void(* initfunc)(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
ExtensionMode extension_x
ExtensionMode extension_y