I’ve been wondering for some time now how to do this properly.
For example; lets say i have a city with lots of cars, people, animals, etc. By the way i’m talking about a 3D game here.
I understand the fact that one object should not have multiple textures if you want it to be only one drawcall.
And therefor you make a texture atlas with the different parts of; for example a car.
To my question:
Would it be better to combine multiple different cars on one atlas?
Even if there is a big chance not all of those will be seen at the same time.
If the answer is YES, where should you stop?
Should i combine as much as possible on as few atlases as possible?
Like: “Cats, Dogs, Jeeps, Blond Girls” on one atlas?
If this is the way to go, how big should the atlases ideally be?
Using texture atlases is done to reduce draw calls, which is a GPU and typically FPS optimization. However, when you atlas textures it requires a larger texture to be used, which eats up more memory.
The question you ask of how far you take the atlasing, really comes down to your game and your performance. If you are on mobile and GPU bound because you have 1k draw calls, atlasing those objects in the scene can be the difference between 5 and 60 FPS.
When you atlas textures, you typically atlas the ones that will be on the screen together, as this is where you get your GPU optimization. Putting multiple smaller textures into a single large texture, when they will never be on the screen to batch at the same time, means all you have done is create a larger texture memory footprint. Which is why it is also important to remember the difference in size between textures, such as a 1024 and 2048, where the size difference is actually 4x (2x in each dimension) and not the common misconception of 2x larger.
The texture atlas size can vary depending on scene construction and what you can even atlas together, but it is important to remember that most platforms have some texture limitations. For example, the iPhone 4 allows a max texture of 2048, so you may need to adjust for this on specific platforms.
It would also probably be a good idea to take a look at both dynamic and static batching, if that is something you have not done. It may be enough for you without having to worry about extra atlasing. There are also assets available on the asset store than can help you with this, with Mesh Baker being a personal favorite of mine.
All of this can sound like a real PITA, but trust me it works. I worked on a game that had a top down view of a city, in which the player could manipulate the camera and see the majority of the city at any one point and time. It was set up of individual assets by a designer and was nearly 10k draw calls. With proper atlasing and batching, we were able to drop that below 50 and enjoyed a smooth mobile launch.
Another tip, don’t try to reduce draw calls or worry about optimizations until you have to. There is a principle in programming where you don’t try to optimize prematurely. First, implement your solution as simply as you can, and if the performance is unacceptable, then work on optimizing by reducing draw calls, memory footprint, etc. Otherwise, you may spend many hours optimizing something that actually doesn’t have any negligible impact on performance either way.
In most android devices(if your target platform is android) you can’t use more than 2048 texture size.
so if you combine textures too much, that will reduce the quality.
(you can combine 4 1024x1024 textures in one 2048x2048 textures, but if you combine more, you have to use 4096x4096 texture to maintain quality)