Home Technical Talk

Texture Atlases: How far is too far?

polycounter lvl 6
Offline / Send Message
ChaosWWW polycounter lvl 6
Hey, I'm starting work on a pack of generic art assets for the Unity Asset Store, and I'm having difficulty wrapping my mind around how to optimize this in a broad sense. I know that the conventional wisdom is that, whenever possible, multiple objects should share the same texture and material (and be batched together if possible). I.E if you have a bunch of pencils and pens in a jar, they should all share a texture atlas rather than having each object have it's own texture, even if these are independent (not merged) objects each with their own physics etc. I hope I at least understand that correctly.

However, I'm wondering how far this can be taken before it becomes impractical or un-optimal. I'm going to use the example of a car to illustrate the problem I'm facing.

Let's say I want 5 different types of cars in my pack. Let's take one of these cars and say that this is a fully interactive car with wheels, doors and the steering wheel as separate objects for animation/interaction. Would it be best to have all of these share the same texture and material, despite the fact that the wheels or the steering wheel are only using a small portion of the overall texture? I would assume the answer for this is yes judging from the conventional wisdom I cited before, although I've seen it done the other way in some games. As a follow up, would it be more optimal for an interactive car like this to be a basic skinned mesh or multiple parented objects?

Assuming texture atlasing is the most optimal thing to do most of the time, would it be a good idea for all 5 car variations in the pack to share the same texture? Aside from the benefits of being able to re-use certain things from other cars like seat and wheel textures, theoretically this would be more optimized. However, let's say someone using my pack only uses one car in his scene. Surely this is a waste of resources in this case. For this problem, assuming it is generally a good idea to texture atlas, I'm more asking for y'alls opinion on what I should do for a situation like this.

Just a theoretical question: if it was possible, would it be the most optimal rendering-wise to use one texture for an entire scene, assuming the scene had a variety of small and large objects and some of them could move? I know this is kind of the concept behind Megatextures, but more just wondering if atlasing as much as possible is always the most optimal thing to do and separate textures are only good for objects in completely separate scenes or for tiling textures.

Tell me if I'm way off base here, the technical side toward rendering a game has always been a bit confusing for me. Thanks!

Replies

  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    I'm confused as to what the problem is here, it sounds like you're over-complicating things for what is at most a 1% gain in performance in some cases you're pointing out. I think some pictures/examples of the stuff you're talking about would serve better as to how big the models/texture/shader is for this specific case.

    In the case of the cars, I'm not sure what all of them sharing the same maps and textures has got to do with animations *unless I didn't understand the question, correct me*, since animations are bone/morph related, not shader/material wise, unless you're using a material driven animation, (EI: blending) which sounds just weird for cars.
    As you said, you will just use an Atlas or Switch-Bool to change textures (this is assuming the cars can get damaged, but again, I'm not sure if this applies in your case).

    However, in terms of texture space, if all of them are the same car, you would want to most likely tint them procedurally via colors in the engine, or use a Mask texture to get the decal details differently, to avoid mutiple version of the same texture with just some variations that are static and only serve to bloat for space.
    You could keep a mask in your Alpha channel of say your Diffuse or something else, if you're not using too many textures and don't plan on using a unique Mask texture.

    IF however, the cars are radically different, and have unique details (a jeep isn't going to look like a ferrari) and are going to have unique AO, dirt, etc, then yes, you will need to have different textures for the chassis.
    HOWEVER, you will need to keep a small separate texture sheet for the unified stuff, like the wheels, steering, pedals, etc, since if the game is going to be online (and play with other people), and no one picks THAT car with THAT texture (the one that has the wheels and other small details) your engine will have loaded a (as example) 2K textures instead of say a 512px one for some small details, so at this point, you have an extra texture that isn't being used for double the size and space in your memory, not to mention triple memory if you're using a mask in your Alpha channel of this particular material.

    At the same time, I'm not sure if Atlas is what you need, Atlases are usually used for sprite animation, either for particles or 2D flat games, most of the time, for unique 3D pieces (outside of environments) you will either use Masks or some other solution reliant on the shader/material setup.

    If you could show/provide more information about the setup your have, Unity and what kind of material you're locked in, I'm sure someone with more Unity understand could help you.
  • ChaosWWW
    Options
    Offline / Send Message
    ChaosWWW polycounter lvl 6
    Thanks for the response, you basically answered my question (all unified elements of an object should share a texture but all unique elements should be their own separate texture). Unfortunately I don't really have any exact examples of what I'm talking about as I'm just planning for this project, don't have much to show for it yet.

    The reason I bring up the separated objects for animation is just because I was wondering if it would be optimal to split up textures based on the pieces, like if the wheel, steering wheel, doors and chassis should all have different textures or the same texture.

    To avoid confusion, what I mean by "atlases" are essentially multiple objects sharing the same texture.

    Thanks for the response, cleared a lot of things up.
  • Makkon
    Options
    Offline / Send Message
    Makkon polycounter
    If it's a separate object, it has to make another drawcall, doesn't matter if you're using a shared texture atlas. Making all those separate objects have the same huge texture is just making that drawcall more expensive. Texture atlases are only useful for static objects that can be combined into one object, such as a landscape or a modular asset set for a building, etc.

    So to answer your question, it's not wise to have all those cars on one sheet unless they're parked cars that will all be one object.
  • ChaosWWW
    Options
    Offline / Send Message
    ChaosWWW polycounter lvl 6
    Okay, one more question: for this car setup (with chassis, wheels, door and steering wheel being separate), would it be more optimal to have one skinned mesh with one texture, where each part would be controlled by bones, or would each piece being a separate static mesh with their own texture be more optimal?
  • Harbinger
    Options
    Offline / Send Message
    Harbinger polycounter lvl 8
    I don't think you'd see a performance impact regardless of the way you texture the car in your last question Chaos. When you're getting into these very specific performance questions, you always need to consider how the asset will be used in game. Just to play devil's advocate:

    If you had a game where you destroyed the car, and after a set time all of the "pieces" that flew off are culled and just the chassis is left behind as wreckage, it would make sense to have two textures, so that the one texture with all of the pieces could be streamed out.

    Obviously, this is a very specific scenario. You're making a generic asset. Put all of the car pieces into one texture sheet. Most likely the people buying this on the asset store don't have highly specific needs :)

    BTW, one thing to think about with cars is not how many textures you need, but how many materials. I usually split cars into two shaders, one for the opaque pieces and one just for the glass, even though they might reference the same texture. This helps eliminate sorting problems, with the added bonus that the opaque pieces won't be rendered as alpha based objects, so they'll cause less overdraw.
  • ChaosWWW
    Options
    Offline / Send Message
    ChaosWWW polycounter lvl 6
    Thanks for the helpful answers guys :) Think I know how I'm going to approach this now...
Sign In or Register to comment.