Compositor: Set W to 1 in Float to Vector conversion

Set the w component to 1 in Float to Vector implicit conversion for the
Realtime Compositor. That's because the Vector Output node expects a
vector for the velocity input, but the CPU compositor fakes it as a
color input, while assumes a fourth component of 1.
This commit is contained in:
Omar Emara
2024-04-02 18:10:13 +02:00
parent 77a34791a3
commit 5de40790d0
3 changed files with 4 additions and 4 deletions

View File

@@ -49,8 +49,8 @@ class ConversionOperation : public SimpleOperation {
/* -------------------------------------------------------------------- */
/** \name Convert Float to Vector Operation
*
* Takes a float result and outputs a vector result. All three components of the output are filled
* with the input float.
* Takes a float result and outputs a vector result. The first three components of the output are
* filled with the input float, while the fourth component is set to 1.
* \{ */
class ConvertFloatToVectorOperation : public ConversionOperation {

View File

@@ -98,7 +98,7 @@ ConvertFloatToVectorOperation::ConvertFloatToVectorOperation(Context &context)
void ConvertFloatToVectorOperation::execute_single(const Result &input, Result &output)
{
output.set_vector_value(float4(float3(input.get_float_value()), 0.0f));
output.set_vector_value(float4(float3(input.get_float_value()), 1.0f));
}
GPUShader *ConvertFloatToVectorOperation::get_conversion_shader() const

View File

@@ -19,7 +19,7 @@ GPU_SHADER_CREATE_INFO(compositor_convert_float_to_float)
GPU_SHADER_CREATE_INFO(compositor_convert_float_to_vector)
.additional_info("compositor_convert_shared")
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.define("CONVERT_EXPRESSION(value)", "vec4(vec3_from_float(value.x), 0.0)")
.define("CONVERT_EXPRESSION(value)", "vec4(vec3_from_float(value.x), 1.0)")
.do_static_compilation(true);
GPU_SHADER_CREATE_INFO(compositor_convert_float_to_color)