noise generators (forked from: Krita user community?)

Cyrille Berger cberger at cberger.net
Mon Feb 25 10:13:13 CET 2008


On Monday 25 February 2008, Matthew Woehlke wrote:
> Cyrille Berger wrote:
> > On Sunday 24 February 2008, Matthew Woehlke wrote:
> >> (Ok, erand48 will have to go, but that's completely
> >> self-contained as I've assumed from the outset that my current
> >> procedural PRN formula would be only temporary... not least because it
> >> turns out rand48 isn't very *good*.)
> >
> > The slight annoyance with rand48/erand48 is that those functions are not
> > thread safe, and as it is recursive noise generator, it doesn't work well
> > if we ask for an update of a rectangle of the generated images which is
> > different from the original rect.
>
> Eh? I'm using the flavor that claims to be re-entrant (i.e. the one that
> takes the seed as an in/out). I actually do all my PRN-getting via a
> myRandom() function that takes the X,Y coordinates and random seed, so
> replacing mine with Krita's should be easy. (Or maybe Krita's would
> benefit from my approach?)
>
> > For this we have a random number generator
> > in Krita, that takes as argument the current coordinate of the pixel.
> > (The formula is probably not very *good*, but I don't know any random
> > number generator formula that is very *good*).
>
> I trust it also takes the random seed? I especially need that because I
> need several *different* random values per pixel (I want to say, as many
> as five); I handle this by simply adding a fixed value to the random
> seed, which should be "good enough".

Yes it does. The point about threading is that the filter isn't necesserally 
run in one pass on the full image. We might split it into two area (ie 
[0x0,500x250] and [0x250,500x250], and if you are not carefull with your 
random number you get a discontinuity at y=250.

-- 
Cyrille Berger


More information about the kimageshop mailing list