Already a little over 2 months since the last release but finally I got this one out. This is quite a big release with a lot changing under the hood which meant a lot of refactoring and then a few headaches getting the mac version up to speed but I got there in the end. These are the main changes:
API Re-factor which changes how you get sprites from TimelineFX to the GPU.
This is a really positive change that I’m happy with. Before this change, in order to draw sprites that timeline fx produced you would basically have to loop over all the sprites and rely on some kind of draw sprite command in whatever renderer you use to send the sprites to the GPU for rendering. This meant 2 things: 1) If you wanted to interpolate the sprites to smooth out the rendering from one frame to the next you would have to do that on the CPU and 2) you would have to send all the sprites to the GPU every frame.
This is no longer necessary. Now a TimelineFX particle manager will produce a sprite buffer that can simply be uploaded to the GPU each time the effects are updated. No interpolating on the CPU is required as it can now be handled entirely in the vertex shader because you can just bind the sprite buffer of the previous frame in the vertex shader and lookup the previous sprite position/scale/rotation etc and interpolate from there. The sprite buffer contains a “captured index” you can use to index in to the previous sprite buffer. Because modern renderer APIs like Vulkan, metal and directx 12 usually have 2 or more frames in flight it’s easy to just simply bind the previous frame’s sprite buffer and use it as a lookup. This has greatly simplified how to implement TimelineFX in to your own renderer where now generally all you’d need to do is copy the sprite buffer from the particle manager to your staging buffer in your renderer for uploading to the GPU.
This means that you only need to upload whenever the particle manager is updated, not every frame. So if you wanted you could just update the particle manager 30 times a second and then whatever the actual frame rate that the renderer is running at if the particle manager hasn’t been updated all you need to do is send the latest interpolation value to the shader and whatever is currently in the vertex buffers will be interpolated and drawn. I will of course produce working examples for all this in due course.
Colour ramps moved to fragment shader
Previously I was storing the colour of each particle in the sprite instance but I’ve changed this so that all of the colour ramps which dictate how the particles change overtime are now stored in bitmaps and uploaded to the GPU. These are then sampled in the fragment shader with lookup indexes stored in the sprite instance data.
UV data stored in GPU buffer
Another thing that I’ve moved to the GPU that was also previously sent in the instance data is the UV coordinates of each image. Now all of the image data containing the UV coordinates for each frame of each image are sent to the GPU and that data is then bound to the vertex buffer and looked up there instead. This saves a lot of space in the instance data and makes things a lot more efficient. Of course the image data only needs to be uploaded once before you draw anything.
New Curved Alpha and Alpha Sharpness attributes
In the last update I wrote about compiling fragment shaders in the editor and whilst I do want do something like that at some point so far I have just updated the default fragment shader with 2 new attributes you can find under the Particle Behaviour > Colour attributes. These are Curved Alpha which allows you to dissolve the particle based on the alpha values stored in the image. Combine this attribute with Alpha Sharpness to determine how sharp the edges of the dissolve are. This greatly improves the options you have for fading particles out and making effects better quality.
As you can see in the image above on the left is the typical fading out of a particle using the intensity graph, but on the right using curved alpha with a little bit of sharpness the particle fades out in a much more convincing way. This is implemented in the fragment shader with minor amount of extra overhead.
Shape preview added under colour attributes
I also added a small feature that shows you exactly how the particle will look with all of the colour attributes applied. If you hover the mouse over the preview you will see a larger tool tip. This makes it a little easier to see how the image looks rather then relying on the preview window alone.
So all these changes took a lot of refactoring in the render and editor so hopefully I haven’t introduced too many new bugs, so I’ll probably spend the next couple of weeks just tidying things up a bit and making sure every thing’s as nice and stable as I can make it (I already noticed one issue whilst writing this post!). The Mac version was especially tricky not so much on my Arm based Mac but more the older intel based Mac I have. Got there in the end though.
I really want to improve all of the example effects I have so far and properly revamp them with new shapes and take advantage of the new colour attributes.
As usual the full list of updates are here, and the next alpha should come around a lot quicker I think after a general tidy up!
* Added new Alpha Sharpness and Curved Alpha attributes found under Particle Behaviour Overtime > Color. These new attributes allow you to dissolve the particle image based on the alpha value in the image.
* Big changes to how the shaders work to render the particles. This is more of an API change but now the interpolation of the particles is done entirely in the vertex shader.
* Color ramps are now stored as bitmaps and uploaded to the GPU for direct sampling by the fragment shader.
* These changes are a big optimisation as it reduces the amount of sprite data that needs to be processed and sent to the GPU. Much less load on the CPU.
* Separated out some of the options found under Spawn Options like relative position and layer and moved them in to a new group called Emitter Options.
* Sprite data compression is much more robust now, however there is an issue on ARM Mac version which is being looked in to. Hopefully will fix for next update.
* You can now rename shapes in the library.
* Setting reverse for edge traversal no longer interferes if you then switch the emission type.
* Added note to emission type about switching between 2d/3d.
* Added the color palette in to the color picker widget.
* Update frequency now gets updated properly in the config file and remembered next time you run the editor.
* Fixed a crash happening with one of the tool tips.
* The replay effect when effect ends option no longer stops low spawn rate emitters from spawning any particles.
* Added a new shape preview under color options so you get an actual preview of how the shape will look.
* Fixed an issue where you couldn’t import an effect with click and drag.
* The minimum amount of compressed frames under sprite data is now 2.
* New insights added for the new color graphs (alpha sharpness and curved alpha)