32 .compositor_domain_priority(1);
34 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
35 .compositor_domain_priority(0);
49 bNode &node =
params.add_node(
"CompositorNodeFilter");
51 params.update_and_connect_available_socket(node,
"Image");
58 if (!
params.node_tree().typeinfo->validate_link(from_socket_type,
SOCK_RGBA)) {
87 if (this->
context().use_gpu()) {
125 return "compositor_edge_filter";
127 return "compositor_filter";
139 output.allocate_texture(domain);
146 float3 color_x = float3(0.0f);
147 float3 color_y = float3(0.0f);
148 for (int j = 0; j < 3; j++) {
149 for (int i = 0; i < 3; i++) {
150 float3 color = input.load_pixel_extended<float4>(texel + int2(i - 1, j - 1)).xyz();
151 color_x += color * kernel[j][i];
152 color_y += color * kernel[i][j];
173 float4 color = float4(0.0f);
174 for (int j = 0; j < 3; j++) {
175 for (int i = 0; i < 3; i++) {
176 color += input.load_pixel_extended<float4>(texel + int2(i - 1, j - 1)) * kernel[j][i];
182 input.load_pixel<
float4>(texel),
color, factor.load_pixel<
float,
true>(texel));
214 const float kernel[3][3] = {{1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f},
215 {2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f},
216 {1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f}};
220 const float kernel[3][3] = {
221 {-1.0f, -1.0f, -1.0f}, {-1.0f, 9.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}};
225 const float kernel[3][3] = {{-1.0f / 8.0f, -1.0f / 8.0f, -1.0f / 8.0f},
226 {-1.0f / 8.0f, 1.0f, -1.0f / 8.0f},
227 {-1.0f / 8.0f, -1.0f / 8.0f, -1.0f / 8.0f}};
231 const float kernel[3][3] = {{1.0f, 0.0f, -1.0f}, {2.0f, 0.0f, -2.0f}, {1.0f, 0.0f, -1.0f}};
235 const float kernel[3][3] = {{1.0f, 0.0f, -1.0f}, {1.0f, 0.0f, -1.0f}, {1.0f, 0.0f, -1.0f}};
239 const float kernel[3][3] = {
240 {5.0f, -3.0f, -2.0f}, {5.0f, -3.0f, -2.0f}, {5.0f, -3.0f, -2.0f}};
244 const float kernel[3][3] = {{1.0f, 2.0f, 1.0f}, {0.0f, 1.0f, 0.0f}, {-1.0f, -2.0f, -1.0f}};
248 const float kernel[3][3] = {
249 {0.0f, -1.0f, 0.0f}, {-1.0f, 5.0f, -1.0f}, {0.0f, -1.0f, 0.0f}};
253 const float kernel[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f}};
283 ntype.
declare = file_ns::cmp_node_filter_declare;
284 ntype.
draw_buttons = file_ns::node_composit_buts_filter;
#define NODE_CLASS_OP_FILTER
@ CMP_NODE_FILTER_PREWITT
@ CMP_NODE_FILTER_SHARP_BOX
@ CMP_NODE_FILTER_LAPLACE
@ CMP_NODE_FILTER_SHARP_DIAMOND
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])
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
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 unbind_as_texture() const
void bind_as_texture(GPUShader *shader, const char *texture_name) 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
bool is_single_value() const
CMPNodeFilterMethod get_filter_method()
float3x3 get_filter_kernel()
const char * get_shader_name()
NodeOperation(Context &context, DNode node)
CMPNodeFilterMethod filter_type
void operator()(LinkSearchOpParams ¶ms)
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)
T interpolate(const T &a, const T &b, const FactorT &t)
T max(const T &a, const T &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_composit_buts_filter(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_filter_declare(NodeDeclarationBuilder &b)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
static void register_node_type_cmp_filter()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_filter_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
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)