32 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
33 .compositor_domain_priority(0);
37 .default_value({0.0f, 1.0f})
40 .compositor_expects_single_value();
44 .default_value({1.0f, 1.0f})
47 .compositor_expects_single_value();
51 .default_value({0.0f, 0.0f})
54 .compositor_expects_single_value();
58 .default_value({1.0f, 0.0f})
61 .compositor_expects_single_value();
103 smaa(
context(), plane_mask, anti_aliased_plane_mask);
111 output_mask.
steal_data(anti_aliased_plane_mask);
114 anti_aliased_plane_mask.
release();
120 if (this->
context().use_gpu()) {
141 const bool use_bilinear =
ELEM(interpolation,
171 output.allocate_texture(domain);
179 if (transformed_coordinates.z == 0.0f) {
184 float2 projected_coordinates = transformed_coordinates.
xy() / transformed_coordinates.z;
189 sampled_color =
input.sample_cubic_extended(projected_coordinates);
192 sampled_color =
input.sample_bilinear_extended(projected_coordinates);
195 sampled_color =
input.sample_nearest_extended(projected_coordinates);
202 float2 x_gradient = (homography_matrix[0].xy() / transformed_coordinates.z) /
size.x;
203 float2 y_gradient = (homography_matrix[1].xy() / transformed_coordinates.z) /
size.y;
204 sampled_color =
input.sample_ewa_extended(projected_coordinates, x_gradient, y_gradient);
211 output.store_pixel(texel, plane_color);
217 if (this->
context().use_gpu()) {
256 if (transformed_coordinates.z == 0.0f) {
260 float2 projected_coordinates = transformed_coordinates.
xy() / transformed_coordinates.z;
262 bool is_inside_plane = projected_coordinates.x >= 0.0f && projected_coordinates.y >= 0.0f &&
263 projected_coordinates.x <= 1.0f && projected_coordinates.y <= 1.0f;
264 float mask_value = is_inside_plane ? 1.0f : 0.0f;
288 float corners[4][2] = {{lower_left.x, lower_left.y},
289 {lower_right.x, lower_right.y},
290 {upper_right.x, upper_right.y},
291 {upper_left.x, upper_left.y}};
292 float identity_corners[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
294 return homography_matrix;
302 return "compositor_plane_deform";
304 return "compositor_plane_deform_bicubic";
306 return "compositor_plane_deform_anisotropic";
310 return "compositor_plane_deform_anisotropic";
334 ntype.
ui_description =
"Plane warp transformation using explicit corner values";
337 ntype.
declare = file_ns::cmp_node_cornerpin_declare;
338 ntype.
initfunc = file_ns::node_composit_init_cornerpin;
339 ntype.
draw_buttons = file_ns::node_composit_buts_cornerpin;
#define NODE_CLASS_DISTORT
#define CMP_NODE_CORNERPIN
void BKE_tracking_homography_between_two_quads(float reference_corners[4][2], float corners[4][2], float H[3][3])
#define BLI_assert_unreachable()
bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
CMPNodeCornerPinInterpolation
@ CMP_NODE_CORNER_PIN_INTERPOLATION_BILINEAR
@ CMP_NODE_CORNER_PIN_INTERPOLATION_BICUBIC
@ CMP_NODE_CORNER_PIN_INTERPOLATION_ANISOTROPIC
@ CMP_NODE_CORNER_PIN_INTERPOLATION_NEAREST
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_mat3_as_mat4(GPUShader *sh, const char *name, const float data[3][3])
void GPU_texture_anisotropic_filter(GPUTexture *texture, bool use_aniso)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Result create_result(ResultType type, ResultPrecision precision)
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)
T get_single_value_default(const T &default_value) const
void allocate_texture(Domain domain, bool from_pool=true)
void store_pixel(const int2 &texel, const T &pixel_value)
void unbind_as_texture() const
void bind_as_texture(GPUShader *shader, const char *texture_name) const
void set_single_value(const T &value)
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
void allocate_single_value()
bool is_single_value() const
void steal_data(Result &source)
Result compute_plane_mask_cpu(const float3x3 &homography_matrix)
void compute_plane_gpu(const float3x3 &homography_matrix, Result &plane_mask)
float3x3 compute_homography_matrix()
const char * get_realization_shader_name() const
Result compute_plane_mask_gpu(const float3x3 &homography_matrix)
Result compute_plane_mask(const float3x3 &homography_matrix)
void compute_plane_cpu(const float3x3 &homography_matrix, Result &plane_mask)
CMPNodeCornerPinInterpolation get_interpolation() const
void compute_plane(const float3x3 &homography_matrix, Result &plane_mask)
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 smaa(Context &context, const Result &input, Result &output, const float threshold=0.1f, const float local_contrast_adaptation_factor=2.0f, const int corner_rounding=25)
void parallel_for(const int2 range, const Function &function)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void node_composit_init_cornerpin(bNodeTree *, bNode *node)
static void node_composit_buts_cornerpin(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_cornerpin_declare(NodeDeclarationBuilder &b)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
static void register_node_type_cmp_cornerpin()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
const c_style_mat & ptr() const
static MatBase identity()
VecBase< T, 2 > xy() const
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)