29 b.add_input<
decl::Color>(
"Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
30 b.add_input<
decl::Float>(
"Alpha").default_value(1.0f).min(0.0f).max(1.0f);
46 if (!
context().is_valid_compositing_region()) {
52 if (image.is_single_value() && alpha.is_single_value()) {
58 else if (!
node().input_by_identifier(
"Alpha")->is_logically_linked()) {
73 float4 color = image.get_color_value();
77 else if (
node().input_by_identifier(
"Alpha")->is_logically_linked()) {
78 color.w = alpha.get_float_value();
83 if (this->
context().use_gpu()) {
87 parallel_for(domain.size, [&](
const int2 texel) { output.store_pixel(texel, color); });
115 image.bind_as_texture(shader,
"input_tx");
117 output.bind_as_image(shader,
"output_img");
121 image.unbind_as_texture();
122 output.unbind_as_image();
134 const int2 output_texel = texel + bounds.min;
135 if (output_texel.x > bounds.max.x || output_texel.y > bounds.max.y) {
138 output.store_pixel(texel + bounds.
min,
float4(image.load_pixel(texel).xyz(), 1.0f));
146 if (context().use_gpu()) {
147 this->execute_copy_gpu();
150 this->execute_copy_cpu();
157 const Domain domain = compute_domain();
158 Result output = context().get_output_result();
160 GPUShader *shader = context().get_shader(
"compositor_write_output", output.precision());
167 image.bind_as_texture(shader,
"input_tx");
169 output.bind_as_image(shader,
"output_img");
173 image.unbind_as_texture();
174 output.unbind_as_image();
180 const Domain domain = compute_domain();
182 Result output = context().get_output_result();
186 const int2 output_texel = texel + bounds.min;
187 if (output_texel.x > bounds.max.x || output_texel.y > bounds.max.y) {
190 output.store_pixel(texel + bounds.
min, image.load_pixel(texel));
197 if (context().use_gpu()) {
198 execute_set_alpha_gpu();
201 execute_set_alpha_cpu();
208 const Domain domain = compute_domain();
209 Result output = context().get_output_result();
211 GPUShader *shader = context().get_shader(
"compositor_write_output_alpha", output.precision());
218 image.bind_as_texture(shader,
"input_tx");
221 alpha.bind_as_texture(shader,
"alpha_tx");
223 output.bind_as_image(shader,
"output_img");
227 image.unbind_as_texture();
228 alpha.unbind_as_texture();
229 output.unbind_as_image();
235 const Domain domain = compute_domain();
238 Result output = context().get_output_result();
241 parallel_for(domain.size, [&](
const int2 texel) {
242 const int2 output_texel = texel + bounds.min;
243 if (output_texel.x > bounds.max.x || output_texel.y > bounds.max.y) {
246 output.store_pixel(texel +
bounds.min,
247 float4(image.load_pixel(texel).xyz(), alpha.load_pixel(texel).x));
255 const rcti compositing_region = context().get_compositing_region();
257 int2(compositing_region.
xmax, compositing_region.
ymax));
272 return Domain(context().get_compositing_region_size());
290 ntype.
declare = file_ns::cmp_node_composite_declare;
291 ntype.
draw_buttons = file_ns::node_composit_buts_composite;
#define NODE_CLASS_OUTPUT
@ CMP_NODE_OUTPUT_IGNORE_ALPHA
void GPU_shader_uniform_2iv(GPUShader *sh, const char *name, const int data[2])
void GPU_shader_bind(GPUShader *shader)
void GPU_texture_clear(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
struct GPUShader GPUShader
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void execute_set_alpha_cpu()
void execute_ignore_alpha_gpu()
void execute_ignore_alpha_cpu()
void execute_ignore_alpha()
Domain compute_domain() override
void execute_set_alpha_gpu()
Bounds< int2 > get_output_bounds()
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
virtual Result get_output_result()=0
NodeOperation(Context &context, DNode node)
const DNode & node() const
Result & get_input(StringRef identifier) const
Context & context() const
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void cmp_node_composite_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_composite(uiLayout *layout, bContext *, PointerRNA *ptr)
void parallel_for(const int2 range, FunctionRef< void(int2)> function)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
void register_node_type_cmp_composite()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
NodeGetCompositorOperationFunction get_compositor_operation
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
static pxr::UsdShadeInput get_input(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &input_name)