Search code examples
alphagimp

GIMP packing image into alpha (pasting grey scale image into alpha)


Trying to do an optimizing trick called channel packing

My image doesnt actually use an alpha layer. So i add one then take a grey scale image I have for roughness inside of a game engine and put it there. Within the engine this is now only one texture but i can plug the RGB into the base and alpha into roughness.

How do I do this? I figured out how to add an alpha channel but it doesnt let me just paste a grey scale image into the channel.

Appreciate the help!


Solution

  • Method #1

    • Add a layer mask Layer>Mask>Add layer mask
    • This automatically selects the mask as the target of editing (in the bottom of the image displays, it says {layer name} mask.
    • Paste your image (Ctrl-V). This creates a floating selection, which is a layer, but don't worry. You can see that this layer is impacting the opacity of the layer below, which is a hint that it really applies to the mask. You can move that layer if you need to adjust the position of the paste.
    • Layer>Anchor layer (Ctrl-H) and your temporary layer is pasted over the mask.
    • Layer>Mask>Apply layer mask to "commit" the changes.

    Method #2:

    • Paste your image and make it a new layer (Ctrl-V, Ctrl-Shift-N)
    • In the Channels list, drag any of the R,G,B channels to the list below to copy it.
    • Remove the pasted layer, select your target layer
    • Layer>Mask>Add layer mask, initialize to a channel, and select the channel you created above.
    • Layer>Mask>Apply layer mask to "commit" the changes.