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

TextureAtlas help

Discussion in 'General Graphics' started by saswilson, Jan 20, 2016.

  1. saswilson

    saswilson

    Joined:
    Jun 6, 2013
    Posts:
    44
    Hi,
    If I have a cube and a sphere would it be possible to use 1 material that uses a texture atlas? So I can make the textures for both the cube and the sphere, pack them into 1 texture and then fit/align the uvs for the gameobjects?
     
  2. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Yes, it's possible to do that in a couple of ways.

    1. You can simply create two different materials with the same texture and use tiling and offset to map the correct part of the Atlas onto your object. However, doing it this way defeats the purpose of having one texture atlas.

    2. In a 3D modeling application, UV map a cube and a sphere to use a certain part of the atlas as its texture. Export and use those objects instead of Unity's sphere and cube.
     
  3. AkiraWong89

    AkiraWong89

    Joined:
    Oct 30, 2015
    Posts:
    662
    Sure. You can have as much as object UV in 1 texture as atlas.
    Careful that more objects inside 1 UV means less quality on texture.
    But it greatly increase performance especially for mobile.
     
  4. saswilson

    saswilson

    Joined:
    Jun 6, 2013
    Posts:
    44
    Thanks for the help. So if I have multiple objects made using MAX, say a rock, tree etc, each one UV'ed and saved separately, how do I then make a texture that would combine all of the models UVs when they are all separate objects?
     
  5. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
  6. AkiraWong89

    AkiraWong89

    Joined:
    Oct 30, 2015
    Posts:
    662
    There are 2 methods:
    Method 1:
    Plan well before unwrapping UV. Decide which objects should goes into this atlas and that atlas then select all specific objects and unwrap together. (So that you can see all selected objects' UV at the same time.) For example you have 4 objects. You can separate the UV space (Open the UV grid line.) into 4 quarter and put the specific objects UV inside and finally form a 4 objects UV texture atlas.

    Method 2: Let's say you already have each texture UV per objects for PC / console games and now you want to combine these individual textures / objects to form a texture atlas for mobile. Texture atlas generator plugin for 3dsMax and Ninja UV Tool for Maya should help or you adjust manually. (Scale UV down 50% / 25% / Offset 0.5 / 0.25 etc... Time consume.) I believe there should be some Unity plugins which can do a great job too but I'm not sure about this.

    Additional: This script should help out something.
    http://docs.unity3d.com/ScriptReference/Texture2D.PackTextures.html
     
    artaka likes this.
  7. saswilson

    saswilson

    Joined:
    Jun 6, 2013
    Posts:
    44
    Ok thanks for the help!