-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
updatePixels() can't be called in WEBGL Mode #5155
Comments
It somehow seems that this just never existed which is extremely odd. It seems as though you are the first person to try to do pixel manipulation of a WebGL canvas and make an issue about how it doesn't work. So strange. Anyways, we should likely add this or at least add a stub function so this doesn't crash sketches. I am not sure what the best approach would be for setting the pixels in the WebGL context. I don't think there is a direct way to write pixels so some process of conversion would have to happen. |
Yeah, I thought it was weird too, but maybe it's kind of an unusual thing to be doing 😅 I think in terms of implementation, all we would need to do is essentially just create a texture using the current pixel data and run it through a shader that just draws that texture to the screen. It's definitely going to be a slow operation, but good for a case when you want to go shader -> pixels and back again. In my case I worked around it by just creating another non-webgl graphics object, drawing my webgl texture to there and then doing my pixel operations. |
Here's a small example of how it could be implemented just using existing functions. I'm not sure it's the most efficient but it works 🤷 |
I was trying to do this too and it didn't work... would be cool to set directly pixels using WEBGL context |
I think you may be better off just drawing your webGL buffer to a graphics object that is not in webGL mode, doing your pixel manipulation there, and then drawing that back to the webGL canvas. |
Any updates on this? Thank you. |
I was having this same issue, I use pixels to create a filter for my sketches. doesn't work in WebGL :( Any updates? |
Seems that it's still a problem in 2023, any news? |
It's on the roadmap now, so it won't get lost! (You can see how we've sorted WebGL issues here: https://github.com/orgs/processing/projects/5) There's a lot of WebGL things in there so this one isn't an immediate priority. However, if anyone is interested in tackling this in the mean time, feel free to let me know, and I can help guide the process! |
Hey, @davepagurek I want to work on this issue. Do you have any suggestions that might help me regarding this issue? |
Thanks @nikhilhvr, I'll assign this to you! I think @aferriss's comment #5155 (comment) is probably the best approach for now -- when one wants to
|
This ended up getting implemented as part of #6109 🙂 |
Most appropriate sub-area of p5.js?
Details about the bug:
When using webGL mode, I'm not able to call
updatePixels()
. An error is given that updatePixels isn't a method on the current renderer. This applies to instances created with createGraphics in webGL mode as well.Here's a sample sketch showing the issue.
https://editor.p5js.org/aferriss/sketches/LlY7q2OLE
createCanvas(400, 400, WEBGL)
updatePixels()
The text was updated successfully, but these errors were encountered: