]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/fft-normalmap-to-heightmap.c
use Scharr operator instead of Sobel operator for edge detection
[xonotic/xonotic.git] / misc / tools / fft-normalmap-to-heightmap.c
index 909f591ff33667355fec0f52bebdcb5d77ab219d..17f9fd896ac66a4d33d4801fe0c60f090f99f2c4 100644 (file)
@@ -39,7 +39,7 @@ void nmap_to_hmap(unsigned char *map, const unsigned char *refmap, int w, int h,
 {
        int x, y;
        int fx, fy;
-       int ffx, ffy;
+       double ffx, ffy;
        double nx, ny, nz;
        double v, vmin, vmax;
 #ifndef C99
@@ -95,6 +95,7 @@ void nmap_to_hmap(unsigned char *map, const unsigned char *refmap, int w, int h,
                if(fy > h/2)
                        fy -= h;
                /* these must have the same sign as fx and fy (so ffx*fx + ffy*fy is nonzero), otherwise do not matter */
+               /* it basically decides how artifacts are distributed */
                ffx = fx;
                ffy = fy;
 #ifdef C99
@@ -353,11 +354,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)