|
![](/i/fill.gif) |
> I've just come across an unusual bit of behaviour when rendering a large
> number of similar isosurfaces.
> When I use the code:
>> #declare Index = 0;
>> #while (Index<29)
>> isosurface {
>> function {f_rounded_box(x, y, z, 0.1, 1.19, 0.3, 0.4)+f_granite(x+rand(Seed),
>> y+rand(Seed), z+rand(Seed))*0.09}
> I get the message:
>> Parse Error: Expected 'function identifier', } found instead
> However, when I use:
>> #declare Index = 0;
>> #while (Index<29)
>> #local RX=rand(Seed);
>> #local RY=rand(Seed);
>> #local RZ=rand(Seed);
>> isosurface {
>> function {f_rounded_box(x, y, z, 0.1, 1.19, 0.3, 0.4)+f_granite(x+RX,
>> y+RY, z+RZ)*0.09}
> Everything works as expected.
> What's happening? Surely Pov's only got to look up the next number in
> the random stream which can't be much different from looking up the
> values of the declared variables.
>
> John (scratching his head in confusion)
There is a big difference:
When you trace an isosurface, you take several samples inside the
container, each time evaluating the function. You must take several
samples for each ray that enters the container untill you actualy find a
surface.
In the first case, you'd need to fetch a new random value EACH time you
sample the container to see if you've found the surface. This makes for
several random values for each ray. This would makes the isosurface
looks like a ball of dust if it was allowed. As you progress toward the
surface, one sample detect that it's should be well ahead, then, the
next sample detects that the surface that should still be ahead is now
beheind. Most of the time, the surface can't be found and you pass right
trough your object.
In the second case, you get a random value ONCE for each direction. The
random value is constent everywhere, and shifts the surface in a random,
but constant, direction.
Alain
Post a reply to this message
|
![](/i/fill.gif) |