Hi there everyone! My name is Simon Kratz and in this tutorial I’m going to explain my workflow of baking particle effects for use in models uploaded to Sketchfab. You can also find the Maya and 3ds Max edition on the Sketchfab blog, in case you missed it 🙂
If you want to add some subtle motion to your scene or enhance other animations with small environmental details like dust and small debris after an explosion, then particle effects are the way to go. You could also keyframe each object individually but if you need lots of individual elements with random motion then particle effects will be the right choice.
At our game studio I’m also the guy who is mainly responsible for the vfx of our games and even though I do most of the stuff inside Unity I needed to find a workflow to exchange particle animations between programs, just in case we need something more complex than Unity can do by itself.
In this tutorial I’m gonna cover a workflow you can use directly with Blender, I’ll derive other software specific tutorials later on. I’m sure some of you will also be able to translate the workflow into different programs by themselves 🙂
Let’s get started!
General approach
I will use Blender here with it’s integrated particle system. You can use any software to your liking since most particle systems share similar functionality. Just keep in mind this tutorial will cover the Blender workflow so things may be different for your case. But as long as you keep in mind we will export the final effect as an animated fbx you should be fine. It helps knowing fbx functionality and Sketchfab’s feature support to get an idea of what can be exported.
As an example:
- You want each of your particles to be attracted to a single point inside your scene?
Nice! That’s basically just a position animation, go ahead and do it! - You want your particles to change color over lifetime?
This is a common particle system feature. But I’m afraid there is currently no way to this in an fbx file (or any other file format I know of).
Creating your particle effect
For my example project I just set up a basic shape in Blender to define an Emission shape. Which shape to choose depends on the effect you would like to achieve. After setting up your basic shape add a Particle System component in the respective tab (the one with four fancy yellow sparkles).
I made some changes to the emitter but much of the motion was added later using Force Field objects. Again, all of the settings depend on the effect you’re going for and it needs some experience to get a grip of everything. But don’t let this discourage you if you’re just starting 🙂
You should already be seeing some motion now if you hit the play button. Most particle systems are also directly linked to your software’s physics simulation system. So if you want to incorporate your particles into a larger physics based animation that’s no problem at all.
In this case I set up a couple of Force Fields (found in the Shift + A menu) and blended their contribution to the final effect using their parameters. You can even animate Force Fields to make your effect look more vivid.
Preparing your effect for baking
Once you’re satisfied with your effect we can start baking it! Sadly Blender doesn’t have a baking solution included that keeps the animation so we’ll have to help ourselves with some preparation.
First, we won’t export plain dots as particles. We need to define an object that we’ll use as a particle mesh. If you haven’t already done so, set the rendering of your particle system to “Object” and assign one of the objects in your scene to the respective slot that appears. You should see the final mesh for your particles inside your scene view now.
You can still transform your object or tweak the animation to your liking.
Baking your particles
Once everything is perfect we’ll need some help from Python 😉 Even though Blender itself can’t bake the particles the logic to do so is scriptable. We’ll use a script that creates a duplicate of our particle mesh for each particle and bake the position, rotation and scale each frame for each of those duplicates. I found a very helpful solution here. You can just copy paste this into Blender’s text editor.
It has some handy controls in the top lines. I suggest you set KEYFRAME_VISIBILITY to False since we need all the particles to be visible to export them. Also delete lines 37, 39 and 40. This way all your particles will be visible.
Keep in mind we’re baking a lot of animated objects here to work in realtime later on. I wanted to push Sketchfab a bit and animated a thousand particles in my upper embed. It still runs perfectly fine on Desktop but a bit slow on mobile. One of my other models has 200 baked particles and it still works fine on mobile. This is just my experience and might vary depending on your polycount/number of materials/length of animation/etc.
Maybe it’s a good rule of thumbs to not go too much above 200 particles if you want to give a good user experience to the Sketchfab users on mobile. 🙂
Finally you’ll have to select two objects: first your reference object (in most cases the one you set as particle mesh earlier), and then your particle system. With both of them selected hit the “Run Script” button in Blender’s text editor and let the magic happen! It might take a while, depending on your number of particles.
Aaaaand it’s done!
You should now see many new objects in your hierarchy, one for each of your particles. Now all that’s left to do is deleting or hiding the original particle system and your reference object. You could delete/hide your physics stuff, too just to keep the exported fbx less messy.
That’s it for this lesson in particle fx for Sketchfab. I’ll try to add more specific workflows for other software later on. But I don’t know all the tools out there so if you find a workflow for your software of choice feel free to drop me a line so I’ll mention you and your solution in the next tutorial. Or maybe you’d like to write a tut about your idea yourself? 🙂
Now go ahead and create some amazing particle effects!
This is such a nice trick, will have to think of a scene to try it out with! Thanks Simon 😉
mind blown.
have to try now
awesome, I have been trying to do this in Maya since seeing your crystal valley. sadly with little success
Hi Essimoon,
Thank you for sharing this production trick.
Here is the result of my experiments with this integration technique.
https://sketchfab.com/models/ef95e9162cce44f0bf0bf30781eee2c8
:0) Jean-Philippe
Thanks Lee!
Maybe I’ll dig into Maya and try to figure out another tut for a working setup 🙂
Let me know if you have some progress!
You’re welcome and awesome job using it! 😀
It’s great to see people profit from this, hope I can do another tut soon.
thank you for this useful way and i really like the physic section in blender i was wondering if there is another way to control opacity for unborn particles in my case am trying to export the particle system i create to Maya so i was looking for a way to convert the particle system animation into real mesh with animation curve so i can export it (i was surprised how hard it is to find a way for this simple task on the internet ! )
it works now because of your nice trick here to Maya but the particles opacity i have no clue how to control it cause i want to export it like .abc file is it possible in the first place ?
any help with this it will be problem solving for a lot of people who trying to integrate blender better in the classic workflows (nuke Maya ) !
thank you
Hi Sam, thanks and I’m glad you like it! 🙂
Sadly I don’t know much about Maya but exporting animated opacity is actually a file format export problem. I don’t know about .abc files but afaik there is no file format able to export per-object opacity animation.
The only (partially) exception is Autodesk FBX, which offers a “visibility” value, ranging from 0 – 1. But hardly any other program or service support that one.
So we’ve yet to find a solution for this 😉
How can I make this work with group instead of a single object reference?
Thanks for the show-all… but- once you bake the animation, you essentially have ‘PLA’ or point-level animation- which Sketchfab does not support, no?
Hi Matt, once you bake the animation you’ll get just Transform/Rotate/Scale animation, no PLA. Sketchfab supports these just fine 🙂
Thanks for guide!!
I have a question. How can I set a constant scale (0,0,0) for dead particles?
Hey there! 🙂
It is possible but requires a couple of tricks. First, you gave to create a new texture for the particle system in Blender. Make it a white/black gradient.
Then under “Mapping” choose “Strand/Particle” to map the texture on each particle”s lifetime. Finally, under “Influence” choose “Size”.
That should do the job 🙂
Hi,
thanks for this tuto,
I have tried (Blender 2.79) but got an error running the script (‘Python script failed, look in the console for now’).
I don’t think I made a mistake in the script (just replace ‘True’ by ‘False’ for Visibility and deleted the 3 recommended lines.
I do not know python though…
Any advices from you guys?
Thank you
Hi Gilles,
you’re right, it seems Blender changed something in this version. I quickly created a working snippet for you 🙂
https://bitbucket.org/snippets/essimoon/ke74G6
Hi Simon,
Thanks a lot for spending time on this. I works great !
Thank you
I have question, if i want to put more of one objet for emitt. in my case, i want place diferent leaves, but i can only see one leave after put the run script . so my question is, ho i can put or select more objets to see them after click the run script?
Hi Miguel!
This should be possible with setting up additional copies of your particle system with the leave variations. Just copy & pastte the particle system, change the leaves and bake it 🙂
Hi Simon, and thank you for this nice read! Very understandable and practical, so greatly appreciated 😀 !
The python script was magical (had to think about it!), yet I still struggle to export the “baked” particles to a fbx file from blender… Whatever I try, the particle’s geometry is copied over and over again, making a simple animation a few hundreds MB… I therefore had to directly export the .blend file, which is OK to me, but seems a bit of a cheat…
Would you happen to have any clue on that?
Also, I tried to create a bubble system (which I started at around the -100th frame), but the “not born yet” particles appear as fixed in the scene, before being scaled down to zero when they are born… I should fiddle around about that, but would you also have any insight on the matter?
I made a nice (at least as “particle-beginner” I’m really proud of it) model inspired from your work, with little fish as particles ( https://skfb.ly/6y7vC if you are curious )!
Thanks for any advice, and thanks anyway for your work!
Hi Loïc, happy you like the tut 🙂
I see the problem with lots of particles, hmm.. It doesnt look like Blender can preserve instances on fbx export at the moment so I’m afraid any duplicate geometry will add to the final file size :/
But using a blend file to avoid this issue actually is a pretty nice trick so why not go with it?^^
I’m pretty sure you can workaround the second issue by scaling your source object to zero (don’t apply transforms! the scale must be at 0!).
Blender should then create the new objects with the source’s scale. As far as I know scale values override in Blender, so if scale is set from a baked particle effect, it should still work despite the original scale value being zero at that time 🙂
best, Simon
Awesome script, thanks simon. I’ve testet it with Blender 2.79 and it works like a charm. Is there any chance to get a port for 2.80?
Hi Frank,
I didn’t really test it with 2.8, yet. Does it not work?
I think 2.8 uses a newer version of python.
It would be nice to be able to use this in 2.8 – especially as Blender won’t let me install 2.79
Dear Simon, dear Sam,
the user “lemon” upgraded the script to Blender 2.80. You can find it here:
https://blender.stackexchange.com/questions/153505/convert-particle-system-to-animated-meshes-blender-2-8/153515
wow great to hear, thanks a lot for the link, Frank!
Hi all,
I tried to follow this guide, but unfortunately when I get to the script step it gives me an error “Python script failed, check the message in the system console” and i cant find anything log in to the console.
I try this with 2.79 | 2.80 | 2.81
Anyone have the same error?
Thanks
I need to upload the Particles effects from Unity to Sketchfab
So when you said Delete lines 37, 39, and 40… and all I see is a note, and code for scale and rotation.
Everything works! Except I can’t figure out how to make all the meshes one object while maintaining the unique animations for each converted particle. Yes you can select all mesh particles and export them which treats it as one object but now I have animations for each particle/mesh that will only play one at a time based on selection…how do I make them play all at once? Or do I merge the animation data together? Any help would be great, Thanks!
Hi Ross, just uncheck “All actions” in Blenders fbx export tab under “animation”. Then you should be good to go 🙂
This is awesome! thank you for sharing your findings.
I just successfully used it in our Blender -> GLTF workflow
I’ll spread the word 🙂
Hi everyone,
script works well on Blender 2.8 and 2.9 but impossible to export in fbx format. When tying to export fbx with animmation, Blender don’t respond. Did or do you have the same issue?