Posted November 04, 2022 by IntakeOVR
This update is mainly about performance, nothing so new. Other than that, there are some minor improvements.
What's in this update
Faster performance
The performance is now up to 3 times faster. Here, we're adding and removing blocks on the Aura example then calculate the time it takes to generate shader which is displayed on the top left of viewport. To test this we used a pretty old laptop.
The previous version takes 38-42 ms to generate the shader, while on the new version it takes 11-21 ms to generate. So in this test the new version is 2-3 times faster.
That's because in previous versions, it generates not only for the canvas but also for each individual blocks, and they're all unique materials.
You can see this by right-clicking a block preview.
But now it's different, now it generates only one shader and that will be used for everyone. This is done by using an array of previews and indexed by block id through the color attribute (because it is unique to every Godot CanvasItem), and the canvas id is the last element of array which is the main image.
That's for the code generation, for the realtime performance, it should be faster too because there's only one material and not unique.
New inputs
We implemented new inputs:
The color input is already there since the beginning, it's just not properly implemented because color is a unique attribute and it would need to be changed for each block, but thanks to the new preview logic, we now have to use a uniform for color and that's shared to all blocks.
Minor improvements
What's next
On the next weekly update I will (hopefully) complete all unimplemented blocks and add some new blocks, and fix an issue where default variable names breaks your shader when loaded