From: Rudolf Polzer Date: Sat, 16 Apr 2011 18:12:47 +0000 (+0200) Subject: simplify normalization X-Git-Tag: xonotic-v0.5.0~103 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic.git;a=commitdiff_plain;h=4c7c9edf236b55ba305c547ade3b3ee0a0a324ab simplify normalization --- diff --git a/misc/tools/fft-normalmap-to-heightmap.c b/misc/tools/fft-normalmap-to-heightmap.c index c9368674..c5b5ea5f 100644 --- a/misc/tools/fft-normalmap-to-heightmap.c +++ b/misc/tools/fft-normalmap-to-heightmap.c @@ -85,10 +85,10 @@ void nmap_to_hmap(unsigned char *map, const unsigned char *refmap, int w, int h, double v = nx * nx + ny * ny + nz * nz; if(v > 0) { - v = sqrt(v); - nx /= v; - ny /= v; - nz /= v; + v = 1/sqrt(v); + nx *= v; + ny *= v; + nz *= v; map[(w*y+x)*4+2] = floor(nx * 127.5 + 128); map[(w*y+x)*4+1] = floor(ny * 127.5 + 128); map[(w*y+x)*4+0] = floor(nz * 127.5 + 128);