Tag Archives: tutorial

04 Oct

Using Optimized Texture Atlas for Particle System in Unity!


The tutorial will be much more helpful if you already have a basic understanding of the Shuriken particle system / Native particle system of unity and is directed towards Intermediate unity users.

The particle effects in your game which adds a lot of polish can also increase the Draw calls resulting in spike or decrease in FPS. This usually occurs when you have multiple elements of same effects  visible in the gameplay camera.


As an example, I made a spark particle effect for this tutorial. The particle was created using 5 particle elements and when used, it costs 4 draw calls. Now If I duplicate it multiple  times and simulate it all together in the game camera, it will cost 14 draw calls as shown below. This can be a huge problem and can impact the performance of your game especially when you have a ton of effects later in the development.


In order to curb this issue, we can always optimize the particles to help make sure that it is as efficient as possible. There are many guidelines on optimizing the particles and we recently started using Atlas for our textures in effects. This is a standard technique used in the game industry however while researching on this subject, we never found a good tutorial or concise document explaining the method and hence we thought why not share our technique!

I have used 4 different textures to make the below effect. It consists of a glow effect, sparkle effect, radial effect and a variant of sparkle effect. For the sparks flying, I just used stretched billboard with the glow texture. There are 5 elements used in order to create the particle but 4 materials hence when simulating it, it takes 4 draw calls!


In order to use this technique, we need to create an atlas and for the same purpose, we can use any photo editing software. Since each of our textures are 128 x 128 resolution, we can compile all the 4 textures into 256×256 as shown below!


Once done with atlas we can go ahead and import it to unity and prepare the material. We will use Additive shader for this particular effect.

If you replace your particle effect with the atlas material, it will not look as intended. This is because you  need to point out the correct texture to each element of your particle system.


We can select the correct texture in the atlas by using the texture sheet animation tab.


The texture tab in default setting looks like above. we need to change it according to our needs. We have 2 rows in our textures with 2 frames each in X and Y coordinates. We need to input the required coordinates, change the animation tab to Single sheet and turn off Random row. Then besides the Frame Of Time graph, you will see a drop down menu. Select the Constant option from the list.


After making the above said changes,  the texture sheet should look like something as below.


There are two options now available to us, Rows and Frames Over Time. Below I will explain what each does!


Rows:This is the value which denotes which row you would like to select in your sheet. Every horizontal break in your texture sheet will be called as Row. They ascend from the top of the page to the bottom. rows

Frames over life a.k.a Frames: Frames are the respective image in your atlas. Since atlas is a compilation of all the textures, the frame number can be used to identify and select the desired texture from your sheet. Refer the image to understand how frame numbers are divided.


After understanding the rows and frame settings, now we can select the desired texture from the sheet. Let’s have a look at our atlas below. If we want to pick a glow texture, then we would need to add Row:1 and Frame: 1. Using this mapping technique we can now start optimizing our entire particle system by selecting each element and replacing it with the corresponding texture in the atlas.


I went ahead and optimized all of the elements in the particle effects with the atlas texture and now we can see that the draw call has reduced to 1! No matter how many duplicates or instances I make of the same particle, the draw call is always 1. SUPER OPTIMIZED!


Using the atlas can a very powerful method when using with particle effects in your game. It can help maintain an optimal draw call and boost its performance. Making use of this technique can be very useful especially for mobile games where draw calls are a bane and can drastically impact the fps of your game.

Hope the tutorial helped you in understanding how to use Texture Atlas for your particle effects and may nothing stop you from creating that epic effects for your awesome game! :)


If you have any queries or if you were confused at any point when following the above process, please do let us know via the comments or email.


30 Sep

Game Dev Tip: How to bake Lightmap in Unity 5 !



A long time ago, I had blasted in Facebook saying that we will share our findings of Light-map workflow in Unity 5. Along with learning that it is always better to not promise anything before it is done, here is a tutorial… Finally !

Unity 5 came out and they completely overhauled the Light-map system. Although an amazing update, it is kind of difficult at the moment to get the hang of it. The tutorials are difficult to find and the workflow seems as if it is kind of messy.

After working and testing on it for about 6-7 months we have kind of figured how to get a good result with the new Light-map system and that is why this tutorial has been forged!

What is Light-map!?

Light-map is nothing but a texture with lighting information baked directly from the scene to help reduce draw calls and increase performance of one’s game. It usually has shadow, Global Illumination and Ambient occlusion baked onto it to give an amazing depth to the environment without hindering the FPS. Real-time lightning is only set to moving or intractable objects which reflects dynamic shadows. This is a rather standard procedure in games pipeline and has been in use since a long time.

What you need?

In-order to follow this tutorial, we will get down to basics and use primitive objects to bake light-map as an example. Later, you can use the same technique to bake your awesome models in Unity. For now these are the stuff you will need

  • A 3D scene exported from any 3D software with a plane and a box.


  • The box should have two UV channels. Channel 1 for Diffuse and Channel 2 for Light-mapping. (UV 2 is not mandatory but it is always better to manual unwrap for better quality light-maps)


  • Unity 5

Once you have all the above stuff, lets move on to setting up a proper scene in Unity. We will export this in FBX. or Obj. or whatever format your 3D package supports and lets move on to Unity!

Setting up the scene!

  • Import the FBX or your exported 3D Obj into your Unity 5 scene. Use the following import setting to make sure that you get good quality Light-maps.
    Note: If you don’t have UV2 channel in your 3D object then you can turn on the GENERATE LIGHTMAP UVs in the import settings. This will automatically unwrap a UV2 channel for your 3D object.


  • Duplicate the boxes and intersect them together so that the contact shadows or Ambient occlusion will be visible


  • Mark your 3D objects as static . The object which are static will only be Light-mapped.


  • Select the directional light, mark it static as this will be the source which will produce the required lighting information which we need for our Light-map.
  • Change the Directional Light setting as shown below. Basically, you need to change the Baking from Real-time to Baked.


  • Go to your quality settings under Project setting and change it as shown in the image below. We do this because the default shadow setting are not that great and are blurry.


Once the scene is set and loaded, we can now move on to settings of the Light-map.

Tweaking the Light-map Settings!

To open up the Lighmap setting tab, you need to go to Windows > Lighting  > Scenes

To get more info about each property of the setting tab, please refer to this link. It is highly recommended that you sit down and read it thoroughly before moving on. Please dont skip the documentation or else you will pay for it. It is always better to have atleast a basic understanding of all the parameters before actually working with them!

Please refer the image below and change the settings as shown.


It is highly important that you select all objects you want to bake. Once all objects are selected, press BUILD to start the baking process !

Baking Lightmaps!

When the Build button is pressed a progress bar will appear on the bottom right corner of your Unity 5 window indicating that the Baking process has started!


Once it is done processing, you will be done with your light-map baking and should have an amazing looking  scene with the shadows all baked into the assets beautifully as shown below.



As you can see in the below image the difference between a scene which is baked with light-map looks way more cooler then the dull scene which is without any maps! The use of Light-mapping in your game can play a big part in bringing in that added polish and a very nice grounded feel to your environments.


Things to remember while baking!

  • The light-map resolution size is displayed in the light-map settings. Make sure to use proper size and not go overboard as it will hamper your performance of the game
  • 15If you want to clear the light-map, you can by do it by going into the Light-map settings, clicking the arrow besides the Build button > Clear Baked Data. It should delete your Light-maps and you will have to bake it again
  • 14If you want to change the Light-map resolution manually, you can do that by going into the Light-maps tab, clicking on the individual Light-map which will take you to the Light-map texture where you can change the texture compression or resolution manually.


That is pretty much it on how you can bake Light-maps in Unity 5. We hope you enjoyed the read and use this light-mapping technique in your pipeline. if you already haven’t been using it, go ahead and test it now! The procedure can really enhance the look and feel of your game and you should not ignore it if possible. If you dint understand anything which was explained here then don’t hesitate to let us know. The whole point of blabbering about this is to make sure you get it right!


Thanks for dropping by and for your support. We will be blogging about our visit to EGX, Birmingham where we showcased Asura! It was an amazing experience and we will share about it pretty soon.

Until then….. Take care, Be Epic and Forge beautiful stuff  :D



For any queries please contact zain@ogrehead.com or support @ogrehead.com| Get Presskit here: http://ogrehead.com/press