Skip to content

Commit

Permalink
wgpu: Sum up all center blur pixels before multiplying
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Jul 17, 2023
1 parent 18e343c commit a35ea3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion render/wgpu/shaders/filter/blur.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ fn main_fragment(in: filter::VertexOutput) -> @location(0) vec4<f32> {
}

// At this point, the center_length must be a whole number, divisible by 2.
var center = vec4<f32>();
for (var i = 0.0; i < center_length; i += 2.0) {
// The center of the kernel is always going to be 1,1 weight pairs. We can just sample between the two pixels.
total += textureSample(texture, texture_sampler, in.uv + (direction * (1.5 + i))) * 2.0;
center += textureSample(texture, texture_sampler, in.uv + (direction * (1.5 + i)));
}
total += center * 2.0;

// The sum of every weight is full_size
return total / filter_args.full_size;
Expand Down

0 comments on commit a35ea3d

Please sign in to comment.