POV-Ray : Newsgroups : povray.binaries.images : Fractal noise (mathsy descussion) [2 x 200KB] Server Time
13 Aug 2024 05:50:51 EDT (-0400)
  Fractal noise (mathsy descussion) [2 x 200KB] (Message 1 to 8 of 8)  
From: Andrew Coppin
Subject: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 11:38:15
Message: <3ebd1ce7@news.povray.org>
See "Fractal noise" in povray.advanced-users. After reading Christoph's
reply, I built this...

First, I *eventually* came up with a macro which always returns the same
random value within the same "cube" in space, but in neighoring cubes there
is no correlation. (See 1st image.)

You would not believe how hard it was to make a macro that takes a 3D vector
as a seed... OK, for 1D, you just use your value directly as the seed. But
for 2D? You could just use X+Y as the seed - but then you get diagonal
patterns. (Since 5+7 = 7+5.) You could also try X*Y, but that has the same
problem. (Plus X*0 = 0, which makes things harder still.)

The algorithm I eventually came up with is NOT FAST. Simply initialise a
random stream to zero, then throw away a given number of samples. How many?
100*X + 10*Y + Z, modulo 256. (Modulus to hopefully speed things up without
loosing "randomness".) Small problem: answer needs to be positive. Solution?
Use abs(). Problems? Now we have symmetry about the origin! Solution? If
anything is negative, add on some arbitary (smallish) constant - different
for each axis.

Did you follow all that? POV-Ray did - sloooooooooowly. Surely there must be
a Better Way...

Next, interpolation. You wouldn't believe it could be this hard... I started
with linear interpolation, but there were huge discontinuities between
cells. I eventually figured out that 1) I had the coordinate axies
hopelessly muddled up, and 2) the interpolation parameter was running
backwards from 1 to 0, not 0 to 1. (I.e., all the cells were upside-down,
back-to-front and mirror image. Heh.) Once I sorted all that out, it worked
just great.

Then I made a small alteration: I took the parameter that runs from 0 to 1,
and took the cosine. This totally messed up the image, until I round the
correct transformation to bring the cosine back into the correct range. The
result is the 2nd image. Since for each point in space this calls the
interlying random macro 8 times (for the corners of the cube), it is
SUPERBLY SLOW! (Parse time for that image was 1 min 6 sec; render was 20 sec
btw.) Oh, and of course, while the value varies nice and smoothly, the
derrivative does not. I should probably fix that. (Which would require
sampling more randoms per point ==> slower still!)

So there you have it - a single wave that could make up part of a Perlin
noise function. (If I've understood what I read.) To make a real Perlin
function, I'd need several such waves, all of different wavelengths, and add
them together. Given how hellishly slow this wave is by itself, maybe I'll
go watch some paint dry instead...

If anyone can think of a faster random function that takes a 3D seed
(instead of the 1D seed POV-Ray's seed() function required) I'd love to know
about it... All other developments I want to try would involve more calls to
the random function, which will only get slower!

Thanks,
Andrew.


Post a reply to this message


Attachments:
Download 'Noise1.png' (127 KB) Download 'Noise2.png' (192 KB)

Preview of image 'Noise1.png'
Noise1.png

Preview of image 'Noise2.png'
Noise2.png


 

From: Andrew Coppin
Subject: (Postscripts)
Date: 10 May 2003 11:40:17
Message: <3ebd1d61$1@news.povray.org>
Yes, I *know* I can't spell! 8^P

No, the JPEG versions were actually about twice the size of the PNG
versions, so I'm posting in PNG.

Andrew.


Post a reply to this message

From: Peter Hertel
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 13:41:38
Message: <3ebd39d2@news.povray.org>
> SUPERBLY SLOW! (Parse time for that image was 1 min 6 sec; render was
20 sec btw.)

You call a 1min 26sec render slow? ;)
IIRC we might have discussed this before, no?

I haven't followed the discussion, but the second image (green) looks
pretty cool anyway.

-Peter


Post a reply to this message

From: Aaron Gillies
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 14:07:28
Message: <3ebd3fe0@news.povray.org>
Andrew must be running a cluster of distributed POV machines!

"Peter Hertel" <peter@hertel**NOSPAM**.no> wrote in message
news:3ebd39d2@news.povray.org...
> > SUPERBLY SLOW! (Parse time for that image was 1 min 6 sec; render was
> 20 sec btw.)
>
> You call a 1min 26sec render slow? ;)
> IIRC we might have discussed this before, no?


Post a reply to this message

From: Aaron Gillies
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 14:08:21
Message: <3ebd4015$1@news.povray.org>
Distributed cluster of POV machines?

"Aaron Gillies" <no### [at] spamcom> wrote in message
news:3ebd3fe0@news.povray.org...
> Andrew must be running a cluster of distributed POV machines!
>
> "Peter Hertel" <peter@hertel**NOSPAM**.no> wrote in message
> news:3ebd39d2@news.povray.org...
> > > SUPERBLY SLOW! (Parse time for that image was 1 min 6 sec; render was
> > 20 sec btw.)
> >
> > You call a 1min 26sec render slow? ;)
> > IIRC we might have discussed this before, no?
>
>
>


Post a reply to this message

From: Apache
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 15:43:19
Message: <3ebd5657$1@news.povray.org>
Same difference.


Post a reply to this message

From: Andrew
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 10 May 2003 18:38:40
Message: <3ebd7f70@news.povray.org>
Purely out of interest, what is your eventual aim here?  So far, it
would seem that the vturbulence() function does basically what you're
doing.

Don't take this as a "why bother?" criticism - I myself am coding Perlin
noise in C++ at the moment as an educational experience, knowing full
well that more efficient and flexible libraries of functions are
available out there if I wanted them...


Post a reply to this message

From: Andrew Coppin
Subject: Re: Fractal noise (mathsy descussion) [2 x 200KB]
Date: 11 May 2003 06:01:47
Message: <3ebe1f8b$1@news.povray.org>
1 min 6 sec IS a pretty dam long time to wait for a few hundred cubes to be
generated! I mean, if I were trying to do something COMPLICATED, then yes,
but all I'm doing is plotting a fairly simple function. And hey, this is a
1.4 GIGGAHERTZ computer, man! (I still can't believe they can actually make
a computer go that fast... unreal...)

As I said, I'm sure my loony 3D-random function is the culprit, but I have
nothing better ATM...

Why am I doing this? Erm... would you be suprised if I said "because I can"
or "becuase I wanna see how it works"? That and I'm interested in creating
some specialised noise functions of my own - if I can get this one to work!

Andrew.

PS. I'm currently looking into the cryptanalysis of the DES. Key-searches
aside, it's suprisingly unbreakable... or I haven't found the correct
website yet ;-)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.