Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with wgsl on some filters (v8) #398

Open
pagoru opened this issue Jan 3, 2024 · 1 comment
Open

Bug with wgsl on some filters (v8) #398

pagoru opened this issue Jan 3, 2024 · 1 comment
Assignees

Comments

@pagoru
Copy link

pagoru commented Jan 3, 2024

@group(0) @binding(1) var uSampler: texture_2d<f32>;
@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(uSampler, uSampler, pixCoord);

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);
@bbazukun123
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants