POV-Ray : Newsgroups : povray.general : Bug with noise generator : Re: Bug with noise generator Server Time
17 Nov 2024 05:16:20 EST (-0500)
  Re: Bug with noise generator  
From: Wolfgang Wieser
Date: 28 Jun 2003 03:38:46
Message: <3efd4605@news.povray.org>
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

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