filters icon indicating copy to clipboard operation
filters copied to clipboard

Bug with wgsl on some filters (v8)

Open pagoru opened this issue 1 year ago • 1 comments

https://github.com/pixijs/filters/blob/a287d90ee07ca237dfed3af5321976be6e3c6b05/filters/pixelate/src/pixelate.wgsl#L16-L30

textureSample wants a texture_2d, sampler and vec2

This is wrong on a lot of filters, and this is the fix:

 @group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
 @group(1) @binding(0) var<uniform> pixelateUniforms : PixelateUniforms; 
  
 @fragment 
 fn mainFragment( 
   @location(0) uv: vec2<f32>, 
   @builtin(position) position: vec4<f32> 
 ) -> @location(0) vec4<f32> { 
  let pixelSize: vec2<f32> = pixelateUniforms.uSize;
  let coord: vec2<f32> = mapCoord(uv);

  var pixCoord: vec2<f32> = pixelate(coord, pixelSize);
  pixCoord = unmapCoord(pixCoord);

  return textureSample(uTexture, uSampler, pixCoord);

pagoru avatar Jan 03 '24 23:01 pagoru

Thanks @pagoru ! I have updated on all filters accordingly 🙏

bbazukun123 avatar Jan 04 '24 16:01 bbazukun123