POV-Ray : Newsgroups : povray.general : Help with a slow difference Server Time
2 Aug 2024 02:23:17 EDT (-0400)
  Help with a slow difference (Message 1 to 3 of 3)  
From: Alf Peake
Subject: Help with a slow difference
Date: 28 Feb 2005 17:03:50
Message: <42239546@news.povray.org>
Any suggestions how to make the last two tests below render faster?
And why the difference in times?

Mat is a union of 240 rounded triangles (each 7 objects) on the
y-plane. I want to cut out a circular section for a table-top.

All tests +w512 +h384 +a0.3, and include
torus{ 3,0.05 translate <3.5,0,3.5> pigment{ rgb <0,1,1> } }

// Total time: 5s - 39424PPS.
object{Mat}

// Time: 9m 11s - 357PPS.
// Rr is the triangle rounding radius.
object{ Mat
   clipped_by{
      cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 } }
   bounded_by{
      cylinder{ <3.5,-Rr*1.1, 3.5>, <3.5, Rr*1.1, 3.5>, 3.01 } }
}

// Time: 12m 27s - 263PPS.
difference{
   object{ Mat }
   cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 inverse }
   bounded_by{
      cylinder{ <3.5,-Rr*1.1, 3.5>, <3.5, Rr*1.1, 3.5>, 3.01 } }
}

The last render can be seen here:
http://www.qsl.net/gw3srg/bits/tabletop.jpg

-- 
Alf


Post a reply to this message

From: Mike Williams
Subject: Re: Help with a slow difference
Date: 1 Mar 2005 01:13:40
Message: <dHlUOIAMeAJCFw4y@econym.demon.co.uk>
Wasn't it Alf Peake who wrote:
>Any suggestions how to make the last two tests below render faster?
>And why the difference in times?
>
>Mat is a union of 240 rounded triangles (each 7 objects) on the
>y-plane. I want to cut out a circular section for a table-top.
>
>All tests +w512 +h384 +a0.3, and include
>torus{ 3,0.05 translate <3.5,0,3.5> pigment{ rgb <0,1,1> } }
>
>// Total time: 5s - 39424PPS.
>object{Mat}
>
>// Time: 9m 11s - 357PPS.
>// Rr is the triangle rounding radius.
>object{ Mat
>   clipped_by{
>      cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 } }
>   bounded_by{
>      cylinder{ <3.5,-Rr*1.1, 3.5>, <3.5, Rr*1.1, 3.5>, 3.01 } }
>}
>
>// Time: 12m 27s - 263PPS.
>difference{
>   object{ Mat }
>   cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 inverse }
>   bounded_by{
>      cylinder{ <3.5,-Rr*1.1, 3.5>, <3.5, Rr*1.1, 3.5>, 3.01 } }
>}
>
>The last render can be seen here:
>http://www.qsl.net/gw3srg/bits/tabletop.jpg
>

It will go a lot faster if you change it from a difference of unions to
a union of differences. This might seem to be counterintuitive because
there will then be 240 difference operations instead of just one, but it
allows POV to create a bounding slab for each triangle instead of one
big bounding slab for the whole tabletop.

union {
  difference {
    object {Rounded_Triangle_1}
    cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 inverse }
  }
  difference {
    object {Rounded_Triangle_2}
    cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 inverse }
  }
  ... etc
}

(Presumably you create the Mat with some sort of loop, so just code teh
difference operations into that loop)

Don't apply manual bounding to the union of differences.

For more details of the logic behind this sort of stuff, see:

<http://www.econym.demon.co.uk/holetut/index.htm>


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Alf Peake
Subject: Re: Help with a slow difference
Date: 1 Mar 2005 15:50:39
Message: <4224d59f@news.povray.org>
Thanks Mike - that solved the problem.

> (Presumably you create the Mat with some sort of loop, so just code
> teh difference operations into that loop)

Correct. Just one loop with a macro call doing all the work. I wrapped
the macro call as suggested. The improvement is remarkable - 11 to 15
times faster :c)

// Time: 50s - 3942 PPS.
Loop{
  difference {
    object {R_Triangles() transform... }
    cylinder{ <3.5,-Rr*1.05, 3.5>, <3.5, Rr*1.05, 3.5>, 3 inverse }
  }
}

> <http://www.econym.demon.co.uk/holetut/index.htm>

I knew that was around somewhere :-/

-- 
Alf


Post a reply to this message

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