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

WebGL Slower than earlier versions - is that normal? #6407

Closed
joemckay5 opened this issue Sep 14, 2023 · 3 comments
Closed

WebGL Slower than earlier versions - is that normal? #6407

joemckay5 opened this issue Sep 14, 2023 · 3 comments

Comments

@joemckay5
Copy link

Topic

Hi all.
I'm working on a game in p5 using WebGL. I've noticed that current versions of P5 are laggy, especially in Safari, however, if I back up to version 0.10.2 the game runs much more smoothly.
Question: Is this just the way it is and WebGL 2 has more features but is slower, or is there a "better practices" way to work with WebGL 2 that I'm not using?
If looking at my code helps, here's a relatively recent build on my website. http://www.joemckaystudio.com/awfultreefarmer/
I'm running this on an older (2019) intel mac laptop.
Thanks,

@davepagurek
Copy link
Contributor

We've added some new features since then, such as stroke caps and joins, which increase the complexity of things like lines and per vertex colors. There are some performance updates coming in the next version (#6230) but we've also found it hard to make further optimizations for sketches in general, where some systems see big gains while others slow down (#6162).

As for what to do about it, we've found that the biggest bottleneck tends to be CPU to GPU transfer. When drawing shapes in immediate mode, a lot of repeated work gets done each frame and gets sent to the GPU. A way to cache shapes on the GPU is to use p5.Geometry. There are some tutorials about that, and the next p5 version will start to add easier ways to build these (#6287), and in the mean time you can maybe try using this library for similar functionality: https://github.com/davepagurek/p5.buildgeometry

@joemckay5
Copy link
Author

Thanks for the quick reply. I'll poke around p5.Geometry and the buildGeometry Library. Must be "fun" trying to work with multiple browsers.

@davepagurek
Copy link
Contributor

I'm going to close this for now for organizational purposes, but feel free to open new issues for optimizations that you can think of, or carry on the discussion in issues like #5975!

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

No branches or pull requests

3 participants