tomczak
Posts: 30
Joined: 26 Mar 2014, 10:25

Re: Using transparent images as TextureSource (Unity)

21 Jan 2017, 18:24

* 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).
 
User avatar
jsantos
Site Admin
Posts: 3805
Joined: 20 Jan 2012, 17:18
Contact:

Re: Using transparent images as TextureSource (Unity)

21 Jan 2017, 20:49

Only when activating compression in Unity or always?
 
User avatar
Regbalt
Posts: 11
Joined: 21 Feb 2018, 16:13

Re: Using transparent images as TextureSource (Unity)

02 Mar 2018, 06:06

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:

Who is online

Users browsing this forum: No registered users and 5 guests