POV-Ray : Newsgroups : povray.general : Fastest way of making polyhedra : Re: Fastest way of making polyhedra Server Time
7 Aug 2024 19:27:00 EDT (-0400)
  Re: Fastest way of making polyhedra  
From: Warp
Date: 11 Jul 2001 08:20:51
Message: <3b4c44a2@news.povray.org>
Andrea Ryan <ary### [at] global2000net> wrote:
: Does this mean two copies of twenty-four different meshes will render
: faster than forty-eight intersections of planes?

  To get the maximum rendering speed you should put all your triangles inside
the same mesh.

  When we are talking about the same shape which is copied several times over
the scene, whether it's better to make a mesh from the shape and then copy
the mesh over the scene, or whether it's better to put all the triangles inside
the same mesh, depends on how many triangles the shape has.
  If the shape has just a few triangles (as is usually the case with a
polyhedron) it's better to put everything inside a single mesh.
  If the shape consists of a huge amount of triangles (several thousands
or more) then it may be better to make it one mesh and then copy this mesh
around the scene. This way memory is saved.

  Making a mesh with a few triangles and then copying this mesh thousands
of times over the scene effectively neutralizes the advantages of the mesh
object. With just a few triangles no considerable rendering speed is achieved,
and copying it many times doesn't save too much memory either.
  The more triangles there are inside the same mesh, the more speed is
achieved.

  In theory, if you have n meshes with 1 triangle each, it will take n
ray-triangle intersection tests to calculate one ray (ie. if you have
1 million triangles this way, it will require 1 million ray-triangle
intersection tests).
  If you have 1 mesh with n triangles inside it, it will, in theory, take
an average of log8(n) ray-triangle intersection tests to calculate one ray
(ie. if you have 1 million triangles, it will require 7 ray-triangle
intersection tests).
  (Of course the numbers probably differ from these in practice, but the
order of magnitude should be approximately this.)

  This is why adding 100000 triangles to a mesh which already had 100000
triangles in it (ie. totaling 200000 triangles) doesn't make any considerable
rendering speed difference.

  Of course the other side of the coin is memory usage.
  If you have a mesh with 100000 triangles in it and you want to copy it
1000 times over the scene, it's memory-wise better to just copy the mesh
instead of copying the triangles inside the same mesh. The rendering time
will suffer a bit from this, but the saved memory can we definitely worth
it (in some cases it can even speed up the rendering if it helps to avoid
swapping).

  So the rule of thumb is:

  - If you have a mesh with just a few triangles (some tens of them) and you
    want to copy this shape many times, copy the triangles inside the same
    mesh instead of copying the mesh itself. This will speed up the rendering.

  - If you have a mesh with lots of triangles in it (tens of thousands or
    more), and you want to copy it several times, copy the mesh. It will save
    lots of memory.

  - In the in-between cases you'll have to find a compromise.


  (Perhaps I should write this into the VFAQ?)

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

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