POV-Ray : Newsgroups : povray.newusers : CSG shape with many 'holes' takes *forever* to render! : Re: CSG shape with many 'holes' takes *forever* to render! Server Time
30 Jul 2024 22:24:04 EDT (-0400)
  Re: CSG shape with many 'holes' takes *forever* to render!  
From:
Date: 1 Aug 2003 01:08:03
Message: <3f29f5b3$1@news.povray.org>
/*

Hi Fuzzy

> If I can get POV to create the image that will be mapped on the fly then
> that would be perfect (and hopefully I don't want to use a temporary file
> inbetween either)

(1) You will need a temporary file

(2) You should be happy about this: else the map(s) would have to be
    recalculated at every test render, even if they don't change.

(3) It's possible to achieve such an on-the-fly creation of the maps
    with a little animation that first creates the map(s), then uses
    them in the last frame of the animation (which is the final result).
    The code is like this: (3 maps in this example)

      #switch (frame_number)
        #case (1)
          // code for first map goes here
          #break
        #case (2)
          // code for second map goes here
          #break
        #case (3)
          // code for third map goes here
          #break
        #else
          // code for the final image goes here; the maps created in
          // the previous frames can be used here
        #end

    The main disadvances of this method are:
    - all files have the same size and type
    - the quality settings, antialias parameters etc. are the same
      for all these files

(4) Using maps for holes doesn't create correct shape, shadows and
    reflections of the walls in the holes. Animation with realistic
    deep holes is impossible.

(5) CSG isn't as slow as you think! I've made a cylindrical sieve with
    FIVE THOUSAND holes. They required less than 26 MINUTES for 640*480
    at 933 MHz, although I used +A0.1 +SP8 +EP8. Your 1352 holes were done
    in only 2 minutes 18 seconds. See code below. For test renders, the
    number of holes can be reduced by lowering Rings and/or Sectors. So I
    can't see any reason not to use CSG. Random placement within the rings
    also is no problem, but additional vertical variation can be difficult
    (depending on density and randomness of the placement).


   Sputnik


*/


// beginning of code

// Cylinder with holes

// +SP8 +EP8 -FN +A0.1 +W640 +H480


#declare Rings = 50; // or 26; 26*52=1352
#declare Sectors = 100; // or 52; // must be even; >=4
#declare Height = 300; // height of cylinder
#declare Radius = 100; // radius of cylinder
#declare Thick = 3; // thickness of wall of cylinder
#declare Hole = 2.5; // radius of holes
#declare Screw = .5; // try -.5 ... 0 ... .5

#declare Ring =
  difference {
    cylinder { 0, Height/Rings*y, Radius
      pigment { color red 1 }
      finish { ambient .5 diffuse .7 }
      }
    cylinder { -0.01*y, (Height/Rings+0.1)*y, Radius-Thick
      pigment { color green 1 }
      finish { ambient .5 diffuse .7 }
      }
    #declare S = 0;
    #while (S<Sectors/2)
      cylinder {
        <0, Height/Rings/2, -Radius-0.01>,
        <0, Height/Rings/2, Radius+0.01>, Hole
        rotate S/Sectors*360*y
        pigment { color rgb <1, .8, 0> }
        finish { ambient .5 diffuse .7 }
        }
      #declare S = S+1;
      #end
    }

#declare Cylinder =
  union {
    #declare R = 0;
    #while (R<Rings)
      object { Ring translate R/Rings*Height*y rotate R*Screw*360/Sectors*y }
      #declare R = R+1;
      #end
    }

object { Cylinder }
object { Cylinder scale <-1, 1, 1> }

light_source { <-3, 2, -1>*1000, rgb 1 }

camera { location <1, 2, -3>*100 look_at 0 translate Height/2*y }

// END of code


Post a reply to this message

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