POV-Ray : Newsgroups : povray.newusers : linear sphere sweep vs union of spheres and cylinders Server Time
26 Nov 2024 05:31:53 EST (-0500)
  linear sphere sweep vs union of spheres and cylinders (Message 1 to 3 of 3)  
From: regdo
Subject: linear sphere sweep vs union of spheres and cylinders
Date: 5 Oct 2004 10:30:00
Message: <web.4162af58314562440ec0eb20@news.povray.org>
Hi to all.
First post, so be kind if i'm out of topic.
here's my problem : i have made an animation from a GPS log, with a shape
representating the car. I have no problem about the construction of the
path followed, for which i used a linear sphere sweep. But, the sweep has
more than 4000 points, so the render is *very* low (at least 15 minutes on
my 800Mhz Pentium). So I tried to optimize and remove the non-visible
points. It's much better (about 30s for each frame) but I still had a
problem with the suppression of these points, which sometimes cause the
sweep to come back onto the screen at positions it is not supposed to. So i
kept more points to keep the general shape of the sweep. It worked fine
till the 14000th frame where I, again, had the same problem. So I tried
replacing the sphere sweep with an union of spheres and cylinders, which is
very close to the initial result. I was **very** surprised with the render
times : for a 30s per frame with the optimized sweep, I now have a 2s
render-time with no optimization at all (more than 4500 cylinders and as
many spheres) !!
Can someone tell me where does such a difference come from ?
Thanks in advance for any information you could have.


Post a reply to this message

From: Mike Williams
Subject: Re: linear sphere sweep vs union of spheres and cylinders
Date: 5 Oct 2004 13:00:33
Message: <wLHwsDACMtYBFwoA@econym.demon.co.uk>
Wasn't it regdo who wrote:
>Hi to all.
>First post, so be kind if i'm out of topic.
>here's my problem : i have made an animation from a GPS log, with a shape
>representating the car. I have no problem about the construction of the
>path followed, for which i used a linear sphere sweep. But, the sweep has
>more than 4000 points, so the render is *very* low (at least 15 minutes on
>my 800Mhz Pentium). So I tried to optimize and remove the non-visible
>points. It's much better (about 30s for each frame) but I still had a
>problem with the suppression of these points, which sometimes cause the
>sweep to come back onto the screen at positions it is not supposed to. So i
>kept more points to keep the general shape of the sweep. It worked fine
>till the 14000th frame where I, again, had the same problem. So I tried
>replacing the sphere sweep with an union of spheres and cylinders, which is
>very close to the initial result. I was **very** surprised with the render
>times : for a 30s per frame with the optimized sweep, I now have a 2s
>render-time with no optimization at all (more than 4500 cylinders and as
>many spheres) !!
>Can someone tell me where does such a difference come from ?
>Thanks in advance for any information you could have.

It's a question of bounding.

When you use a linear sphere sweep, you have one object and therefore
one large bounding box. Any ray which enters that box needs to be tested
to see if it intersects any part of the sphere sweep.

When you use 4000 spheres and 3999 cylinders, you have 7999 objects and
therefore 7999 small bounding boxes. Each ray only enters a small number
of those bounding boxes, and only has to be tested to see if it
intersects those particular spheres and cylinders.

[You might well think that sphere and cylinder intersection tests are
quite cheap, and therefore you'd gain little by performing 7999 bounding
box tests instead of 7999 sphere/cylinder tests, but POV has a clever
way of creating hierarchical stacks of boxes. Most rays only get tested
against a few superboxes instead of all 7999 bottom-level bounding
boxes.]

If you try running test scenes with bounding switched off (-MB in the
command line), you'll see that the linear sphere sweep and the union of
spheres and cylinders take the same amount of time, which suggests that
a linear sphere sweep intersection test takes the same amount of time as
the corresponding 7999 sphere/cyliner tests.

If you then look at the stats in the message pane, you'll see that there
were many millions of cylinder and sphere tests performed when bounding
is disabled, since every ray gets tested against every object. Switch
bounding back on and those stats reduce by a factor of several thousand.

If you do the same stats comparison for the linear sweep, the unbounded
stats initially look a lot nicer, but then you have to remember that
each one of those sphere sweep intersection tests costs the same as 7999
sphere/cylinder tests. With bounding back on (+MB0 if there's nothing
else in the scene) the stats only reduce slightly if the object fills a
large proportion of the screen.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: regdo
Subject: Re: linear sphere sweep vs union of spheres and cylinders
Date: 7 Oct 2004 02:30:00
Message: <web.4164e20631c5b9f39761e0e60@news.povray.org>
Thanks for your answer. It was obvious, but I missed it.
You know you've spent too little time raytracing when ...
you ask for such stupid questions :)


Post a reply to this message

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