POV-Ray : Newsgroups : povray.newusers : Very slow rendering of an object with many holes Server Time
1 Nov 2024 10:19:58 EDT (-0400)
  Very slow rendering of an object with many holes (Message 1 to 8 of 8)  
From: Tomohiro
Subject: Very slow rendering of an object with many holes
Date: 21 May 2009 12:50:01
Message: <web.4a1585be2b4d1dd4bbb61a180@news.povray.org>
Hello, I have another question.

My scene has a plate with many (about 1000) holes, like following:

difference{
  cylinder{<0,0,0>,<0,1,0>,10}
  #local X=-9; #while(X<9)
    #local Y=-9; #while(Y<9)
      #if (X*X+Y*Y < 81)
        cylinder{<X,-0.1,Y>,<X,1.1,Y>,0.1}
      #end
    #local Y=Y+0.5; #end
  #local X=X+0.5; #end
}

Rendering of this is very slow, even if I added bounded_by.
On the other hand, if I removed CSG, it is much faster.

How can I improve the rendering speed?


Post a reply to this message

From: stevenvh
Subject: Re: Very slow rendering of an object with many holes
Date: 21 May 2009 13:45:01
Message: <web.4a1592bddc3f4a9cc0721a1d0@news.povray.org>
"Tomohiro" <nomail@nomail> wrote:
> Hello, I have another question.
>
> My scene has a plate with many (about 1000) holes, like following:
>
> difference{
>   cylinder{<0,0,0>,<0,1,0>,10}
>   #local X=-9; #while(X<9)
>     #local Y=-9; #while(Y<9)
>       #if (X*X+Y*Y < 81)
>         cylinder{<X,-0.1,Y>,<X,1.1,Y>,0.1}
>       #end
>     #local Y=Y+0.5; #end
>   #local X=X+0.5; #end
> }
>
> Rendering of this is very slow, even if I added bounded_by.
> On the other hand, if I removed CSG, it is much faster.
>
> How can I improve the rendering speed?


I think the following link provide an answer:
http://www.econym.demon.co.uk/holetut/index.htm

Steven


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Very slow rendering of an object with many holes
Date: 21 May 2009 14:31:14
Message: <4a159df2$1@news.povray.org>
Tomohiro wrote:

> How can I improve the rendering speed?

You're in luck, there is an entire tutorial just on holes ;)

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


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Very slow rendering of an object with many holes
Date: 21 May 2009 14:32:58
Message: <4a159e5a$1@news.povray.org>
oops as stevenvh already posted, should have hit update before send ;)


Post a reply to this message

From: clipka
Subject: Re: Very slow rendering of an object with many holes
Date: 21 May 2009 15:25:00
Message: <web.4a15aa63dc3f4a9ce1d5d3040@news.povray.org>
"Tomohiro" <nomail@nomail> wrote:
> My scene has a plate with many (about 1000) holes, like following:
>
> ...
>
> Rendering of this is very slow, even if I added bounded_by.
> On the other hand, if I removed CSG, it is much faster.
>
> How can I improve the rendering speed?

This is a general problem with CSG objects that have a lot of cut-outs. It has
to do with how POV uses (or, as in this case, doesn't use) bounding.

If your holes are placed at regular intervals, one solution would be to assemble
the plate from 1000 elements having a single hole each. This is actually a good
deal faster, because in this case POV-Ray will apply bounding to each of these
elements for good effect.

If the holes are cylindrical, you can also make creative use of the blob object,
by defining the holes collectively as one single blob with 1000 cylinder
elements, instead of 1000 individual cylinder objects; IIRC, this should give
you some speed advantage as well, because blobs (like meshes) have their own
bounding mechanism.


Post a reply to this message

From: Tomohiro
Subject: Re: Very slow rendering of an object with many holes
Date: 22 May 2009 18:50:00
Message: <web.4a172aa8dc3f4a9c20aaa4ac0@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
> I think the following link provide an answer:
> http://www.econym.demon.co.uk/holetut/index.htm

Thank you for your helps.

My object has regular arrangement of cylindrical holes, but
I cannot guess a function because:

- holes are arranged in hexagonal way
- no "half" holes at edge of the object
- (if possible) a small part of edge of holes should be cut in 45 degree

On the other hand, usage of blob worked almost well, but
it cannot satisfy the third requirement written above.


Post a reply to this message

From: Chris B
Subject: Re: Very slow rendering of an object with many holes
Date: 23 May 2009 10:01:51
Message: <4a1801cf@news.povray.org>
"Tomohiro" <nomail@nomail> wrote in message 
news:web.4a172aa8dc3f4a9c20aaa4ac0@news.povray.org...
> "stevenvh" <nomail@nomail> wrote:
>> I think the following link provide an answer:
>> http://www.econym.demon.co.uk/holetut/index.htm
>
> Thank you for your helps.
>
> My object has regular arrangement of cylindrical holes, but
> I cannot guess a function because:
>
> - holes are arranged in hexagonal way
> - no "half" holes at edge of the object
> - (if possible) a small part of edge of holes should be cut in 45 degree
>
> On the other hand, usage of blob worked almost well, but
> it cannot satisfy the third requirement written above.
>

The following example took a little longer than I'd anticipated to write, 
mainly because I'd not read your first posting carefully enough and didn't 
initially realise you wanted a cylindrical object. Anyway, the approach I 
took was basically the same and could be made to work with a variety of 
shapes:  I've declared a 'blank' box without a hole and a 'holed' box of the 
same size so that they can be slotted together in the same sort of way that 
Mike's tutorial shows, but each of the boxes is just big enough to take one 
hole.

The nested #while loops lay the boxes out in a grid, with a few conditional 
statements to determine what to place where (based on the calculated centre 
point for that box). The first condition is that, if it's well outside the 
circle it doesn't bother placing an object there at all. The second says 
that, if it overlaps the edge, trim it using a CSG intersection with a 
cylinder. If the centre would make the hole touch the edge it uses the 
'blank' object, otherwise it uses the 'holed' object.

I hope I've correctly interpreted what you meant when said you wanted the 
holes laid out in an 'hexagonal way'. I've interpreted this as a 50% offset 
in successive rows, giving a hexagonal/triangular pattern (ie with prominent 
diagonal lines of holes), but it should be fairly easy to replace every 
third hole on each line with a 'blank' giving a pure hexagonal pattern.

This example rendered 1618 holes in 2 seconds on my machine.

camera {location  <-1, 2,-4> look_at 0}
light_source {< 70, 200, -80> color rgb 0.8}

#declare XHoles = 50;
#declare XSep = 0.1;
#declare ZSep = 0.5*XSep*sqrt(3);
#declare ZHoles = int(XHoles*XSep/ZSep);
#declare Radius = (XHoles*ZSep)/2;

#declare BlankObject = box {<-XSep/2,-0.1,-ZSep/2><XSep/2,0,ZSep/2> }

#declare HoledObject = difference {
  object {BlankObject}
  cylinder {<0,-0.05,0><0,0.05,0>,0.02}
  cone {<0,-0.05,0>,0,<0,0.05,0>,XSep/2}
}

#declare HoleCount = 0;
union {
  #declare I =-(XHoles-1)/2;
  #while (I<(XHoles/2))
    #declare J = -(ZHoles-1)/2;
    #while (J<(ZHoles/2))
      #local ThisCentre = <XSep*(I+mod(J,2)/2),0,J*ZSep>;
      // If it's part of the object
      #if (vlength(ThisCentre)<(Radius+XSep/sqrt(2)))
        // If it's part of the edge
        #if (vlength(ThisCentre)>(Radius-XSep/sqrt(2)))
          intersection {
            #if (vlength(ThisCentre)<(Radius-0.05))
              object {HoledObject translate ThisCentre}
              #declare HoleCount = HoleCount + 1;
            #else
              object {BlankObject translate ThisCentre}
            #end
            cylinder {<0,-0.11,0><0,0.1,0>,Radius}
          }
        // If it's clear of the edge
        #else
          object {HoledObject translate ThisCentre}
          #declare HoleCount = HoleCount + 1;
        #end
      #end
      #declare J = J + 1;
    #end
    #declare I = I + 1;
  #end
  pigment {rgb 1}
}

cylinder {<0,-0.5,0><0,-0.12,0>,Radius pigment {rgb <1,1,0>}}
#debug concat(str(HoleCount,3,0)," Holes.\n")

Regards,
Chris B.


Post a reply to this message

From: clipka
Subject: Re: Very slow rendering of an object with many holes
Date: 23 May 2009 14:10:00
Message: <web.4a183ae8dc3f4a9cefff66860@news.povray.org>
"Tomohiro" <nomail@nomail> wrote:
> My object has regular arrangement of cylindrical holes, but
> I cannot guess a function because:
>
> - holes are arranged in hexagonal way
> - no "half" holes at edge of the object
> - (if possible) a small part of edge of holes should be cut in 45 degree
>
> On the other hand, usage of blob worked almost well, but
> it cannot satisfy the third requirement written above.

.... so looks like you need to resort to solution #1: Small building blocks with
just a few holes each. One type for the "bulk" of the object, and another few
for the edges.


Post a reply to this message

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