Looking to make textures for Unity3d, and I'm stuck at what seems to be a simple stage. My goal is to create an RGBA image, with color information for every pixel, and a separate alpha channel. These two components get fed into Unity as base color and reflection strength, respectively. (Using "Reflective/Bumped Diffuse" material.)

If I use masking tools in Photoshop, I can erase parts of the output image (transparency). However, I would like to keep the original RBG color information when output, and not just have "blank" areas. Also, it would be nice if I could do it non-destructively, ie. the final alpha channel is dependent on a standard layer, or built from a path object, etc.

I have the same problem with The Gimp.

Any help on this would be greatly appreciated.

(If Photoshop/Gimp are not the tools for the job, can someone please recommend a better one?)


5 Answers 5


Photoshop Solution

Deleting a section of the image is only affecting that layer. What you want to do is create a separate channel which stores your Alpha information.

  1. In the Tool Panel with Layers/Channels/Paths, choose the Channels Tab. Here you will see RGB, Red, Green, and Blue.
  2. Create a new channel using the button at the bottom of the panel, this is your Alpha Channel. This is an 8-bit greyscale channel giving you 256 levels of transparency.
  3. You can use the little "eye" icons to toggle this channel on/off.
  4. Draw or copy/paste your information into the channel.

Note: When saving you need to be careful about file formats. Things like .Tiff & .TGA save the full alpha channel independent of color information. However Photoshop doesn't allow this with PNG, much to many developers annoyance. It will not properly save Alpha Channel images and tends to strip out color information for fully transparent areas to compress file size.

  • \$\begingroup\$ This was exactly what my problem was. I was outputting to PNG and not seeing any of the "alpha" channel goodness. Thanks, this is perfect. Does anyone have instructions for using the Gimp similarly? \$\endgroup\$
    – eli
    Aug 3, 2010 at 19:01
  • 1
    \$\begingroup\$ It's frustrating because back around version 5.0 or 5.5 Photoshop would actually save the full channel on PNGs. Adobe changed the way they handled them for subsequent versions of the software. Sigh... \$\endgroup\$
    – wkerslake
    Aug 3, 2010 at 19:28

I find the best way to do this in The GIMP is to use a layer mask (right click on a layer and create mask).

The layer will then have two "images" associated with it - the RGBA image and a grayscale layer mask which acts as an extra (multiplicative) alpha channel. You can click either of these images to select which one will be edited.

If you hold CTRL and click the layer mask, you will see just the RGBA image (this disables the mask). If you hold down ALT and click the layer mask, you will see just the layer mask.

When you export an image with an active layer mask, the exported image will retain the colour information even from areas that the mask makes fully transparent.

For your purposes, you may find it effective to compose your alpha channel on a separate (RGBA) layer - then when you are done you can just copy this layer into the layer mask of the original layer.

  • \$\begingroup\$ This is closer to what I need. But it only affects the top layer! I have multiple layers in my image, and I would like to be able to do this without flattening it. Thanks for answering. \$\endgroup\$
    – eli
    Aug 3, 2010 at 7:58
  • \$\begingroup\$ Add a mask layer to each layer of your image. \$\endgroup\$
    – deft_code
    Aug 3, 2010 at 20:02

In the GIMP, one way would be to split the image into layers for each channel. Select "Colors->Components->Decompose" and choose RGBA or whatever channels you want to break into layers. Then edit your individual alpha and color channels as you see fit (they should be greyscale), then go "Colors->Components->Compose" choose your desired channel layout and choose your layers to use for each channel.

Also, you can use the "Channels" dialogue. It should be a part of the default toolbox things, but if not you can select "Windows->Dockable Dialogues->Channels". You can toggle visibility of each color channel, and by clicking and highlighting the channel names you can choose which ones to edit individually (it looks like it preserves color with alpha, although I don't see a way to "hide" the alpha while editing without hiding the entire image...).

  • \$\begingroup\$ it looks like I have to flatten the image first, then decompose, then edit, and then recompose. Thanks for the tip! But I'm looking for a non-destructive way. \$\endgroup\$
    – eli
    Aug 3, 2010 at 7:11
  • \$\begingroup\$ Ahh, I assumed you were working with a single layer image so flattening wouldn't be necessary, but nevermind then. Good luck! \$\endgroup\$ Aug 3, 2010 at 7:42

To write your own content processor (as suggested by @Andrew Russell) specific to Unity3D, place this script in your Assets/Editor folder will combine any image *-Base.* with a similarly-named *-Alpha.* file and modify the original texture:

class AlphaCombinerPostprocessor extends AssetPostprocessor {
    function OnPostprocessTexture(texture : Texture2D)
        if (assetPath.Contains("-Base.")) {
            var fn = assetPath.Replace("-Base.","-Alpha.");
            var alpha = AssetDatabase.LoadAssetAtPath(fn,Texture2D);
            if (alpha) {
                Debug.Log("Adding alpha from "+fn);
                var c : Color[] = texture.GetPixels();
                var a : Color[] = alpha.GetPixels();
                if (c.Length != a.Length) {
                    Debug.LogError(fn+" is different size to "+assetPath);
                for (var i=0; i<c.Length; i++)
                    c[i].a = a[i].a;

Adapt to your own asset file naming conventions.


One alternative is to write your own content processor to perform the operation you want. That way you could simply give your "reflectivity" layer (or even multiple reflectivity layers) a special name, and have the content processor put that data in the alpha channel for you. (Or indeed implement any kind of process that you like.)

If you were using XNA and The GIMP (this is what I use and am familiar with), then it would be very easy for you to add this XCF importer to your content pipeline and make the necessary modifications to process specially named layers.

As you are using Unity, not XNA, I am not familiar with what content pipeline options you have available. But perhaps you can adapt the linked code so that it works within your content process.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .