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

Filter shaders applied to framebuffers with a different size than the main canvas are drawn at the wrong scale #6782

Closed
1 of 17 tasks
davepagurek opened this issue Jan 31, 2024 · 0 comments · Fixed by #6783
Closed
1 of 17 tasks

Comments

@davepagurek
Copy link
Contributor

davepagurek commented Jan 31, 2024

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

1.9.0 and 1.9.1

Web browser and version

Firefox 117

Operating system

MacOS 14.2.1

Steps to reproduce this

Steps:

  1. Create a framebuffer that's a different size from the main canvas
  2. Apply a filter shader to it
  3. Do something to see the contents of the framebuffer (e.g. draw it to the main canvas or save it to an image)
    The framebuffer's contents have been scaled incorrectly. This is due to the fact that we're accidentally drawing images at the size of the renderer, not the size of the target, which might be different:
    this._pInst.image(fbo, -this.width / 2, -this.height / 2,
    this.width, this.height);

Snippet:

function setup() {
  createCanvas(400, 400, WEBGL);
  
  const fbo = createFramebuffer({ width: 200, height: 200, density: 1 })
  fbo.draw(() => {
    background(0)
    fill(255)
    circle(0, 0, 125)
    // Try commenting this out
    filter(GRAY)
  })
    
  background('red')
  imageMode(CENTER)
  image(fbo, 0, 0, fbo.width, fbo.height)
}

Live: https://editor.p5js.org/davepagurek/sketches/YVRQq7Bqy

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

Successfully merging a pull request may close this issue.

1 participant