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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Two Mats One Tex

Discussion in 'General Graphics' started by Flailer, Sep 30, 2015.

  1. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Quick question about texture memory. As I'm not 100% sure about how unity manages textures in memory as regards to materials.

    If I have two materials, both using the same texture, will Unity try and load a second texture into memory identical to the first or is it smart enough to not do that? Or will for example this be resolved further down the line, for example will the graphics driver detect its duplicate? - I guess not for the later if its flagged as a new allocation.

    Just basically want to know if I have multiple materials referencing the same atlas whether or not I'm going to end up with amount of atlases x materials stored in memory or just one atlas being pointed at by many materials.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Unity will just reference the already loaded texture, there is no additional cost when reusing the texture.
     
    Flailer likes this.
  3. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Thank you, do you have a source for this information?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I tested it with the profiler, unity even shows how many references the texture has.
     
  5. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Hmm, this is profiler functionality I wasn't aware of. Usually just have the memory window which shows how many textures there are and memory. Mind taking a few moments to just run through what you did?
     
  6. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    Flailer likes this.
  7. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    That's it, thank you for your time. As always, so simple when you know how. :)