Tool for combining height / displacement map with normal map

Does anyone have or know of a tool for combining a height or displacement map with a normal map? Specifically, I want to take the height and set it as the alpha channel in the normal map.

I am currently doing that manually via GIMP, and it’s a pretty painful process.

Thanks.

I had a similar situation where I wanted to merge the intensity from 4 textures (let’s say the R channel but really all RGB values were the same) into the RGBA values of a single texture. I used an image editing app for this which wasn’t ideal (especially handling the Alpha channel).

Recently I wrote an importer to do that automatically.
It would be easy to convert it to your needs and combine the RBG (normal) from the first texture and the R (height ) from the second texture into the Alpha channel.

The importer uses a single XML file like this one

<?xml version="1.0" encoding="UTF-8"?>
<channels>
   <image source="Channels/b_c0.png"/>
   <image source="Channels/b_c1.png"/>
   <image source="Channels/b_c2.png"/>
   <image source="Channels/b_c3.png"/>
</channels>

We could extend it to use a matrix to define the weight of various channels like so:

<?xml version="1.0" encoding="UTF-8"?>
<channels>
   <image source="Channels/b_c0.png" R="1 0 0 0" />
   <image source="Channels/b_c1.png" G="1 0 0 0" />
   <image source="Channels/b_c2.png" B="1 0 0 0" />
   <image source="Channels/b_c3.png" A="1 0 0 0" />
</channels>

In your case you could have something like this:

<?xml version="1.0" encoding="UTF-8"?>
<channels>
   <image source="Channels/normal.png" R="1 0 0 0" G="0 1 0 0" B="0 0 1 0" />
   <image source="Channels/height.png" A="1 0 0 0" />
</channels>

…to get a better idea of how this will work, here is an example that converts a texture to grayscale:

<?xml version="1.0" encoding="UTF-8"?>
<channels>
   <image source="Channels/color.png" R="0.2126 0.7152 0.0722 0" G="0.2126 0.7152 0.0722 0" B="0.2126 0.7152 0.0722 0" A="0 0 0 1"/>
</channels>

…or to mix 2 textures:

<?xml version="1.0" encoding="UTF-8"?>
<channels>
   <image source="Channels/tx1.png" R="0.5 0 0 0" G="0 0.5 0 0" B="0 0 0.5 0" A="0 0 0 0.5"/>
   <image source="Channels/tx2.png" R="0.5 0 0 0" G="0 0.5 0 0" B="0 0 0.5 0" A="0 0 0 0.5"/>
</channels>

@nkast Nice! I’ll take a look at it… looks like it could be pretty useful.

I think you can have a quick hack to do what you want within a day.
Use the sample project to test your results visually. (Samples.SLMC.WINDOWS.MG)
(at the moment it doesn’t show the alpha channel :expressionless: )

The idea about using the matrix is in my plans whenever I find the time.