|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi,
I think I found a couple of bugs with the noise generator.
I downloaded the source code for POV-Ray 3.5 for windows, to see how noise
is generated. When reviewing the source, I saw the following:
In the POV-Ray Core project,
in the file "Texture.cpp",
in the function "static void InitSolidNoise (void)",
there is a section of code designed to generate random gradient vectors,
which are uniformly distributed on the unit sphere. There are 2 bugs with
that:
1. There is a loop there, with a condition that is supposed to "trash" any
random vector which is outside the sphere. The condition should be OR, not
AND:
The code for each random vector generation looks something like that:
do {
Find a random vector in the unit cube.
s = the length of the vector, squared.
} while ((s > 1.0) && (s < 1.0e-5));
Normalize the vector;
The condition is a contradiction, and should have been:
"while ((s > 1.0) || (s < 1.0e-05))"
This bug causes the vectors to be non-uniformly distributed on the sphere.
2. In general, this technique will not produce uniform distribution of
vectors even when the bug is fixed (because the random values are actually
a discrete set of values), but I guess some compromises are tolerable, and
probably invisible (Who can tell that the noise is not exactly uniform?...)
Zohar Leder,
zoh### [at] yahoocom
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
You'd better post this to povray.programming.
I'm including a full-quote here so that the complete message appears on
p.programming.
Zohar wrote:
> Hi,
> I think I found a couple of bugs with the noise generator.
> I downloaded the source code for POV-Ray 3.5 for windows, to see how noise
> is generated. When reviewing the source, I saw the following:
>
> In the POV-Ray Core project,
> in the file "Texture.cpp",
> in the function "static void InitSolidNoise (void)",
>
> there is a section of code designed to generate random gradient vectors,
> which are uniformly distributed on the unit sphere. There are 2 bugs with
> that:
> 1. There is a loop there, with a condition that is supposed to "trash" any
> random vector which is outside the sphere. The condition should be OR, not
> AND:
>
> The code for each random vector generation looks something like that:
>
> do {
> Find a random vector in the unit cube.
> s = the length of the vector, squared.
> } while ((s > 1.0) && (s < 1.0e-5));
>
> Normalize the vector;
>
> The condition is a contradiction, and should have been:
> "while ((s > 1.0) || (s < 1.0e-05))"
>
ACK.
> This bug causes the vectors to be non-uniformly distributed on the sphere.
>
> 2. In general, this technique will not produce uniform distribution of
> vectors even when the bug is fixed (because the random values are actually
> a discrete set of values), but I guess some compromises are tolerable, and
> probably invisible (Who can tell that the noise is not exactly
> uniform?...)
>
> Zohar Leder,
> zoh### [at] yahoocom
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <web.3efcbb174718e7c3d0082e520@news.povray.org> , "Zohar"
<zoh### [at] yahoocom> wrote:
> do {
> Find a random vector in the unit cube.
> s = the length of the vector, squared.
> } while ((s > 1.0) && (s < 1.0e-5));
>
> Normalize the vector;
>
> The condition is a contradiction, and should have been:
> "while ((s > 1.0) || (s < 1.0e-05))"
Indeed, the current code does not make sense. This is a bug.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|