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

Texture Atlassing

Discussion in 'Scripting' started by bartje86tralala, Feb 1, 2013.

  1. bartje86tralala

    bartje86tralala

    Joined:
    Aug 1, 2012
    Posts:
    7
    Hi, im trying to merge textures in an atlass to bring the number of draw calls back. This works fine. However, for a big scene if i bring the max allowed atlass size above 512 it runs out of memory.

    I am certain their is by far enough memory available on the video card so that is not the problem. However, to make the textures atlas they need to have the Read/Write flag set which forces them to be stored in host memory. Is there a way to get rid of unused textures in between the creation of the texture atlas or to suppress unused memory all together. I am using Javascript, switching to C# so that i can use the garbage collector is no option for now.

    What i have tried is the following.

    - Resources.UnloadUnusedAssets() => (this wont work since i have to yield on it so i lose my calling order which is quite important).
    - Collect all meshes that will result in the same atlas as they are built up from the same group of materials. Then create an atlas for only the selected groups. Still goes out of memory.
    - Destroy( unusedTexture ) => wont work get unity error: invalid bbla risking data loss..
    - Texture.Apply( ) so that it becomes unreadable afterwards meaning that it is released from host memory according to docs..

    Note, i have taken into account that mipmapping is applied to the texture atlasses and that if it contains alpha, DXT5 is used or if uncompressed RGBA textures are supplied the atlass will not DXT compress. I am certain there is enough device memory available.

    Regards, bk
     
  2. Gibbonator

    Gibbonator

    Joined:
    Jul 27, 2012
    Posts:
    204
    Are you atlasing the textures on startup? If you can write a tool to do the atlasing in the editor then it should be possible to avoid having the Read/Write flag set at runtime.
     
  3. bartje86tralala

    bartje86tralala

    Joined:
    Aug 1, 2012
    Posts:
    7
    Yes i am atlassing on startup. Run script in editor mode will that work? Without having to set the Read/Write flag?