x


WWW texture quality

Hello everyone,

I am making an isometric game with sprites. I decided to make the textures be loaded from the HDD at startup, so people can make their own textures, and it makes it easier to see of new textures are good looking.

I already implemented the possibility to load textures from the HDD, but whenever I load a texture, it is heavily compressed and looks really ugly, cropped, and streched out when using it in a GUI.DrawTexture.

So my question is, how can I change the texturetype when loading a texture from a WWW call? (GUI texture format, point filter mode, 4096 max size and truecolor format to be precise)

Thanks in advance.

more ▼

asked Apr 11 '12 at 01:38 PM

citiral gravatar image

citiral
3 2 2 4

When you create the 2D texture into which you wish to download the texture, what parameters did you give it?

For instance: new Texture2D(4096, 4096, TextureFormat.DXT1, false); ???

What file type for the textures are you using?

Apr 11 '12 at 02:07 PM GuyTidhar

I just initialized an array: var texturearr : Texture2D[];

and loaded the textures in like this:

var www : WWW = new WWW ("file://" + Application.dataPath + "/isometric UV2.png");
yield www;
texturearr[0] = www.texture;
www = new WWW ("file://" + Application.dataPath + "/isometric UV2blocked.png");
yield www;
texturearr[1] = www.texture;
Apr 11 '12 at 02:19 PM citiral
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Please use this: http://unity3d.com/support/documentation/ScriptReference/WWW.LoadImageIntoTexture.html

For instance. in your case you could do:

var textures : Texture2D[];
var textureNames : String[] = [ "/isometric UV2.png", "/isometric UV2blocked.png" ];

function Start()
{
    StartCoroutine(DownloadTextures());
}

function DownloadTextures()
{
   textures = new Texture2D[textureNames.Length];

   for(var t=0; t<textureNames.Length; t++)
   {
       textures[t] = new Texture2D(4096, 4096, TextureFormat.DXT1, false);

       // Start a download of the given URL
       var www = new WWW("file://" + Application.dataPath + textureNames[t]);

       // wait until the download is done
       yield www;

       // assign the downloaded image to the main texture of the object
       www.LoadImageIntoTexture(textures[t]);
   }
}

Now you can just add texture string names for each texture you wish.

more ▼

answered Apr 11 '12 at 02:20 PM

GuyTidhar gravatar image

GuyTidhar
2.2k 4 8 13

That still made it be strechted, but I got it to work by just adding

texturearr[0].anisoLevel = 0;
texturearr[0].filterMode = FilterMode.Point;

I can't believe it was that simple. Thanks, I woudln't have found it if you didn't suggest:

  textures[t] = new Texture2D(4096, 4096, TextureFormat.DXT1, false);

I am forever grateful!

Apr 11 '12 at 02:47 PM citiral

You are very welcome mate :)

Apr 11 '12 at 04:42 PM GuyTidhar
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3668
x2188
x524
x128
x58

asked: Apr 11 '12 at 01:38 PM

Seen: 715 times

Last Updated: Apr 11 '12 at 04:42 PM