per-pixel random problems?

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Dec 11 23:25:56 CET 2008


Lukast dev wrote:
> I use random in Sumi-e brush. You can look how it is used in brush.cpp
> 
> But basiclly
> #ifdef _WIN32
> #define srand48 srand
> #define drand48 rand
> #endif

Hmm, penalizing Windows users... not sure how I feel about that.

Really, you shouldn't do that, you should do this:

#ifndef HAVE_ERAND48
double erand48(quint16 seed[3])
{
     const quint64 a = 0x5DEECE66D, b = 0xB;
     quint64 n = seed[0] + (seed[1]<<16) + (seed[2]<<32);
     n = ((n * a) + b) & 0xFFFFFFFFFFFF;
     seed[0] = n & 0xFFFF;
     seed[1] = (n>>16) & 0xFFFF;
     seed[2] = (n>>32) & 0xFFFF;
     return ldexp(double(n), -47));
}
#endif

...and you should never use the non-thread-safe versions! ;-)

> and I'm using drand48();
> 
> Works quite fast :)

Well, yes, /one/ iteration should be /very/ fast. I was talking about 
doing several dozen per pixel :-).

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
|-\ /-\ \ | -+-   |-\  +  \ | -+- /-\
| | | | |\|  |    |-/ /-\ |\|  |  |
|-/ \-/ | \  |    |   | | | \ -+- \-/



More information about the kimageshop mailing list