Phitt wrote:I'm not sure if the GIMP plugin creates different normal maps by default than the nVidia Photoshop plugin, but with the nVidia plugin using default settings you need to invert the green channel (or export with y inverted), then copy the green channel into the alpha channel, copy the red channel into the green channel and do the rest as you described. Otherwise the lighting on the normal map is off (tested that using a one color diffuse texture and a bumpy normal map with a single light source coming from one direction to see if the shading was correct).
So I finally looked into how the GIMP
plugin does it, and what you have to do in order to convert an RGB normalmap to a green-alpha one in GIMP
1. Copy the green channel to the alpha channel.
2. Copy the red channel to the green channel.
3. Fill the red and blue channels with black as usual.
No inversion is involved.
You can test this by grabbing a normalmap from Grimrock 1 and the corresponding normalmap from Grimrock 2, for example, assets/env/chain_metal_normal.dds which is present in both asset packs and therefore in both formats. Then use your converting procedure, and if it ends up the same as the Grimrock 2 version, you did it right.
Edit: I've looked at the gimp
-dds source, and the only differences between the DXT5 and DXT5nm export options are that DXT5nm adds the normalmap flag to the file (which Grimrock doesn't care about afaik), moves the red channel to the alpha channel, and fills the red channel with white (not black). It doesn't change the compression or mipmap generation algorithm. So I see no reason to use it over the plain DXT5 export option.
Also, here's a Script-Fu script I made to convert RGB maps to Grimrock style green-alpha ones automatically, including the mipmaps. This allows you to convert Grimrock 1 normal maps to Grimrock 2 normal maps with the press of a button, and without degrading the quality by regenerating mipmaps. It fills the red and blue channels with the current background colour, so you probably want to select black for the background colour before running it. It also serves as a demonstration of how terrible my Scheme knowledge is:
Code: Select all
(define orig-image 0)
(define (rgb-ga-layer layer)
(plug-in-normalmap 1 orig-image layer 0 0 1 0 0 0 8 0 0 0 0 0 layer)
(new-image (car (plug-in-decompose 1 orig-image layer "RGBA" 1)))
(gimp-edit-copy (car (gimp-image-get-layer-by-name new-image "green")))
(gimp-floating-sel-anchor (car (gimp-edit-paste (car (gimp-image-get-layer-by-name new-image "alpha")) TRUE)))
(gimp-edit-copy (car (gimp-image-get-layer-by-name new-image "red")))
(gimp-floating-sel-anchor (car (gimp-edit-paste (car (gimp-image-get-layer-by-name new-image "green")) TRUE)))
(gimp-drawable-fill (car (gimp-image-get-layer-by-name new-image "red")) 1)
(gimp-drawable-fill (car (gimp-image-get-layer-by-name new-image "blue")) 1)
(plug-in-recompose 1 new-image layer)
(define (script-fu-rgb-ga img)
(set! orig-image img)
(for-each rgb-ga-layer (vector->list (cadr (gimp-image-get-layers img))))
"RGBA to Green-Alpha"
"Convert an RGBA normal map to a Green-Alpha one."
"Andrew Minton" ;author
"cc0 or whatever" ;copyright notice
"February 19, 2016" ;date created
"RGBA" ;image type that the script works on
SF-IMAGE "Image" 0
(script-fu-menu-register "script-fu-rgb-ga" "<Image>/Colors/Components")
Remove the "(plug-in-normalmap 1 orig-image layer 0 0 1 0 0 0 8 0 0 0 0 0 layer)" line if you don't want to normalize the RGB map first (I included it because sometimes people compressed their Grimrock 1 normalmaps with DXT1, which degrades the quality really bad, and renormalizing generally makes the damage a little less noticeable)