<br><br><div class="gmail_quote">2008/12/11 Matthew Woehlke <span dir="ltr"><<a href="mailto:mw_triad@users.sourceforge.net">mw_triad@users.sourceforge.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Cyrille Berger wrote:<br>
> it's not erand... We need a non recursive function to be able to compute it's<br>
> value at every pixel independentely of other values. Being integer based<br>
> (unlike the current one) would be a huge bonus, since I discovered since that<br>
> time that floating point units in CPU are buggy and give very different<br>
> results from one arch to an other...<br>
<br>
</div>Honestly I'm not clear why erand48 doesn't work (it doesn't, I've been<br>
playing with it in a stand-alone program). You'd think with suitably<br>
large and semi-prime numbers, you could get a distribution where A*x % b<br>
results in a halfway decent f(x) for reasonable B. Alas, seems not.<br>
<br>
Well, what I did for my plasma stand-alone is run (x%5 + y%37)<br>
iterations. It seems to give an acceptable result, but it's relatively<br>
expensive :-).<br>
<div class="Ih2E3d"><br>
> On Thursday 11 December 2008, Matthew Woehlke wrote:<br>
</div><div class="Ih2E3d">>> The png is substantial (500+kb), so I dumped it at<br>
>> <a href="http://img124.imageshack.us/img124/9986/noisetesthq8.png" target="_blank">http://img124.imageshack.us/img124/9986/noisetesthq8.png</a>. (Um. And<br>
>> ImageShack no longer works without scripting or View Source; guess I<br>
>> won't be using them any more.)<br>
> Here is what I get: <a href="http://cyrille.diwi.org/tmp/noise.png" target="_blank">http://cyrille.diwi.org/tmp/noise.png</a><br>
<br>
</div>It's not as bad, but I would say there are artifacts there also. Hmm...<br>
I wonder how much difference using long double makes, it may be that<br>
you're getting 80-bit calculations and I am not?<br>
<br>
Anyway, this simple change... well, looks at least as good as yours,<br>
maybe a *tiny* bit better. I'm wondering if some of it is just in my<br>
head ;-). Regardless, this makes things on /my/ end a lot better:<br>
<br>
Index: image/kis_random_generator.cc<br>
===================================================================<br>
--- image/kis_random_generator.cc (revision 895863)<br>
+++ image/kis_random_generator.cc (working copy)<br>
@@ -46,8 +46,8 @@<br>
// To plot it in Octave :<br>
// t = 1:1:100000;<br>
//plot (t, sort(0.5*(cos( cos(cos(t.*t.*t.*t))) + 1)));<br>
- // This function has a near-gaussian distribtution<br>
- int n = x + (y + 1) * d->seed;<br>
+ // This function has a near-gaussian distribution<br>
+ quint64 n = (quint64(x) * 1103515249) + (quint64(y) * 91573) + d->seed;<br>
return 0.5*(cos(pow(n, 4)) + 1);<br>
}<br>
<br>
(note also the spelling correction ;-) )<br>
<br>
I may keep fiddling with a pure-integer random function.<br>
<div class="Ih2E3d"><br>
--<br>
Matthew<br>
Please do not quote my e-mail address unobfuscated in message bodies.<br>
</div></blockquote></div><br>I use random in Sumi-e brush. You can look how it is used in brush.cpp<br><br>But basiclly<br>#ifdef _WIN32<br>#define srand48 srand<br>#define drand48 rand<br>#endif<br><br>and I'm using drand48();<br>
<br>Works quite fast :)<br>