Fixed gray texture on export.

Fixed gray texture on export bug, it was caused by the texture scale function (during upscaling), right now it's required to have the texture dimensions be a power of 2 width/height.
Optional OBJ/PNG/sprite export options.
Chanaged readme.
TODO: Cleanup export code. Make proper scale options (bilinear & point).
This commit is contained in:
max
2019-07-16 14:12:32 +02:00
parent 09f7c488b9
commit 7f17793af0
5 changed files with 185 additions and 20 deletions

View File

@ -155,6 +155,30 @@ namespace MA_Texture
return texture;
}
public static Texture2D MA_Scale32D(this Texture2D texture, int width, int height)
{
float ratioWidth = (float)width / texture.width;
float ratioHeight = (float)height / texture.height;
Texture2D newTexture = new Texture2D(width, height);
for (int x = 0; x < width; x++)
{
int posX = Mathf.FloorToInt(x / ratioWidth);
for (int y = 0; y < height; y++)
{
int posY = Mathf.FloorToInt(y / ratioHeight);
Color pixel = texture.GetPixel(posX, posY);
newTexture.SetPixel(x, y, new Color(pixel.r, pixel.g, pixel.b, pixel.a));
}
}
newTexture.name = texture.name;
newTexture.Apply();
return newTexture;
}
#endregion
#region combine