Mirza Beig@TheMirzaBeig
Optimization/tweak updates are live, ⏱️
> for the layered frosted glass demo.
The key/trick is to remember that performance for graphics is broadly dependent on instructions * pixels. Reducing either or both is how you get faster rendering, per-frame rendered:
> reduce the operations per pixel,
and the number of pixels.
Scaling the pixels of a 2D frame (like your screen) is quadratic. So it goes both ways for lower or higher computation requirement. Rendering to lower-resolution textures means reducing total instructions for every pixel, at a rate of 4x with uniform scaling.
Outside of electronic computation, it's a matter of design and conceptual application-- exploiting parallel processing via GPUs, identifying/discovering more suitable, faster, efficient algorithms/sequencing/systems for a purpose (task, work to do).
-- [There is altogether another meta layer, of consideration for end users and their willingness to go through additional customized setting up for their projects. While keeping in mind my own past 'trauma' from the API flux of Unity's SRPs.]
While having a chain of scaling textures would be more efficient and is standard, I'm relying a lot on a few lower-resolution render targets at key points, including the final output. Because it's Web, people do not expect particularly crisp graphics, and for mobile you have a very high physical pixel density because of the small screens, regardless:
2 to 8 million pixels on a rectangle,
on screens the ~size of your face.
💸 Blur functions are expensive. I could do separate passes (x + y number of instructions vs. x * y), but it's also more complexity in the tech. maintenance chain for me, and can slow down my iteration speed for development.
I opt for finding ways getting away with less instructions per pixel, when there are all those pixels to still process-for -> 'stochastic sampling' (less calls to the heavy blur functions). I parameterize the shader to allow for custom scene textures, too. It's a downsample of 2-8x for the back.
Later, I *could* (thought probably won't) implement sampling from textures of variable blur, best fitting the intended radius or simulation of smoothness for scattering, which is what Doom (2016) does. It ought to be much faster for performance, or maybe I could tap into Unity's globals. 🤷♂️
✨ I'm liking the progress/results so far!