What is the actual performance cost, if any, of using a large texture atlas with one material for multiple objects vs. using one small texture + one material per object?
Assume the total number of pixels of texture is the same either way. Also assume a fairly low-end system like a mac mini / GMA950 where optimization matters.
I haven’t found a way to quantify this myself, but I suspect the difference is negligible.
If the draw calls are the same (you aren’t combining the objects) - I would assume there is extra code involved in the atlas. At least you would always be referencing a much larger texture, where as in the other example, (individual objects) your GPU wouldn’t always be using the full size of the texture atlas, since some objects wouldn’t be on screen. They’d be kept in RAM, but not always used in VRAM, I think.
Why would you apply a texture atlas to separate objects in the first place.
Granted, if you are combining objects to cut draw calls, the benefits can be huge, depending on shaders, scene complexity, etc.
The atlasing thing is just something that I’d been told when I started doing 3D work, but the more I’ve learned the more it started seeming questionable.
I must have missed the part where it’s atlasing + combining meshes that makes the difference.
And the atlasing + combining meshes makes a HUGE difference.
Imagine a room with 100 small objects that are static in the scene (but perhaps dynamic at load time, for some reason).
By combining them AND using 1 material for all of them, you’ve cut 100 draw calls (per shader pass) Use a fancy shader and you can cut many hundred.
“”"
Imagine a room with 100 small objects that are static in the scene (but perhaps dynamic at load time, for some reason).
“”"
I have a question about that too: if the objects are spread throughout a fairly large zone such that they can’t all be seen at once - like houses in a village, there must be a cost for keeping all of the geometry for the combined mesh available to the GPU, right? Or can they do some fancy thing where they drops just parts of a mesh based on what’s on screen?
Or is the cost even that bad if it’s a reasonable number of polys?
Yeah, that’s right.
There will be a triangle or vertex limit for the GPU. So by combining them, you force it to always render all of them.
So you have to make a judgement call.
It you have 100 objects and at any time a random set of 20-30 will be on screen, you might want to combine them all. You might have groups of 10 which are in the same area, so maybe its better to have 10 groups of 10.
If however, something like a random set of 5 will be on screen at any time, it probably makes sense to leave them all separate.
There isn’t a perfect equation to tell you what to do, you’ll just have to test
it out.
As an aside, which I’m sure you already know, typically, you’d want to be aware of solutions to potential problems, but only implement once your game is settled. Otherwise the solution you choose now might not make sense in a month.