Refactor: Use Float2 images internally if possible
Previously, Float2 images were internally stored as either Float3 or Float4 images due to limitations in the implementation, which no longer exists. So this patch refactors the compositor code to store Float2 images in actual Float2 containers, which gives better performance and memory savings. Some algorithms were adjusted to operate on Float2 instead of Float3 as was previously the case. Pull Request: https://projects.blender.org/blender/blender/pulls/140855
This commit is contained in:
@@ -78,8 +78,8 @@ float maximum_luminance(Context &context,
|
||||
/* Computes the maximum float value of all pixels in the given result. */
|
||||
float maximum_float(Context &context, const Result &result);
|
||||
|
||||
/* Computes the maximum float3 value of all pixels in the given result. */
|
||||
float3 maximum_float3(Context &context, const Result &result);
|
||||
/* Computes the maximum float2 value of all pixels in the given result. */
|
||||
float2 maximum_float2(Context &context, const Result &result);
|
||||
|
||||
/* Computes the maximum float of all pixels in the given float result, limited to the given range.
|
||||
* Values outside of the given range are ignored. If non of the pixel values are in the range, the
|
||||
|
||||
@@ -25,8 +25,8 @@ static const char *get_shader_name(const ResultType type, const PaddingMethod pa
|
||||
break;
|
||||
case PaddingMethod::Extend:
|
||||
switch (type) {
|
||||
case ResultType::Float3:
|
||||
return "compositor_pad_extend_float4";
|
||||
case ResultType::Float2:
|
||||
return "compositor_pad_extend_float2";
|
||||
case ResultType::Float:
|
||||
return "compositor_pad_extend_float";
|
||||
default:
|
||||
@@ -92,9 +92,9 @@ static void zero_pad_cpu(const Result &input,
|
||||
output.store_pixel(texel, input.load_pixel_extended<float>(texel - size));
|
||||
});
|
||||
break;
|
||||
case ResultType::Float3:
|
||||
case ResultType::Float2:
|
||||
parallel_for(extended_domain.size, [&](const int2 texel) {
|
||||
output.store_pixel(texel, input.load_pixel_extended<float3>(texel - size));
|
||||
output.store_pixel(texel, input.load_pixel_extended<float2>(texel - size));
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -583,38 +583,38 @@ float maximum_float(Context &context, const Result &result)
|
||||
return maximum_float_cpu(result);
|
||||
}
|
||||
|
||||
static float3 maximum_float3_gpu(Context &context, const Result &result)
|
||||
static float2 maximum_float2_gpu(Context &context, const Result &result)
|
||||
{
|
||||
GPUShader *shader = context.get_shader("compositor_maximum_float3", ResultPrecision::Full);
|
||||
GPUShader *shader = context.get_shader("compositor_maximum_float2", ResultPrecision::Full);
|
||||
GPU_shader_bind(shader);
|
||||
|
||||
float *reduced_value = parallel_reduction_dispatch(
|
||||
result, shader, Result::gpu_texture_format(ResultType::Float3, ResultPrecision::Full));
|
||||
const float3 maximum = reduced_value;
|
||||
result, shader, Result::gpu_texture_format(ResultType::Float2, ResultPrecision::Full));
|
||||
const float2 maximum = reduced_value;
|
||||
MEM_freeN(reduced_value);
|
||||
GPU_shader_unbind();
|
||||
|
||||
return maximum;
|
||||
}
|
||||
|
||||
static float3 maximum_float3_cpu(const Result &result)
|
||||
static float2 maximum_float2_cpu(const Result &result)
|
||||
{
|
||||
return parallel_reduce(
|
||||
result.domain().size,
|
||||
float3(std::numeric_limits<float>::lowest()),
|
||||
[&](const int2 texel, float3 &accumulated_value) {
|
||||
accumulated_value = math::max(accumulated_value, result.load_pixel<float3>(texel));
|
||||
float2(std::numeric_limits<float>::lowest()),
|
||||
[&](const int2 texel, float2 &accumulated_value) {
|
||||
accumulated_value = math::max(accumulated_value, result.load_pixel<float2>(texel));
|
||||
},
|
||||
[&](const float3 &a, const float3 &b) { return math::max(a, b); });
|
||||
[&](const float2 &a, const float2 &b) { return math::max(a, b); });
|
||||
}
|
||||
|
||||
float3 maximum_float3(Context &context, const Result &result)
|
||||
float2 maximum_float2(Context &context, const Result &result)
|
||||
{
|
||||
if (context.use_gpu()) {
|
||||
return maximum_float3_gpu(context, result);
|
||||
return maximum_float2_gpu(context, result);
|
||||
}
|
||||
|
||||
return maximum_float3_cpu(result);
|
||||
return maximum_float2_cpu(result);
|
||||
}
|
||||
|
||||
static float maximum_float_in_range_gpu(Context &context,
|
||||
|
||||
@@ -42,7 +42,7 @@ bool operator==(const ImageCoordinatesKey &a, const ImageCoordinatesKey &b)
|
||||
*/
|
||||
|
||||
ImageCoordinates::ImageCoordinates(Context &context, const int2 &size, const CoordinatesType type)
|
||||
: result(context.create_result(ResultType::Float3))
|
||||
: result(context.create_result(ResultType::Float2))
|
||||
{
|
||||
this->result.allocate_texture(Domain(size), false);
|
||||
|
||||
@@ -96,7 +96,7 @@ void ImageCoordinates::compute_cpu(const CoordinatesType type)
|
||||
parallel_for(size, [&](const int2 texel) {
|
||||
float2 centered_coordinates = (float2(texel) + 0.5f) - float2(size) / 2.0f;
|
||||
float2 normalized_coordinates = (centered_coordinates / max_size) * 2.0f;
|
||||
this->result.store_pixel(texel, float3(normalized_coordinates, 0.0f));
|
||||
this->result.store_pixel(texel, normalized_coordinates);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -104,14 +104,13 @@ void ImageCoordinates::compute_cpu(const CoordinatesType type)
|
||||
const int2 size = this->result.domain().size;
|
||||
parallel_for(size, [&](const int2 texel) {
|
||||
float2 normalized_coordinates = (float2(texel) + 0.5f) / float2(size);
|
||||
this->result.store_pixel(texel, float3(normalized_coordinates, 0.0f));
|
||||
this->result.store_pixel(texel, normalized_coordinates);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case CoordinatesType::Pixel: {
|
||||
parallel_for(this->result.domain().size, [&](const int2 texel) {
|
||||
this->result.store_pixel(texel, float3(float2(texel), 0.0f));
|
||||
});
|
||||
parallel_for(this->result.domain().size,
|
||||
[&](const int2 texel) { this->result.store_pixel(texel, float2(texel)); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,26 @@ void InputSingleValueOperation::execute()
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR: {
|
||||
const float3 value = input_socket_->default_value_typed<bNodeSocketValueVector>()->value;
|
||||
result.set_single_value(value);
|
||||
switch (input_socket_->default_value_typed<bNodeSocketValueVector>()->dimensions) {
|
||||
case 2: {
|
||||
const float2 value = input_socket_->default_value_typed<bNodeSocketValueVector>()->value;
|
||||
result.set_single_value(value);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const float3 value = input_socket_->default_value_typed<bNodeSocketValueVector>()->value;
|
||||
result.set_single_value(value);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const float4 value = input_socket_->default_value_typed<bNodeSocketValueVector>()->value;
|
||||
result.set_single_value(value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
|
||||
@@ -236,8 +236,26 @@ mf::Variable *MultiFunctionProcedureOperation::get_constant_input_variable(DInpu
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR: {
|
||||
const float3 value = float3(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
constant_function = &procedure_.construct_function<mf::CustomMF_Constant<float3>>(value);
|
||||
switch (input->default_value_typed<bNodeSocketValueVector>()->dimensions) {
|
||||
case 2: {
|
||||
const float2 value = float2(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
constant_function = &procedure_.construct_function<mf::CustomMF_Constant<float2>>(value);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const float3 value = float3(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
constant_function = &procedure_.construct_function<mf::CustomMF_Constant<float3>>(value);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const float4 value = float4(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
constant_function = &procedure_.construct_function<mf::CustomMF_Constant<float4>>(value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
|
||||
@@ -41,9 +41,9 @@ GPUNodeStack &ShaderNode::get_output(const StringRef identifier)
|
||||
return get_shader_node_output(*node_, outputs_.data(), identifier);
|
||||
}
|
||||
|
||||
static eGPUType gpu_type_from_socket_type(eNodeSocketDatatype type)
|
||||
static eGPUType gpu_type_from_socket(DSocket socket)
|
||||
{
|
||||
switch (type) {
|
||||
switch (eNodeSocketDatatype(socket->type)) {
|
||||
case SOCK_FLOAT:
|
||||
return GPU_FLOAT;
|
||||
case SOCK_INT:
|
||||
@@ -53,7 +53,17 @@ static eGPUType gpu_type_from_socket_type(eNodeSocketDatatype type)
|
||||
/* GPUMaterial doesn't support boolean, so it is passed as a float. */
|
||||
return GPU_FLOAT;
|
||||
case SOCK_VECTOR:
|
||||
return GPU_VEC3;
|
||||
switch (socket->default_value_typed<bNodeSocketValueVector>()->dimensions) {
|
||||
case 2:
|
||||
return GPU_VEC2;
|
||||
case 3:
|
||||
return GPU_VEC3;
|
||||
case 4:
|
||||
return GPU_VEC4;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return GPU_NONE;
|
||||
}
|
||||
case SOCK_RGBA:
|
||||
return GPU_VEC4;
|
||||
default:
|
||||
@@ -73,7 +83,7 @@ static void populate_gpu_node_stack(DSocket socket, GPUNodeStack &stack)
|
||||
zero_v4(stack.vec);
|
||||
|
||||
stack.sockettype = socket->type;
|
||||
stack.type = gpu_type_from_socket_type(eNodeSocketDatatype(socket->type));
|
||||
stack.type = gpu_type_from_socket(socket);
|
||||
|
||||
stack.hasinput = socket->is_logically_linked();
|
||||
stack.hasoutput = socket->is_logically_linked();
|
||||
|
||||
@@ -208,8 +208,8 @@ static void initialize_input_stack_value(const DInputSocket input, GPUNodeStack
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR: {
|
||||
const float3 value = float3(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
copy_v3_v3(stack.vec, value);
|
||||
const float4 value = float4(input->default_value_typed<bNodeSocketValueVector>()->value);
|
||||
copy_v4_v4(stack.vec, value);
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
|
||||
@@ -66,10 +66,17 @@ ResultType get_node_socket_result_type(const bNodeSocket *socket)
|
||||
case SOCK_BOOLEAN:
|
||||
return ResultType::Bool;
|
||||
case SOCK_VECTOR:
|
||||
/* Vector sockets can also be ResultType::Float4 or ResultType::Float2, but the
|
||||
* developer is expected to define that manually since there is no way to distinguish them
|
||||
* from the socket. */
|
||||
return ResultType::Float3;
|
||||
switch (socket->default_value_typed<bNodeSocketValueVector>()->dimensions) {
|
||||
case 2:
|
||||
return ResultType::Float2;
|
||||
case 3:
|
||||
return ResultType::Float3;
|
||||
case 4:
|
||||
return ResultType::Float4;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return ResultType::Float;
|
||||
}
|
||||
case SOCK_RGBA:
|
||||
return ResultType::Color;
|
||||
default:
|
||||
|
||||
@@ -38,8 +38,9 @@
|
||||
*
|
||||
* The shader is generic enough to implement many types of reductions. This is done by using macros
|
||||
* that the developer should define to implement a certain reduction operation. Those include,
|
||||
* TYPE, IDENTITY, INITIALIZE, LOAD, and REDUCE. See the implementation below for more information
|
||||
* as well as the compositor_parallel_reduction_info.hh for example reductions operations. */
|
||||
* TYPE, IDENTITY, INITIALIZE, LOAD, REDUCE, and WRITE. See the implementation below for more
|
||||
* information as well as the compositor_parallel_reduction_info.hh for example reductions
|
||||
* operations. */
|
||||
|
||||
/* Doing the reduction in shared memory is faster, so create a shared array where the whole data
|
||||
* of the work group will be loaded and reduced. The 2D structure of the work group is irrelevant
|
||||
@@ -108,6 +109,12 @@ void main()
|
||||
* it. */
|
||||
barrier();
|
||||
if (gl_LocalInvocationIndex == 0) {
|
||||
/* If no WRITE macro is provided, we assume the reduction type can be passed to the float4
|
||||
* constructor. If not, WRITE is expected to be defined to construct the output value. */
|
||||
#if defined(WRITE)
|
||||
imageStore(output_img, int2(gl_WorkGroupID.xy), WRITE(reduction_data[0]));
|
||||
#else
|
||||
imageStore(output_img, int2(gl_WorkGroupID.xy), float4(reduction_data[0]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_image_coordinates_uniform)
|
||||
LOCAL_GROUP_SIZE(16, 16)
|
||||
IMAGE(0, GPU_RGBA16F, write, image2D, output_img)
|
||||
IMAGE(0, GPU_RG16F, write, image2D, output_img)
|
||||
COMPUTE_SOURCE("compositor_image_coordinates_uniform.glsl")
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_image_coordinates_normalized)
|
||||
LOCAL_GROUP_SIZE(16, 16)
|
||||
IMAGE(0, GPU_RGBA16F, write, image2D, output_img)
|
||||
IMAGE(0, GPU_RG16F, write, image2D, output_img)
|
||||
COMPUTE_SOURCE("compositor_image_coordinates_normalized.glsl")
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_image_coordinates_pixel)
|
||||
LOCAL_GROUP_SIZE(16, 16)
|
||||
IMAGE(0, GPU_RGBA16F, write, image2D, output_img)
|
||||
IMAGE(0, GPU_RG16F, write, image2D, output_img)
|
||||
COMPUTE_SOURCE("compositor_image_coordinates_pixel.glsl")
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
@@ -25,9 +25,9 @@ IMAGE(0, GPU_R16F, write, image2D, output_img)
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_pad_extend_float4)
|
||||
GPU_SHADER_CREATE_INFO(compositor_pad_extend_float2)
|
||||
ADDITIONAL_INFO(compositor_pad_shared)
|
||||
COMPILATION_CONSTANT(bool, zero_pad, false)
|
||||
IMAGE(0, GPU_RGBA16F, write, image2D, output_img)
|
||||
IMAGE(0, GPU_RG16F, write, image2D, output_img)
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
@@ -147,14 +147,15 @@ DEFINE_VALUE("REDUCE(lhs, rhs)", "max(rhs, lhs)")
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_maximum_float3)
|
||||
GPU_SHADER_CREATE_INFO(compositor_maximum_float2)
|
||||
ADDITIONAL_INFO(compositor_parallel_reduction_shared)
|
||||
IMAGE(0, GPU_RGBA32F, write, image2D, output_img)
|
||||
DEFINE_VALUE("TYPE", "vec4")
|
||||
DEFINE_VALUE("IDENTITY", "vec4(FLT_MIN)")
|
||||
DEFINE_VALUE("INITIALIZE(value)", "value")
|
||||
DEFINE_VALUE("LOAD(value)", "value")
|
||||
IMAGE(0, GPU_RG32F, write, image2D, output_img)
|
||||
DEFINE_VALUE("TYPE", "vec2")
|
||||
DEFINE_VALUE("IDENTITY", "vec2(FLT_MIN)")
|
||||
DEFINE_VALUE("INITIALIZE(value)", "value.xy")
|
||||
DEFINE_VALUE("LOAD(value)", "value.xy")
|
||||
DEFINE_VALUE("REDUCE(lhs, rhs)", "max(rhs, lhs)")
|
||||
DEFINE_VALUE("WRITE(value)", "vec4(value, vec2(0.0f))")
|
||||
DO_STATIC_COMPILATION()
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class BlurOperation : public NodeOperation {
|
||||
const Result &size = this->get_input("Size");
|
||||
if (this->get_extend_bounds()) {
|
||||
Result padded_input = this->context().create_result(ResultType::Color);
|
||||
Result padded_size = this->context().create_result(ResultType::Float3);
|
||||
Result padded_size = this->context().create_result(ResultType::Float2);
|
||||
|
||||
const int2 padding_size = this->compute_extended_boundary_size(size);
|
||||
|
||||
@@ -268,8 +268,7 @@ class BlurOperation : public NodeOperation {
|
||||
float4 accumulated_color = float4(0.0f);
|
||||
float4 accumulated_weight = float4(0.0f);
|
||||
|
||||
const float2 size = math::max(float2(0.0f),
|
||||
size_input.load_pixel_extended<float3>(texel).xy());
|
||||
const float2 size = math::max(float2(0.0f), size_input.load_pixel_extended<float2>(texel));
|
||||
int2 radius = int2(math::ceil(size));
|
||||
float2 coordinates_scale = float2(1.0f) / (size + float2(1.0f));
|
||||
|
||||
@@ -327,7 +326,7 @@ class BlurOperation : public NodeOperation {
|
||||
|
||||
float2 compute_maximum_blur_size()
|
||||
{
|
||||
return math::max(float2(0.0f), maximum_float3(this->context(), this->get_input("Size")).xy());
|
||||
return math::max(float2(0.0f), maximum_float2(this->context(), this->get_input("Size")));
|
||||
}
|
||||
|
||||
bool is_identity()
|
||||
@@ -374,7 +373,7 @@ class BlurOperation : public NodeOperation {
|
||||
float2 get_blur_size()
|
||||
{
|
||||
BLI_assert(this->get_input("Size").is_single_value());
|
||||
return math::max(float2(0.0f), this->get_input("Size").get_single_value<float3>().xy());
|
||||
return math::max(float2(0.0f), this->get_input("Size").get_single_value<float2>());
|
||||
}
|
||||
|
||||
bool get_separable()
|
||||
|
||||
@@ -251,14 +251,13 @@ class BoxMaskOperation : public NodeOperation {
|
||||
|
||||
float2 get_location()
|
||||
{
|
||||
return this->get_input("Position").get_single_value_default(float3(0.5f, 0.5f, 0.0f)).xy();
|
||||
return this->get_input("Position").get_single_value_default(float2(0.5f));
|
||||
}
|
||||
|
||||
float2 get_size()
|
||||
{
|
||||
return math::max(
|
||||
float2(0.0f),
|
||||
this->get_input("Size").get_single_value_default(float3(0.2f, 0.1f, 0.0f)).xy());
|
||||
return math::max(float2(0.0f),
|
||||
this->get_input("Size").get_single_value_default(float2(0.2f, 0.1f)));
|
||||
}
|
||||
|
||||
float get_angle()
|
||||
|
||||
@@ -271,10 +271,10 @@ class CornerPinOperation : public NodeOperation {
|
||||
|
||||
float3x3 compute_homography_matrix()
|
||||
{
|
||||
float2 lower_left = get_input("Lower Left").get_single_value_default(float3(0.0f)).xy();
|
||||
float2 lower_right = get_input("Lower Right").get_single_value_default(float3(0.0f)).xy();
|
||||
float2 upper_right = get_input("Upper Right").get_single_value_default(float3(0.0f)).xy();
|
||||
float2 upper_left = get_input("Upper Left").get_single_value_default(float3(0.0f)).xy();
|
||||
float2 lower_left = get_input("Lower Left").get_single_value_default(float2(0.0f));
|
||||
float2 lower_right = get_input("Lower Right").get_single_value_default(float2(0.0f));
|
||||
float2 upper_right = get_input("Upper Right").get_single_value_default(float2(0.0f));
|
||||
float2 upper_left = get_input("Upper Left").get_single_value_default(float2(0.0f));
|
||||
|
||||
/* The inputs are invalid because the plane is not convex, fall back to an identity operation
|
||||
* in that case. */
|
||||
|
||||
@@ -261,10 +261,9 @@ class DirectionalBlurOperation : public NodeOperation {
|
||||
|
||||
float2 get_center()
|
||||
{
|
||||
return math::clamp(
|
||||
this->get_input("Center").get_single_value_default(float3(0.5f, 0.5f, 0.0f)).xy(),
|
||||
float2(0.0f),
|
||||
float2(1.0f));
|
||||
return math::clamp(this->get_input("Center").get_single_value_default(float2(0.5f)),
|
||||
float2(0.0f),
|
||||
float2(1.0f));
|
||||
}
|
||||
|
||||
float get_translation_amount()
|
||||
|
||||
@@ -269,8 +269,8 @@ class DisplaceOperation : public NodeOperation {
|
||||
* transform it into the normalized sampler space. */
|
||||
float2 scale = float2(x_scale.load_pixel_extended<float, true>(texel),
|
||||
y_scale.load_pixel_extended<float, true>(texel));
|
||||
float2 displacement = input_displacement.load_pixel_extended<float3, true>(texel).xy() *
|
||||
scale / float2(size);
|
||||
float2 displacement = input_displacement.load_pixel_extended<float2, true>(texel) * scale /
|
||||
float2(size);
|
||||
return coordinates - displacement;
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ class DisplaceOperation : public NodeOperation {
|
||||
|
||||
const Result &input_displacement = get_input("Vector");
|
||||
if (input_displacement.is_single_value() &&
|
||||
math::is_zero(input_displacement.get_single_value<float3>().xy()))
|
||||
math::is_zero(input_displacement.get_single_value<float2>()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -255,14 +255,13 @@ class EllipseMaskOperation : public NodeOperation {
|
||||
|
||||
float2 get_location()
|
||||
{
|
||||
return this->get_input("Position").get_single_value_default(float3(0.5f, 0.5f, 0.0f)).xy();
|
||||
return this->get_input("Position").get_single_value_default(float2(0.5f));
|
||||
}
|
||||
|
||||
float2 get_size()
|
||||
{
|
||||
return math::max(
|
||||
float2(0.0f),
|
||||
this->get_input("Size").get_single_value_default(float3(0.2f, 0.1f, 0.0f)).xy());
|
||||
return math::max(float2(0.0f),
|
||||
this->get_input("Size").get_single_value_default(float2(0.2f, 0.1f)));
|
||||
}
|
||||
|
||||
float get_angle()
|
||||
|
||||
@@ -55,13 +55,13 @@ class ImageInfoOperation : public NodeOperation {
|
||||
const Domain realized_domain =
|
||||
RealizeOnDomainOperation::compute_realized_transformation_domain(this->context(),
|
||||
domain);
|
||||
dimensions_result.set_single_value(float3(realized_domain.size, 0.0f));
|
||||
dimensions_result.set_single_value(float2(realized_domain.size));
|
||||
}
|
||||
|
||||
Result &resolution_result = this->get_result("Resolution");
|
||||
if (resolution_result.should_compute()) {
|
||||
resolution_result.allocate_single_value();
|
||||
resolution_result.set_single_value(float3(domain.size, 0.0f));
|
||||
resolution_result.set_single_value(float2(domain.size));
|
||||
}
|
||||
|
||||
math::AngleRadian rotation;
|
||||
@@ -71,7 +71,7 @@ class ImageInfoOperation : public NodeOperation {
|
||||
Result &location_result = this->get_result("Location");
|
||||
if (location_result.should_compute()) {
|
||||
location_result.allocate_single_value();
|
||||
location_result.set_single_value(float3(location, 0.0f));
|
||||
location_result.set_single_value(location);
|
||||
}
|
||||
|
||||
Result &rotation_result = this->get_result("Rotation");
|
||||
@@ -83,7 +83,7 @@ class ImageInfoOperation : public NodeOperation {
|
||||
Result &scale_result = this->get_result("Scale");
|
||||
if (scale_result.should_compute()) {
|
||||
scale_result.allocate_single_value();
|
||||
scale_result.set_single_value(float3(scale, 0.0f));
|
||||
scale_result.set_single_value(scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ class RelativeToPixelOperation : public NodeOperation {
|
||||
Result &output_vector_value = this->get_result("Vector Value");
|
||||
if (output_vector_value.should_compute()) {
|
||||
output_vector_value.allocate_single_value();
|
||||
output_vector_value.set_single_value(float3(value_in_pixels, 0.0f));
|
||||
output_vector_value.set_single_value(value_in_pixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class RelativeToPixelOperation : public NodeOperation {
|
||||
if (this->get_data_type() == CMP_NODE_RELATIVE_TO_PIXEL_DATA_TYPE_FLOAT) {
|
||||
return float2(this->get_input("Float Value").get_single_value_default(0.0f));
|
||||
}
|
||||
return this->get_input("Vector Value").get_single_value_default(float3(0.0f)).xy();
|
||||
return this->get_input("Vector Value").get_single_value_default(float2(0.0f));
|
||||
}
|
||||
|
||||
float2 compute_reference_size()
|
||||
|
||||
@@ -153,7 +153,7 @@ class SunBeamsOperation : public NodeOperation {
|
||||
|
||||
float2 get_source()
|
||||
{
|
||||
return this->get_input("Source").get_single_value_default(float3(0.5f, 0.5f, 0.0f)).xy();
|
||||
return this->get_input("Source").get_single_value_default(float2(0.5f));
|
||||
}
|
||||
|
||||
float get_length()
|
||||
|
||||
@@ -38,7 +38,7 @@ static void cmp_node_trackpos_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Float>("X");
|
||||
b.add_output<decl::Float>("Y");
|
||||
b.add_output<decl::Vector>("Speed").subtype(PROP_VELOCITY).dimensions(2);
|
||||
b.add_output<decl::Vector>("Speed").subtype(PROP_VELOCITY).dimensions(4);
|
||||
}
|
||||
|
||||
static void init(const bContext *C, PointerRNA *ptr)
|
||||
@@ -176,7 +176,6 @@ class TrackPositionOperation : public NodeOperation {
|
||||
speed_toward_next * float2(size));
|
||||
|
||||
Result &result = get_result("Speed");
|
||||
result.set_type(ResultType::Float4);
|
||||
result.allocate_single_value();
|
||||
result.set_single_value(speed);
|
||||
}
|
||||
@@ -195,7 +194,6 @@ class TrackPositionOperation : public NodeOperation {
|
||||
}
|
||||
if (should_compute_output("Speed")) {
|
||||
Result &result = get_result("Speed");
|
||||
result.set_type(ResultType::Float4);
|
||||
result.allocate_single_value();
|
||||
result.set_single_value(float4(0.0f));
|
||||
}
|
||||
|
||||
@@ -505,10 +505,7 @@ static void motion_blur_cpu(const Result &input_image,
|
||||
|
||||
class VectorBlurOperation : public NodeOperation {
|
||||
public:
|
||||
VectorBlurOperation(Context &context, DNode node) : NodeOperation(context, node)
|
||||
{
|
||||
this->get_input_descriptor("Speed").type = ResultType::Float4;
|
||||
}
|
||||
using NodeOperation::NodeOperation;
|
||||
|
||||
void execute() override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user