]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/normalmap.sh
Merge branch 'master' of git://git.xonotic.org/xonotic/xonotic
[xonotic/xonotic.git] / misc / tools / normalmap.sh
index 08ca0fae071d882f6b3590e8521e2594f6b9ba19..b41b613a0f68598420f3f19933b6eea9f3bdc3c2 100755 (executable)
@@ -2,6 +2,7 @@
 
 # usage: ./bump2norm.sh foo_bump.tga foo_norm.tga
 # NOTE: unfortunately requires X-server (otherwise file-tga-save won't work... no joke)
+# also, alpha channel value 0 is avoided as gimp doesn't save it properly
 
 in=$1
 out=$2
@@ -29,8 +30,16 @@ gimp -i -b - <<EOF
                (img (car (gimp-file-load RUN-NONINTERACTIVE "$in" "$in")))
                (drawable (car (gimp-image-active-drawable img)))
                (layer (car (gimp-image-get-active-layer img)))
+               (mycurve (cons-array 256 'byte))
+               (i 1)
        )
        (gimp-layer-add-alpha layer)
+       (aset mycurve 0 1)
+       (while (< i 256) (aset mycurve i i) (set! i (+ i 1)))
+       (gimp-curves-explicit drawable HISTOGRAM-RED 256 mycurve)
+       (gimp-curves-explicit drawable HISTOGRAM-GREEN 256 mycurve)
+       (gimp-curves-explicit drawable HISTOGRAM-BLUE 256 mycurve)
+       (gimp-curves-explicit drawable HISTOGRAM-ALPHA 256 mycurve)
        (plug-in-normalmap RUN-NONINTERACTIVE img drawable $filter $minz $scale 1 $heightsource 1 $conv 0 0 1 0 1 layer)
        (file-tga-save RUN-NONINTERACTIVE img drawable "$out" "$out" 1 1)
        (gimp-quit 0)