Saturday 28 March 2015

Importing Assets and Batching In Unity

Ok now I have the models unwrapped, textured and all using the texture atlas. Time to get them into the game to see if it was all worth it!

Importing the Models


When importing models into unity there are a few things to watch out for; for us it was the automatic smoothing that is applied when you first import your model. As we are working in a poly art style the last thing we want are our polys getting smoothed out. We want the amount of light that hits each face to be calculated from the normal and used across the entire poly. To fix this switch the normal and tangent options to calculate. Then bring the smoothing angle down to zero. I also want all my models to share the same material so I unchecked the import materials box. This looks much better and brings out the shape of our models.



Importing the Texture Atlas

When bringing any texture into unity you should check its settings after import. Unity will automatically set it as a low resolution so you should set its max size back to be closest to the actual size of the image. This is why I chose to make the texture map 2048x 2048; the options listed for size are all powers of two so I can set the texture to render at its true resolution. When theses settings have been changed the texture should appear in game at its proper resolution.


Applying the Materials

The way I apply the atlas is to select a model which will be using it. Drag and drop the texture onto the components list and Unity will automatically create a material. Now for every other model you want to texture simply add the Texture Atlas material to the material section on the mesh renderer component. Now these models are all sharing the same material.

Batching


So far the batching is looking very promising, as this is still a developing game there are far more assets to be imported. The team has also just upgraded to unity 5 so I want to make sure that working out the % savings is still the same procedure as unity 4.6. For the moment we appear to be saving roughly half the draw calls we would otherwise make without batching. I will update with full figure once more assets have been placed in game.



No comments:

Post a Comment