31 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
34 .default_value({1.0f, 0.0f, 0.0f})
66 if (this->
context().use_gpu()) {
111 "compositor_map_uv_anisotropic";
149 output.allocate_single_value();
163 float2 uv_coordinates = input_uv.load_pixel<float3>(texel).xy();
165 float4 sampled_color = input_image.sample_nearest_zero(uv_coordinates);
173 float alpha = input_uv.load_pixel<float3>(texel).z;
175 float4 result = sampled_color * alpha;
177 output_image.store_pixel(texel, result);
199 const int x = base_texel.x * 2;
200 const int y = base_texel.y * 2;
203 const int2 lower_right_texel =
int2(
x + 1,
y);
205 const int2 upper_right_texel =
int2(
x + 1,
y + 1);
214 const float2 lower_x_gradient = (lower_right_uv - lower_left_uv) / uv_size.x;
215 const float2 left_y_gradient = (upper_left_uv - lower_left_uv) / uv_size.y;
216 const float2 right_y_gradient = (upper_right_uv - lower_right_uv) / uv_size.y;
217 const float2 upper_x_gradient = (upper_right_uv - upper_left_uv) / uv_size.x;
220 auto compute_pixel = [&](
const int2 &texel,
221 const float2 &coordinates,
223 const float2 &y_gradient) {
243 compute_pixel(lower_left_texel, lower_left_uv, lower_x_gradient, left_y_gradient);
244 if (lower_right_texel.x !=
size.x) {
245 compute_pixel(lower_right_texel, lower_right_uv, lower_x_gradient, right_y_gradient);
247 if (upper_left_texel.y !=
size.y) {
248 compute_pixel(upper_left_texel, upper_left_uv, upper_x_gradient, left_y_gradient);
250 if (upper_right_texel.x !=
size.x && upper_right_texel.y !=
size.y) {
251 compute_pixel(upper_right_texel, upper_right_uv, upper_x_gradient, right_y_gradient);
278 "Map a texture using UV coordinates, to apply a texture to objects in compositing";
281 ntype.
declare = file_ns::cmp_node_map_uv_declare;
282 ntype.
draw_buttons = file_ns::node_composit_buts_map_uv;
284 ntype.
initfunc = file_ns::node_composit_init_map_uv;
#define NODE_CLASS_DISTORT
@ CMP_NODE_MAP_UV_FILTERING_NEAREST
@ CMP_NODE_MAP_UV_FILTERING_ANISOTROPIC
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_anisotropic_filter(GPUTexture *texture, bool use_aniso)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
const bNode & bnode() const
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
virtual Domain compute_domain()
void share_data(const Result &source)
void allocate_texture(Domain domain, bool from_pool=true)
void store_pixel(const int2 &texel, const T &pixel_value)
float4 sample_nearest_zero(const float2 &coordinates) const
void unbind_as_texture() const
void bind_as_texture(GPUShader *shader, const char *texture_name) const
T load_pixel_extended(const int2 &texel) const
const Domain & domain() const
T load_pixel(const int2 &texel) const
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
void unbind_as_image() const
float4 sample_ewa_zero(const float2 &coordinates, const float2 &x_gradient, const float2 &y_gradient) const
bool is_single_value() const
const T & get_single_value() const
int compositor_domain_priority() const
void execute_cpu_anisotropic()
void execute_cpu_nearest()
char const * get_shader_name()
void execute_single_cpu()
bool get_nearest_neighbour()
NodeOperation(Context &context, DNode node)
void node_register_type(bNodeType &ntype)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
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_composit_init_map_uv(bNodeTree *, bNode *node)
static void cmp_node_map_uv_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_map_uv(uiLayout *layout, bContext *, PointerRNA *ptr)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
static void register_node_type_cmp_mapuv()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string 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
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)