Files
test/source/blender/compositor/intern/implicit_input_operation.cc
Omar Emara 36154a1ab4 Compositor: Initial support for implicit inputs
This patch adds initial support for implicit inputs in pixel operations.
This is currently a non-functional change but will be used in the
future to support implicit inputs in texture nodes or so.

This works by exposing extra inputs to pixel operation for each of the
supported implicit input types if needed, and linking those inputs to
instances of the ImplicitInputOperation operation.

Only a single implicit input exist for now and we do not differentiate
between any of the implicit inputs type. In order to do that, we need to
refactor how input declarations for implicit inputs happen, since they
are now tied to the Geometry Nodes specifically.
2025-03-26 13:42:21 +02:00

58 lines
1.6 KiB
C++

/* SPDX-FileCopyrightText: 2025 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_assert.h"
#include "COM_implicit_input_operation.hh"
#include "COM_input_descriptor.hh"
#include "COM_operation.hh"
#include "COM_result.hh"
namespace blender::compositor {
const StringRef ImplicitInputOperation::output_identifier_ = StringRef("Output");
static ResultType get_implicit_input_result_type(const ImplicitInput implicit_input)
{
switch (implicit_input) {
case ImplicitInput::None:
break;
case ImplicitInput::TextureCoordinates:
return ResultType::Float3;
}
BLI_assert_unreachable();
return ResultType::Float3;
}
ImplicitInputOperation::ImplicitInputOperation(Context &context,
const ImplicitInput implicit_input)
: Operation(context), implicit_input_(implicit_input)
{
this->populate_result(output_identifier_,
context.create_result(get_implicit_input_result_type(implicit_input)));
}
void ImplicitInputOperation::execute()
{
Result &result = this->get_result();
switch (implicit_input_) {
case ImplicitInput::None:
BLI_assert_unreachable();
break;
case ImplicitInput::TextureCoordinates:
const int2 size = this->context().get_compositing_region_size();
result.wrap_external(
this->context().cache_manager().texture_coordinates.get(this->context(), size));
}
}
Result &ImplicitInputOperation::get_result()
{
return Operation::get_result(output_identifier_);
}
} // namespace blender::compositor