]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/fft-normalmap-to-heightmap.c
do not write zero alpha values
[xonotic/xonotic.git] / misc / tools / fft-normalmap-to-heightmap.c
index aa4ac7fffe78855f555424ba2cfff178581f75db..8d95d5c6f5f4325d13e8746c0a1cadc61c3318d0 100644 (file)
@@ -270,6 +270,8 @@ void hmap_to_nmap(unsigned char *map, int w, int h, int src_chan, double scale)
                imgspace1[(w*y+x)][0] = (v - 128.0) / 127.0;
                imgspace1[(w*y+x)][1] = 0;
 #endif
+               if(v < 1)
+                       v = 1; /* do not write alpha zero */
                map[(w*y+x)*4+3] = floor(v + 0.5);
        }
 
@@ -354,11 +356,11 @@ void hmap_to_nmap_local(unsigned char *map, int w, int h, int src_chan, double s
        int i, j;
        double *img_reduced = malloc(w*h * sizeof(double));
        static const double filter[3][3] = { /* filter to derive one component */
-               { -1, 0, 1 },
-               { -2, 0, 2 },
-               { -1, 0, 1 }
+               {  -3, 0,  3 },
+               { -10, 0, 10 },
+               {  -3, 0,  3 }
        };
-       static const double filter_mult = 0.125;
+       static const double filter_mult = 0.03125;
 
        for(y = 0; y < h; ++y)
        for(x = 0; x < w; ++x)
@@ -380,6 +382,8 @@ void hmap_to_nmap_local(unsigned char *map, int w, int h, int src_chan, double s
                                break;
                }
                img_reduced[(w*y+x)] = (v - 128.0) / 127.0;
+               if(v < 1)
+                       v = 1; /* do not write alpha zero */
                map[(w*y+x)*4+3] = floor(v + 0.5);
        }