30 b.use_custom_socket_order();
31 b.allow_any_socket_order();
34 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
37 .structure_type(StructureType::Dynamic);
39 .structure_type(StructureType::Dynamic)
40 .align_with_previous();
43 .default_value({1.0f, 0.0f, 0.0f})
47 "The UV coordinates at which to sample the texture. The Z component is assumed to "
48 "contain an alpha channel")
49 .structure_type(StructureType::Dynamic);
56 .description(
"Interpolation method");
61 .description(
"The extension mode applied to the X axis");
66 .description(
"The extension mode applied to the Y axis");
96 if (this->
context().use_gpu()) {
116 const bool use_bilinear =
ELEM(
146 switch (interpolation) {
148 return "compositor_map_uv_anisotropic";
150 return "compositor_map_uv_bicubic";
153 return "compositor_map_uv";
156 return "compositor_map_uv";
197 output.allocate_single_value();
213 float2 uv_coordinates = input_uv.load_pixel<float3>(texel).xy();
214 float4 sampled_color = float4(input_image.sample<Color>(
215 uv_coordinates, interpolation, extension_mode_x, extension_mode_y));
222 float alpha = input_uv.load_pixel<float3>(texel).z;
224 float4 result = sampled_color * alpha;
226 output_image.store_pixel(texel, Color(result));
247 const int x = base_texel.x * 2;
248 const int y = base_texel.y * 2;
251 const int2 lower_right_texel =
int2(
x + 1,
y);
253 const int2 upper_right_texel =
int2(
x + 1,
y + 1);
261 const float2 lower_x_gradient = lower_right_uv - lower_left_uv;
262 const float2 left_y_gradient = upper_left_uv - lower_left_uv;
263 const float2 right_y_gradient = upper_right_uv - lower_right_uv;
264 const float2 upper_x_gradient = upper_right_uv - upper_left_uv;
267 auto compute_pixel = [&](
const int2 &texel,
268 const float2 &coordinates,
270 const float2 &y_gradient) {
292 compute_pixel(lower_left_texel, lower_left_uv, lower_x_gradient, left_y_gradient);
293 if (lower_right_texel.x != size.x) {
294 compute_pixel(lower_right_texel, lower_right_uv, lower_x_gradient, right_y_gradient);
296 if (upper_left_texel.y != size.y) {
297 compute_pixel(upper_left_texel, upper_left_uv, upper_x_gradient, left_y_gradient);
299 if (upper_right_texel.x != size.x && upper_right_texel.y != size.y) {
300 compute_pixel(upper_right_texel, upper_right_uv, upper_x_gradient, right_y_gradient);
308 this->
get_input(
"Interpolation").get_single_value_default<MenuValue>().value);
309 switch (interpolation) {
326 this->
get_input(
"Extension X").get_single_value_default<MenuValue>().value);
327 switch (extension_x) {
342 this->
get_input(
"Extension Y").get_single_value_default<MenuValue>().value);
343 switch (extension_y) {
368 "Map a texture using UV coordinates, to apply a texture to objects in compositing";
#define NODE_CLASS_DISTORT
Read Blender memory allocation and freeing.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
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()
T sample(const float2 &coordinates, const Interpolation &interpolation, const Extension &extension_mode_x, const Extension &extension_mode_y, std::optional< float2x2 > jacobian=std::nullopt) const
bool is_single_value() const
void store_pixel(const int2 &texel, const T &pixel_value)
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 load_pixel_extended(const int2 &texel) const
T load_pixel(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)
const CompositorInputRealizationMode & compositor_realization_mode() const
NodeOperation(Context &context, const bNode &node)
void execute_cpu_anisotropic()
void execute_cpu_interpolation(const Interpolation &interpolation)
Extension get_extension_mode_y()
Extension get_extension_mode_x()
Interpolation get_interpolation()
char const * get_shader_name(const Interpolation &interpolation)
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
Color sample_pixel(Context &context, const Result &input, const Interpolation &interpolation, const Extension &extension_mode_x, const Extension &extension_mode_y, const float2 coordinates)
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)
static void node_init(bNodeTree *, bNode *node)
static void node_register()
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
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