Baking Particles for Sketchfab (Blender Edition)

Back to overview

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).

image01

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.

image02

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.

image00

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.

image04

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!

About the author

Bart Veldhuizen

Community Lead at Sketchfab. 3D Scanning enthusiast and Blenderhead.



No Comments

    Related articles