Texture2D quality when fitting to a smaller UIRawImage
Hi
In my app I download PNG files from the internet and store them on the device. When needed I load them into the UIRawImage. Some of the images are used as thumbnails before they are scaled to the original resolution. I cannot anticipate the size of the thumbnail, so it's not generated before. When I try to fit a texture into much smaller UIRawImage, the effect is terrible. Please have a look at what I get vs what I would expect to get.
I understand, that it's a matter of some kind of filter, but I fail to find something which would help. I have tried changing the filter modes of the texture, but there's no difference in the quality.
I have checked the quality settings, I use the High level with anti aliasing set to 2x Multi Sampling, Texture Quality - full res.
I am certain this is doable, but I fail to find a way which would not affect performance etc.
Any tips will be appreciated.
Answer by Krstn · Nov 02, 2018 at 09:23 AM
After some research i have found that the mipmapping was not enabled on my dynamically created textures.
Creating them this way:
byte[] localFile = File.ReadAllBytes(filePath);
Texture2D tempTexture = new Texture2D(1, 1);
tempTexture.LoadImage(localFile);
texture = new Texture2D(tempTexture.width, tempTexture.height, TextureFormat.RGBA32, true, false);
texture.SetPixels(tempTexture.GetPixels(0,0,tempTexture.width, tempTexture.height));
texture.Apply(true);
tempTexture = null;
Solved my issue. The important part is the 3rd parameter to the Texture2D constructor.
Your answer
Follow this Question
Related Questions
How to crop an alpha UI image? 0 Answers
Texture is bad on device 0 Answers
How to change Texture in editor 0 Answers
Convert texture from Compressed to TrueColor in scripts. 1 Answer
Text to Texture2d / png 0 Answers