retaining colors with 0 alpha in GIMP
I decided to utilize all 4 color channels in the images for my heightmap-driven terrain engine. (to handle more detail in the heightmap itself and to allow offsets for what texture layer to use) The only problem is that GIMP doesn't save the color value when there's 0 alpha, which causes holes for every other piece of information where the information stored in the alpha channel reaches 0. Is there any way to force it to store the correct color value, or am I going to need to make a utility of my own to stitch together the 4 heightmaps into a single 4-channel image?
Edit: in case it helps, I'm using PNGs.
Edit: in case it helps, I'm using PNGs.
In GIMP 2.3 (developmental version) there is an option to "save color values from transparent pixels", in the PNG save dialog.
Don't have GIMP 2.2 installed to check if it's there.
Installing the developmental version from source wasn't too painful though. You just have to make sure that you have all the dependencies before building it.
Don't have GIMP 2.2 installed to check if it's there.
Installing the developmental version from source wasn't too painful though. You just have to make sure that you have all the dependencies before building it.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
I decided to make a simple command-line utility to combine up to 4 images into a single image as necessary, and it works perfectly. It would be nice to do it completely in GIMP, however.
Since I posted about it, I might as well images of it: my new terrain creation method with a multi-channeled heightmap. I am using this multi-channel image as my heightmap:
![[Image: level000.png]](http://akb825.com/images/level000.png)
The red channel is the main heightmap detail, the green channel is finer detail of the heightmap, the blue channel is the large offset of the texture height (though the transitions can break if more than 1 texture layer is traversed between pixels), and the alpha channel is finer texture height offset.
This first image is with only using the first layer and ignoring the rest, or simply the main heightmap detail.
![[Image: terrain%20one.png]](http://akb825.com/images/terrain%20one.png)
This image has all of the layers enabled, which gives it greater detail, allows sand to show around the river bed, and allows slight variations in the texturing as the finer offsets allow other texture layers to show through.
![[Image: terrain%20all.png]](http://akb825.com/images/terrain%20all.png)
I could have had the finer detail in the first channel of the heightmap as well, but as the heightmap grows vertically, precision is lost, so the second channel allows for much finer adjustments to be made. (since it has a whole different height scale)
Since I posted about it, I might as well images of it: my new terrain creation method with a multi-channeled heightmap. I am using this multi-channel image as my heightmap:
![[Image: level000.png]](http://akb825.com/images/level000.png)
The red channel is the main heightmap detail, the green channel is finer detail of the heightmap, the blue channel is the large offset of the texture height (though the transitions can break if more than 1 texture layer is traversed between pixels), and the alpha channel is finer texture height offset.
This first image is with only using the first layer and ignoring the rest, or simply the main heightmap detail.
![[Image: terrain%20one.png]](http://akb825.com/images/terrain%20one.png)
This image has all of the layers enabled, which gives it greater detail, allows sand to show around the river bed, and allows slight variations in the texturing as the finer offsets allow other texture layers to show through.
![[Image: terrain%20all.png]](http://akb825.com/images/terrain%20all.png)
I could have had the finer detail in the first channel of the heightmap as well, but as the heightmap grows vertically, precision is lost, so the second channel allows for much finer adjustments to be made. (since it has a whole different height scale)
Skorche Wrote:In GIMP 2.3 (developmental version) there is an option to "save color values from transparent pixels", in the PNG save dialog.GIMP 2.2 also has that option, but it doesn't seem to work. (unless it's describing something else with a similar description)
Don't have GIMP 2.2 installed to check if it's there.
Installing the developmental version from source wasn't too painful though. You just have to make sure that you have all the dependencies before building it.
One dirty hack that I've used in photoshop is to adjust the levels on my alpha channels such that the min value is 1, not zero. Generally, there's no discernable optical difference, but this prevents the PNG codec from trashing the color values for that pixel.
I was thinking of that, too. But now that I've played around with the it, I think it's actually faster to save the layers as 4 grayscale images and use the simple utility I made thanks to all the dialogs I have to go through to zero out the channels not used for every layer. (and it's not quite so dirty
)
)
GIMP is trivially scriptable you know. Script-fu and Gimp-Python are both installed by default now.
<shameless plug>You can even script it in Ruby now!</shameless plug>
<shameless plug>You can even script it in Ruby now!</shameless plug>
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
That would be a very good solution. (if I could get it to save keeping the colors intact...
)
)

