WebGL `setAttributes` causes image interpolation to default to LINEAR
Open
Nobody has claimed this yet.
Area:WebGL
Bug
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
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.11
Web browser and version
129.0.6668.58 & 115.15.0esr
Operating system
Debian 12
Steps to reproduce this
Steps:
- Call
setAttributes setInterpolationon a texture toNEAREST- Render the texture and watch it not work
Example (working sketch located at https://editor.p5js.org/PotatoBoy/sketches/tFXOSAnZV):
let img;
let canvas;
function preload() {
img = loadImage('test.png');
}
function setup() {
canvas = createCanvas(400, 400, WEBGL);
setAttributes({ alpha: true });
canvas.getTexture(img).setInterpolation(NEAREST, NEAREST);
}
function draw() {
background(0);
image(img, -width / 2, -height / 2, width, height);
}
Result:
Expected Result:
Note: Related to https://github.com/processing/p5.js/issues/6325 which is encompassed by this issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction and trace the WebGL paths for setAttributes and setInterpolation. Verify the texture setup before and after setAttributes, then confirm the fix by rerunning the sketch and checking that NEAREST interpolation remains effective when the texture is rendered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100