Page 2 of 2

Re: Using transparent images as TextureSource (Unity)

Posted: 21 Jan 2017, 18:24
by tomczak
* First, using Photoshop to perform the premultiplication => no success
What do you mean with "no success" ? Could you elaborate?
Sure : Some kind of "white creamy" veil on transparent areas (in both cases : PNG prepared in photoshop or premultiplied in an editor extension).

Re: Using transparent images as TextureSource (Unity)

Posted: 21 Jan 2017, 20:49
by jsantos
Only when activating compression in Unity or always?

Re: Using transparent images as TextureSource (Unity)

Posted: 02 Mar 2018, 06:06
by Regbalt
Stand today for the same problem: "Whats going on? Why are the image's alpha's wrong ?"
Found the script here and wrapped it in an "Context Menue Option".
So the textures, that need to be premultplyed, can be selected and converted in unity Asset Browser.

For everyone interested:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class PremultplyTextureContext : Editor {

    [MenuItem("Assets/PremultplyTexture")]
    public static void onpremultiplycontext()
    {
        foreach (Object obj in Selection.objects)
        { 
            Texture2D tex = obj as Texture2D;

            Debug.Log("Premultiplyed :" + tex.name);
            string path = AssetDatabase.GetAssetPath(tex);
            
            Texture2D texOut = TextureConverter.ConvertToPremultipliedAlpha(tex);

            byte[] data = texOut.EncodeToPNG();

            System.IO.File.WriteAllBytes(path, data);            
        }
        AssetDatabase.Refresh();
    }

    [MenuItem("Assets/PremultplyTexture",true)]
    public static bool checkpremultiplycontext()
    {
        bool returnValue = true;
        foreach (Object obj in Selection.objects)
        {
            if (!(obj is Texture2D)) returnValue = false;
        }

        return returnValue;
    }
}
And later found this: http://www.noesisengine.com/forums/view ... t=10#p6097
:cry: