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

Automatic Texture Atlaser

Discussion in 'Assets and Asset Store' started by AptasUnityUser03, Jan 16, 2015.

  1. AptasUnityUser03

    AptasUnityUser03

    Joined:
    Nov 14, 2014
    Posts:
    4
    Automatic Texture Atlaser


    Hi everyone,


    I've got an automated texture atlaser that I've been working on and I wanted to get some feedback on it before I release it on the Asset store.


    The idea of a texture atlas is to improve performance by having multiple objects in a scene use the same texture.

    Several texture files that were combined into a single texture file

    My tool takes all the textures in a selected group of game objects and atlases their textures together, updates the objects' UV values and then applies the newly created texture atlas to each object; all without changing any of their prefabs.

    Key features
    • It automatically generates texture atlases and appropriate UV values that can be used as they are or manually adjusted using the included scaling tools.

    • It automatically applies the newly created atlas material to the objects used to create it updating their UV values as appropriate.

    • It instantiates the objects included in the atlas before editing them in order to preserve any prefabs in the project.

    • It conveniently stores the newly created atlas material and both textures in a new folder named Atlases in the Assets folder.

    Important notes
    • It is strongly recommended that you have prefabs of all the objects you want to atlas so that you have the original object state stored in case you want to undo the atlasing process on it at a later date or add the object to another atlas. The object in the scene will have it's UV values permanently changed, altering the way other materials will be shown when applied to it.

    • The tool requires that the diffuse and normal texture of each object be proportional.
      • To be clear the textures in an individual material must have the same ratio but there is no requirement that different materials do so(i.e. a diffuse texture with a ⅓ ratio must have a normal texture with a ⅓ ratio). An error will be thrown if the textures on an object are unacceptable, any materials without a normal map will have a blank texture added and the package automatically scales the smaller texture to the same size as the larger texture.
    • The package currently will not work with tiled textures.
    Opening menu
    5.png
    After hitting Preview Atlas
    5a.png
    After hitting Apply Atlas
    6a.png
     
    Last edited: Jan 26, 2015
  2. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    anyway to combine certain objects as well so u dont have to rely strictly on static batching? I find i get better performance with things combined already as well as static batching those combined objects per location.

    Also is there a way to add additional objects/ textures to the atlas after the atlas was already created? Does it keep track of what textures are in the atlas so u dont duplicate already added textures?
     
  3. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    Oh and this would only be useful to me if it did all textures in the unity 5 pipeline standard shaders metallic workflow.. all the textrues with the corresponding alpha channels in them.
     
  4. b4c5p4c3

    b4c5p4c3

    Joined:
    Jan 4, 2013
    Posts:
    537
    When you copy the textures to the atlas you copy the full texture content or only the part used by the object???

    for example if object 1 uses just a tiny rectangle of a "texture atlas 1" and object 2 just a tiny rectangle of "texture atlas 2" the newly created texture atlas contains the full "texture atlas 1" + full "texture atlas 2" or just the 2 rectangles??
     
  5. AptasUnityUser03

    AptasUnityUser03

    Joined:
    Nov 14, 2014
    Posts:
    4
    Just to clarify are you asking about combining the meshes of the various objects added to the atlas? If so it does give the option to do so in my latest revision.

    In regards to adding objects to the atlas, as long as all the objects are still in the parent object you used the tool on you could hit the undo button, then add the new objects as children and then use the reimport button before applying the atlas again. If on the other hand you had removed the objects from the parent you would have to reimport each object from it's prefab and then run the atlasing process all over again.

    The tool does keep track of which textures are in the object and don't add duplicates to the atlas as long as the mainTexture and secondary texture pairs match (i.e. texture a with texture b bumpmap and texture a with texture b bumpmap will not include the second pair in the atlas but texture a with texture b bumpmap and texture a with texture c bumpmap would include both pairs in the atlas)
     
    Last edited: Jan 26, 2015
  6. AptasUnityUser03

    AptasUnityUser03

    Joined:
    Nov 14, 2014
    Posts:
    4
    At the moment the tool does work on textures with alpha channels in them if the shaders use the main texture for the alpha channel. I have tried it with the unity beta and it does work but under the current setup the newly created texture is a legacy shader which can then be changed to the new unity standard shader, but will need to have the new 5.0 settings reset afterwards. I plan to release an update shortly after 5.0 is officially released that will correct these issues.
     
    Last edited: Jan 26, 2015
  7. AptasUnityUser03

    AptasUnityUser03

    Joined:
    Nov 14, 2014
    Posts:
    4
    The tool does add the full texture to the atlas but it will update the UVs appropriately so that the object will only display the same portion of the input texture it did before.
     
  8. gchudeck

    gchudeck

    Joined:
    Jan 15, 2015
    Posts:
    2
    Have you released this/ I'm looking for something that will just create an atlas and update the uvs. I can combind the meshes myself.