X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=fractalnoise.c;h=3425daf84dca34e94bb7881c1d1939d109176214;hb=6fa2a4c4c869043c2b63f96aea7b861fe011e237;hp=93622b14e4530f6f8f8223223bd79dfeda4353b3;hpb=e4b3858e7aca0ead91be1d8f675db084d025abad;p=xonotic%2Fdarkplaces.git diff --git a/fractalnoise.c b/fractalnoise.c index 93622b14..3425daf8 100644 --- a/fractalnoise.c +++ b/fractalnoise.c @@ -17,7 +17,7 @@ void fractalnoise(byte *noise, int size, int startgrid) startgrid = bound(0, startgrid, size); - amplitude = 32767; + amplitude = 0xFFFF; // this gets halved before use noisebuf = qmalloc(size*size*sizeof(int)); memset(noisebuf, 0, size*size*sizeof(int)); @@ -55,10 +55,11 @@ void fractalnoise(byte *noise, int size, int startgrid) if (n(x,y) > max) max = n(x,y); } max -= min; + max++; // normalize noise and copy to output for (y = 0;y < size;y++) for (x = 0;x < size;x++) - *noise++ = (n(x,y) - min) * 255 / max; + *noise++ = (byte) (((n(x,y) - min) * 256) / max); qfree(noisebuf); #undef n }