Search Unity

Does Unity have issues with using many textures?

Discussion in 'Scripting' started by Disastercake, Sep 16, 2012.

  1. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    I plan to have a separate texture for each piece of equipment in my game. I am choosing to do this because it will be easier to both edit the textures to make many variations, and because I think it would cost less in memory usage instead of loading whole outfits if only one piece of that outfit is being used.

    Does anyone feel this may be a bad idea?
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    That really depends. Different materials mean things can't be batched. So it sort of depends on how many you are talking about, how big the textures are, how many are going to be displayed at the same time, etc. If you're talking 20 weapons, then it's probably no big deal. If you're talking 1000 different weapons, all displayed at the same time, and 2048x2048 textures, then it would be a complete disaster.
     
  3. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Ideally you should set it up so you share textures as much as possible. If you check out some of the examples from modelling sites like 3DRT you will see 30+ models in a "pack" sharing the same texture. That might be a little extreme, but ideally you should be able to get at least each outfit piece sharing a texture.

    If the issue is about draw calls or texture/buffer you can also dynamically pack textures. On level load grab each texture, combine it, and update the UV co-oridnates of the mesh. I have posted a simple example of this on the forums before (will find link for you).

    EDIT: The link - Combine Textures and meshes

    EDIT: There's also that example of the guy making great UDK scenes with only a 256x512 texture ... http://vimeo.com/35470093 ... http://www.unrealengine.com/showcase/udk/amazing_one_texture_environment/
     
    Last edited: Sep 16, 2012
  4. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    I would imagine no more than 20 characters at a time would be displayed. However, each character is comprised of 9-12 textures for an outfit, and 1-3 textures for weaponry. Would Unity start to take a noticeable hit in the different between using whole outfit textures versus separate per piece of clothing?
    I'm mostly concerned with how much the bar will be raised for minimum requirements so I'm not cutting more and more of the audience out for technical spec reasons.

    Each part of the outfit is a separate mesh though, so will it still batch even if they share materials?

    I think the issue with dynamically packing them would quickly become the size in memory it takes up (since each character with a slightly new texture would take a large new chunk). Thank you for the links, they were definitely interesting.

    Also, I think those sites usually have packs that have 30 models that share the same model and UVs, but still different textures. Things like, say, a goblin army with different skin tone: each skin tone has it's own texture. It's just editing the original texture for each one. Maybe the weapons are all on one texture though?

    On a side note: I'm getting upwards to 4000-5000 draw calls in a very populated scene. Is this a bad stat?
     
    Last edited: Sep 16, 2012
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    Yes, it's a noticeable hit. However, whether or not that matters is dependent on your game. It's faster to have one texture than it is 12 textures. But then again, if you're low on texture memory, it could be better to have 3 small texture rather than one large one that is only being partially used. for characters, you can pretty much forget about batching separate characters together (I think the limit for dynamic batching is somewhere around 300 vertexes or something). Pretty much the only thing you should be looking at for your characters is combining textures for the outfits (and possibly weapons). But to get the full benefit, you also have to combine the meshes, not just the textures

    That's a high number. But with the numbers you give above, the characters can't even be accounting for 10% of that. The best place to start looking when your draw calls are so high is your terrain - increasing the pixel error, setting the billboard start distance closer, the max mesh trees lower, lowering the detail distance and detail density, etc.

    Still, that number may not be too high - draw call counts are a generally a good thing to look at reducing, but each draw call can vary in speed, so it's not the end-all. You just need to benchmark on your low level system. Realize also that you can dynamically lower a lot of things on your low-end target machine as well, so you still have some leeway. I recommend making your game run on a "middle of the road" machine, and then lowering settings for low end boxes, and adding eye candy you can turn on for high end boxes.
     
  6. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    Both these things are basically what I was searching to hear, thank you, Jaimi. Because my character's outfits are customizable it would cut a planned feature from my game. These are separate meshes for a good reason: hiding meshes that aren't in use. From what I can tell there's really no huge benefit to combining these textures unless I cut the customization feature out, or simplify it and drop it down to customize whole outfits. Without testing for my minimum specs, it's hard for me to consider changing this feature at this point.

    I think it might be partially because the weather system I'm using requires there to be a huge camera distance. I'll have to add occlusion to the map to get a better idea, and maybe try to figure out how to set view distance of objects manually, since the weather system is just trying to see the clouds surrounding the map (I think).

    Edit: I added occlusion, and it immediately dropped from 5000 to below 2000 without negatively affecting the weather system.

    Edit: Also it seems that dynamic shadows on 60-80 characters at once is causing thousands of draw calls.

    This is good advice. I will have to get my hands on a machine I feel is an average PC for my target market.

    Thanks for all the good advice, everyone.
     
    Last edited: Sep 17, 2012
  7. timsk

    timsk

    Joined:
    May 27, 2011
    Posts:
    177
    I've had other Unity devs say similar things to me. A really simple solution to this is to setup a a camera that renders only the weather system effects (skyboxes, particle effects etc). It's only a case of creating a camera at the same position as your current one and setting up layers and culling masks correctly.