Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Galemp on November 18, 2015, 10:27:03 pm

Title: Back-converting normal maps to height maps
Post by: Galemp on November 18, 2015, 10:27:03 pm
Does anyone know of a method to take DDS DXT5 normal maps, and convert them back to grayscale height maps?

I found a way to do it with DXT1 settings (the blue-ish ones) but I haven't found a way to convert DXT5 (the greenish ones). Even being able to convert from DXT5 to DXT1 would help. I have Photoshop and the NVidia plugins if that helps.

On a side note if anyone has the original height maps used to generate the textures for the SG Rahu this would be a moot point. Thanks.
Title: Re: Back-converting normal maps to height maps
Post by: The E on November 19, 2015, 01:41:43 am
Okay, first of all, a point of terminology: DXT1, 3 and 5 are texture compression formats, they have nothing to do with the format of normal map used. The correct way to refer to the blue ones is "standard" normal maps, what FSO is using are "those damn special things taylor invented back in the dark ages for inadequately explained reasons".

Now, if you have a green normal map, you can convert it back to a standard normal map by copying the Alpha channel to the Red channel, then blanking or removing the Alpha channel, you can then feed this back into whatever method you use to reconstruct the height map (You may also need to flood the Blue channel with full color value, you'll have to experiment with this).
Title: Re: Back-converting normal maps to height maps
Post by: Kobrar44 on November 19, 2015, 02:48:54 am
I recall there was a gimp script soooomewhere on the forums which calulated a proper blue value for the blue channel.
http://www.hard-light.net/forums/index.php?topic=69064.0 (http://www.hard-light.net/forums/index.php?topic=69064.0)
Title: Re: Back-converting normal maps to height maps
Post by: fightermedic on November 19, 2015, 03:58:01 am
I recall there was a gimp script soooomewhere on the forums which calulated a proper blue value for the blue channel.
http://www.hard-light.net/forums/index.php?topic=69064.0 (http://www.hard-light.net/forums/index.php?topic=69064.0)
oohh, usefull, thanks!
Title: Re: Back-converting normal maps to height maps
Post by: Raven2001 on November 19, 2015, 05:48:09 am
There's a free tool called xNormal for map baking and etc. It  also has some good editing tools (height to normal, etc), but I don't recall if it has a normal to height map tool.
In any case, it's worth taking a look because IMO the height to normal map tool is better than the Nvidia one :)
Title: Re: Back-converting normal maps to height maps
Post by: mjn.mixael on November 19, 2015, 10:15:15 am
In all my research going from Normal to Height is often not recommended from a quality perspective. You can do it, but it's a little like turning a jpg into a png. Sure, it'll work... but signs of the compression remain.

In my needs, it's worked best to do this with any of the automated tools out there and then spending some time fixing it by hand.
Title: Re: Back-converting normal maps to height maps
Post by: Galemp on November 19, 2015, 11:44:22 am
Alright, I found a way to convert from DXT5 to standard normal maps in GIMP.

Colors > Components > Decompose, change mode to RGBA. This will open a new image with one layer for each channel.

Flood the Blue channel with White and delete the Red channel.

Then go to Colors > Components > Compose with the mode set to RGB and you can generate a new image reassigning channels. Green stays green, Blue is the new Blue, old Alpha is the new Red. Use the normal map plugin for GIMP (https://code.google.com/p/gimp-normalmap/downloads/list) to "normalize" the output, i.e. ensure each pixel has a vector length of 1.

Good news, the filter will also let you convert a normal map to a height map. Now for the bad news: the results are fairly poor, borderline unusable.

In all my research going from Normal to Height is often not recommended from a quality perspective. You can do it, but it's a little like turning a jpg into a png. Sure, it'll work... but signs of the compression remain.

In my needs, it's worked best to do this with any of the automated tools out there and then spending some time fixing it by hand.

This does seem to be the way to go.

[attachment DELETED!! by Strong Bad]
Title: Re: Back-converting normal maps to height maps
Post by: The Dagger on November 20, 2015, 03:42:50 pm
That map was surely made directly from the diffuse. I mean, I get a map that looks the same as what we have by applying the normal-map filter to the diffuse.