Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Are high resolution textures optimized automatically?

Discussion in 'General Graphics' started by tomer20072, Sep 16, 2016.

  1. tomer20072

    tomer20072

    Joined:
    Dec 8, 2015
    Posts:
    57
    I'm a beginner in unity and i'm trying to learn my way around how it works, and I created a model that uses a 4k resolution texture that i need for when the player is real close to the object, but the thing is i need hundrads or maybe thousands of those objects in my scene, and I'm worried that without some kind of optimization it will really kill the performance, so i just wanted to ask, is there some mechanism that automatically optimizes high resolution textures as you get far away from them? or do i have to create low rez textures myself and create an lod group to make it work?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,936
    It's called mip mapping.

    You still have to worry about VRAM usage though.
     
    _GimbalLock_ and tomer20072 like this.
  3. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,620
    With a lot of these sorts of things, one of the best things you can do is test it yourself. Start scaling up what you're doing and see how it influences performance on your target system.

    I know that may seem like a lame answer, but it is often the most direct path to your answer and solution. And it gives you experience.

    Also, if you're thinking of having thousands of objects in your scene, as you start scaling up, look into LOD, occlusion culling, and additive scenes.
     
    tomer20072 and theANMATOR2b like this.
  4. tomer20072

    tomer20072

    Joined:
    Dec 8, 2015
    Posts:
    57
    Yes that's what i had planned on doing, to just see how it runs, i just haven't finished the texturing yet and i just wanted to know how i should set it up going into it, I am indeed planning on implementing occlusion culling in this scene as well.
    thank you both
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,209
    A hundred unique 4k x 4k textures with DXT1 compression is going to be ~533MB of ram, which with modern high end video cards is probably fine. Multiple hundreds of 4k textures is going to start pushing it, so if you're using Unity's standard shader with the usual albedo (DXT1 ~5.33MB), metallic/smoothness(DXT5 ~10.66MB), and normal map (DXTnm ~10.66MB), for 100 uniquely textured objects that's going to be >2.6GB of textures which isn't going to be fine unless you're running on the absolutely latest video cards. However if you have 100 objects all using the same set of 3 textures, that's just ~21MB of texture memory for those textures, regardless of if it's 1 object or 100000 objects, and that's totally fine (though 100000 objects in Unity might cause you other issues).

    So, in short, if there's a good bit of texture reuse, you'll probably be fine. If you're planning on hundreds of uniquely textured objects using 4k textures you are probably going to either have a lower resolution version that exists in the scene until you get close and only then load the full resolution object (and be aware doing so will either cause a hitch or require a small delay before you can show it). Alternatively you can look at something like Amplify Textures 2 which implements essentially infinite texture resolutions by dynamically streaming textures in and out for you.
     
    hopeful likes this.
  6. tomer20072

    tomer20072

    Joined:
    Dec 8, 2015
    Posts:
    57
    Thank you for explaining, that sounds great for me as i only have 8 unique textures for all those objects, i already playtested and the scene could still run with like twenty thosand of those objects, so it looks like it's gonna run just great.
    Thanks a lot for all of your help
     
    hopeful likes this.