- Home /
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.
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?
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;
Answer by GuyTidhar · Apr 11, 2012 at 02:20 PM
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.
That still made it be strechted, but I got it to work by just adding
texturearr[0].anisoLevel = 0;
texturearr[0].filter$$anonymous$$ode = Filter$$anonymous$$ode.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!
Answer by networm · Apr 04, 2020 at 02:17 AM
If Texture2D enabled mipChain then the resolution of texture would be affected by QualitySettings.masterTextureLimit.
The key is that WWW.texture enabled mipChain when construct Texture2D. So you need to construct a Texture2D which disabled mipChain manually and use WWW.LoadImageIntoTexture to load texture.
Your answer
Follow this Question
Related Questions
www.texture textureType to GUI 0 Answers
How to improve the texture quality in Unity ? 1 Answer
Texture quality and quality settings 1 Answer
Load an image from www and save it for offline use 0 Answers