{"id":142059974921,"date":"2017-01-04T10:00:57","date_gmt":"2017-01-04T09:00:57","guid":{"rendered":"http:\/\/blog.sketchfab.com\/?p=142059974921"},"modified":"2019-08-15T18:05:39","modified_gmt":"2019-08-15T16:05:39","slug":"baking-particles-sketchfab-blender-edition","status":"publish","type":"post","link":"https:\/\/sketchfab.com\/blogs\/community\/baking-particles-sketchfab-blender-edition\/","title":{"rendered":"Baking Particles for Sketchfab (Blender Edition)"},"content":{"rendered":"<p>Hi there everyone! My name is Simon Kratz and in this tutorial I&#8217;m going to explain my workflow of baking particle effects for use in models uploaded to Sketchfab.\u00a0You can also find the <a href=\"https:\/\/blog.sketchfab.com\/baking-particles-sketchfab-maya-edition\/\">Maya<\/a>\u00a0and <a href=\"https:\/\/blog.sketchfab.com\/baking-particles-sketchfab-max-edition\/\">3ds Max<\/a>\u00a0edition on the Sketchfab blog, in case you missed it :)<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/www.klonk-games.com\/\" target=\"_blank\" rel=\"nofollow\">At our game studio<\/a> I&#8217;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.<\/p>\n<p>In this tutorial I&#8217;m gonna cover a workflow you can use directly with Blender, I&#8217;ll derive other software specific tutorials later on. I&#8217;m sure some of you will also be able to translate the workflow into different programs by themselves :)<\/p>\n<p>Let&#8217;s get started!<\/p>\n<div class=\"sketchfab-embed-wrapper\">    <iframe title=\"Polygon Motion\" class=\"\" width=\"690\" height=\"388\" src=\"https:\/\/sketchfab.com\/models\/e49fc301e69d4e67b24d12faa94aec18\/embed\" frameborder=\"0\" allow=\"autoplay; fullscreen; xr-spatial-tracking\" allowfullscreen=\"\" mozallowfullscreen=\"true\" webkitallowfullscreen=\"true\" xr-spatial-tracking=\"true\" execution-while-out-of-viewport=\"true\" execution-while-not-rendered=\"true\" web-share=\"true\"><\/iframe><\/div>\n<h3>General approach<\/h3>\n<p>I will use Blender here with it\u2019s 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 <a href=\"https:\/\/help.sketchfab.com\/hc\/en-us\/articles\/203058018-Animations\">Sketchfab\u2019s feature support<\/a> to get an idea of what can be exported.<\/p>\n<p>As an example:<\/p>\n<ul>\n<li>You want each of your particles to be attracted to a single point inside your scene?<br \/>\nNice! That&#8217;s basically just a position animation, go ahead and do it!<\/li>\n<li>You want your particles to change color over lifetime?<br \/>\nThis is a common particle system feature. But I&#8217;m afraid there is currently no way to this in an fbx file (or any other file format I know of).<\/li>\n<\/ul>\n<h3>Creating your particle effect<\/h3>\n<p>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).<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974922 lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image01-3-1030x438.png\" alt=\"image01\" width=\"690\" height=\"293\" \/><noscript><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974922 lazyload\" src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image01-3-1030x438.png\" alt=\"image01\" width=\"690\" height=\"293\" srcset=\"https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image01-3-1030x438.png 1030w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image01-3-300x127.png 300w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image01-3-768x326.png 768w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image01-3-1177x500.png 1177w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image01-3.png 1386w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/noscript><\/p>\n<p>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&#8217;re going for and it needs some experience to get a grip of everything. But don&#8217;t let this discourage you if you&#8217;re just starting :)<\/p>\n<p>You should already be seeing some motion now if you hit the play button. Most particle systems are also directly linked to your software&#8217;s physics simulation system. So if you want to incorporate your particles into a larger physics based animation that&#8217;s no problem at all.<\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974923 lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image02-3-1030x533.png\" alt=\"image02\" width=\"690\" height=\"357\" \/><noscript><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974923 lazyload\" src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image02-3-1030x533.png\" alt=\"image02\" width=\"690\" height=\"357\" srcset=\"https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image02-3-1030x533.png 1030w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image02-3-300x155.png 300w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image02-3-768x398.png 768w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image02-3-965x500.png 965w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image02-3.png 1062w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/noscript><\/p>\n<h3>Preparing your effect for baking<\/h3>\n<p>Once you&#8217;re satisfied with your effect we can start baking it! Sadly Blender doesn&#8217;t have a baking solution included that keeps the animation so we&#8217;ll have to help ourselves with some preparation.<\/p>\n<p>First, we won&#8217;t export plain dots as particles. We need to define an object that we&#8217;ll use as a particle mesh. If you haven&#8217;t already done so, set the rendering of your particle system to &#8220;Object&#8221; 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.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974924 lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image00-3-1030x365.png\" alt=\"image00\" width=\"690\" height=\"245\" \/><noscript><img decoding=\"async\" class=\"aligncenter size-large wp-image-142059974924 lazyload\" src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image00-3-1030x365.png\" alt=\"image00\" width=\"690\" height=\"245\" srcset=\"https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image00-3-1030x365.png 1030w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image00-3-300x106.png 300w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image00-3-768x272.png 768w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image00-3-1413x500.png 1413w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image00-3.png 1622w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/noscript><\/p>\n<p>You can still transform your object or tweak the animation to your liking.<\/p>\n<h3>Baking your particles<\/h3>\n<p>Once everything is perfect we&#8217;ll need some help from Python ;) Even though Blender itself can&#8217;t bake the particles the logic to do so is scriptable. We&#8217;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 <a href=\"http:\/\/blender.stackexchange.com\/questions\/4956\/convert-particle-system-to-animated-meshes?answertab=active#tab-top\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">here<\/a>. You can just copy paste this into Blender&#8217;s text editor.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-142059974925 lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image04-2.png\" alt=\"image04\" width=\"942\" height=\"323\" \/><noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-142059974925 lazyload\" src=\"http:\/\/blog.sketchfab.com\/wp-content\/uploads\/2016\/12\/image04-2.png\" alt=\"image04\" width=\"942\" height=\"323\" srcset=\"https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image04-2.png 942w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image04-2-300x103.png 300w, https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image04-2-768x263.png 768w\" sizes=\"(max-width: 942px) 100vw, 942px\" \/><\/noscript><\/p>\n<p>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.<br \/>\nKeep in mind we\u2019re 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.<br \/>\nMaybe it\u2019s 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. :)<\/p>\n<p>Finally you&#8217;ll have to select two objects: first your reference object (in most cases the one you set as particle mesh earlier), and then\u00a0your particle system. With both of them selected hit the &#8220;Run Script&#8221; button in Blender&#8217;s text editor and let the magic happen! It might take a while, depending on your number of particles.<\/p>\n<h2>Aaaaand it&#8217;s done!<\/h2>\n<p>You should now see many new objects in your hierarchy, one for each of your particles. Now all that&#8217;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.<\/p>\n<p>That&#8217;s it for this lesson in particle fx for Sketchfab. I&#8217;ll try to add more specific workflows for other software later on. But I don&#8217;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&#8217;ll mention you and your solution in the next tutorial. Or maybe you&#8217;d like to write a tut about your idea yourself? :)<\/p>\n<p>Now go ahead and create some amazing particle effects!<\/p>\n<div class=\"sketchfab-embed-wrapper\">    <iframe title=\"Crystal Valley\" class=\"\" width=\"690\" height=\"388\" src=\"https:\/\/sketchfab.com\/models\/732fc5f70415493ca64a71f783c2aa50\/embed\" frameborder=\"0\" allow=\"autoplay; fullscreen; xr-spatial-tracking\" allowfullscreen=\"\" mozallowfullscreen=\"true\" webkitallowfullscreen=\"true\" xr-spatial-tracking=\"true\" execution-while-out-of-viewport=\"true\" execution-while-not-rendered=\"true\" web-share=\"true\"><\/iframe><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to &#8216;bake&#8217; particle systems into animated geometry with this tutorial by Simon Kratz.<\/p>\n","protected":false},"author":2,"featured_media":142059974926,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[582],"tags":[739,994,992],"class_list":["post-142059974921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial","tag-special-effects","tag-tutorial-modeling","tag-tutorial-procedural"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/sketchfab.com\/blogs\/community\/wp-content\/uploads\/2016\/12\/image03-3.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/posts\/142059974921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/comments?post=142059974921"}],"version-history":[{"count":6,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/posts\/142059974921\/revisions"}],"predecessor-version":[{"id":142059990582,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/posts\/142059974921\/revisions\/142059990582"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/media\/142059974926"}],"wp:attachment":[{"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/media?parent=142059974921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/categories?post=142059974921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sketchfab.com\/blogs\/community\/wp-json\/wp\/v2\/tags?post=142059974921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}