Fix: GPU Directional Blur distorts input
The GPU Directional Blur node distorts the inputs if the resolution is not square. This is because rotation is performed on normalized coordinates. This patch performs the normalization at the texture evaluation.
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
void main()
|
||||
{
|
||||
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
|
||||
ivec2 input_size = texture_size(input_tx);
|
||||
vec2 input_size = vec2(texture_size(input_tx));
|
||||
|
||||
vec2 coordinates = (vec2(texel) + vec2(0.5)) / vec2(input_size);
|
||||
vec2 coordinates = vec2(texel) + vec2(0.5);
|
||||
|
||||
float current_sin = 0.0;
|
||||
float current_cos = 1.0;
|
||||
@@ -30,7 +30,7 @@ void main()
|
||||
transformed_coordinates *= mat2(current_cos, current_sin, -current_sin, current_cos);
|
||||
transformed_coordinates += origin;
|
||||
|
||||
accumulated_color += texture(input_tx, transformed_coordinates);
|
||||
accumulated_color += texture(input_tx, transformed_coordinates / input_size);
|
||||
|
||||
current_scale += scale;
|
||||
current_translation += translation;
|
||||
|
||||
@@ -117,7 +117,7 @@ class DirectionalBlurOperation : public NodeOperation {
|
||||
const float2x2 rotation = math::from_rotation<float2x2>(
|
||||
math::AngleRadian(-node_storage(bnode()).angle));
|
||||
const float2 translation = rotation * float2(-translation_amount / get_iterations(), 0.0f);
|
||||
return translation / input_size;
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* Get the amount of rotation that will be applied on each iteration. */
|
||||
@@ -135,7 +135,8 @@ class DirectionalBlurOperation : public NodeOperation {
|
||||
|
||||
float2 get_origin()
|
||||
{
|
||||
return float2(node_storage(bnode()).center_x, node_storage(bnode()).center_y);
|
||||
const float2 input_size = float2(get_input("Image").domain().size);
|
||||
return float2(node_storage(bnode()).center_x, node_storage(bnode()).center_y) * input_size;
|
||||
}
|
||||
|
||||
/* The actual number of iterations is 2 to the power of the user supplied iterations. The power
|
||||
|
||||
Reference in New Issue
Block a user