Jump to content

Bug with the GameDatabase loading textures - no Filtering.


Recommended Posts

It seems that textures, at least PNG's that are loaded over the GameDatabase don't have any kind of filtering or mipmaping applied to them. From a distance they look like they are using point filtering. I noticed this when replacing the Mun space texture, the original texture loaded from the resource file works fine, but when I load the same texture as a through the GameDatabase, and swap out the Mun's .mainTexture on the Material - it has no filtering. Am I missing something or is this a bug/forgot to implement?

I've tried manually setting the anisoLevel, filterMode and mipMapBias on the (GameData-loaded) Texture object to the same values on the original, but it made no difference.

Link to comment
Share on other sites

Ok so I created a work around.


Color32[] aPixels = xTexture.GetPixels32();
string sName = xTexture.name;
int nWidth = xTexture.width;
int nHeight = xTexture.height;

Resources.UnloadAsset(xTexture);

Texture2D xNewTexture = new Texture2D(nWidth, nHeight, TextureFormat.ARGB32, true);
xNewTexture.name = sName;

xNewTexture.SetPixels32(aPixels);
xNewTexture.Apply(true, false);

xNewTexture.Compress(false);
xNewTexture.Apply(false, true);

xNewTexture.filterMode = FilterMode.Trilinear;
xNewTexture.anisoLevel = 9;
xNewTexture.mipMapBias = -0.5f;

GameDatabase.Instance.databaseTexture[i].texture = xNewTexture;

GC.Collect();
GC.WaitForPendingFinalizers();

It's important that these things happen in this order.

Edited by Tingle
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...