I am creating a christmas background, its completely made out of different shapes (background mountains with bright moon, middleground lake with decorated christmas trees and foreground are dark pinetree tops).
I found out about drawingContext.filter = blur one hour ago, but while applying to my background mountains, moon and foreground dark pinetree tops; my canvas has a 1 FPS.
Is there a solution? I thought that drawingContext.filter = blur was the faster option, from filter(blur)? I have 32GB RAM and by far not the slowest processor.
Not sure if this question needs my code.. I assume not as it is just a general question but if you do require it, I will be happy to upload it.
I removed drawingContext.filter = blur one by one, but even with only one place to use it, my FPS remains 1.
Only when i completely remove the filter, my FPS goes back to 60.
I have gone through this before. It is possible that
drawingContext.filter = blur
is the fastest solution using CPU, I'm not sure about that. But what I'm sure is that you'll get incredibly faster results using GPU. Move to shaders. It is a little scary at the beginning but you'll definitely get way faster performance there.Here is a good explanation why: https://www.youtube.com/watch?v=-P28LKWTzrI
I was doing everything in P5 and it was taking about 10secs to render a frame. I didn't move all to shaders. I created a buffer canvas with the raw input, sent it to the shader and then placed the filtered image back to P5 to merge with the main canvas. It went down from 10s a frame to 60fps. Huge improvement.
Here is a sample of how my p5js code looks. I'm marking the important lines:
Let me know if you need more details. I'll be happy to expand.