POV-Ray : Newsgroups : povray.general : mesh vs. union of triangles speed comparison : mesh vs. union of triangles speed comparison Server Time
11 Aug 2024 15:11:18 EDT (-0400)
  mesh vs. union of triangles speed comparison  
From: Nieminen Mika
Date: 20 Jun 1999 07:16:06
Message: <376ccd76@news.povray.org>
As a result of a discussion about rendering speed of meshes and unions of
triangles, I made this test.

  * The result:

  With a relative small amount of triangles (a few thousands) the union is
a bit faster. With larger amounts (tens of thousands) the mesh is a bit
faster. If the amount of triangles is so large that the union of them needs
to swap, then the mesh is absolutely faster.
  It's interesting that the trace time of a mesh with 15000 triangles is
approximately the same as the trace time of a mesh with 102000 triangles.
This seems to mean that the trace time is only a little dependant of the
number of triangles (if the number is quite large) as long as swapping is
not needed.

  I also discovered something interesting: Smooth triangles are double
illuminated when in a union but not when in a mesh.
  Is this intentional? If I remember correctly, they were double illuminated
also in a mesh in povray 3.0.

  * The details:

  The computer is a SparcStation 4. I rendered the images at 320x240
resolution with no antialiasing.
  I used the following scene to make the test:

--------------------------------------------------------------------------

#declare TriangleAmnt=<3,9>;
#declare UseUnion=no;
#declare SmoothTriangles=no;
#declare UseColors=no;

#declare ColorsAmnt=100;

//----
#debug concat("\n",str(TriangleAmnt.u*TriangleAmnt.v*2,0,0)," triangles\n")

camera { location <0,20,-50>/2 look_at 0 angle 35 }
light_source { <1000,500,-2000> 1 }
light_source { <-1000,500,0> x+y }

#if(UseColors)
  #declare Colors=array[ColorsAmnt]
  #declare Ind=0;
  #declare R=seed(0);
  #while(Ind<ColorsAmnt)
    #declare Colors[Ind]=texture { pigment { rgb <rand(R),rand(R),rand(R)> } }
    #declare Ind=Ind+1;
  #end
#end

#declare MeshWidth=5;
#declare MeshHeight=10;
#if(UseUnion)
union
#else
mesh
#end
{ #declare Ang=0;
  #while(Ang<360)
    #declare y1Coord=-MeshHeight/2;
    #while(y1Coord<MeshHeight/2)
      #declare x1Coord=MeshWidth*sin(radians(Ang));
      #declare x2Coord=MeshWidth*sin(radians(Ang+360/TriangleAmnt.v));
      #declare y2Coord=y1Coord+MeshHeight/TriangleAmnt.u;
      #declare z1Coord=MeshWidth*cos(radians(Ang));
      #declare z2Coord=MeshWidth*cos(radians(Ang+360/TriangleAmnt.v));
      #if(SmoothTriangles)
        smooth_triangle
        { <x1Coord,y1Coord,z1Coord>,<x1Coord,0,z1Coord>,
          <x2Coord,y1Coord,z2Coord>,<x2Coord,0,z2Coord>,
          <x1Coord,y2Coord,z1Coord>,<x1Coord,0,z1Coord>
          #if(UseColors)
            texture { Colors[int(rand(R)*ColorsAmnt)] }
          #end
        }
        smooth_triangle
        { <x2Coord,y2Coord,z2Coord>,<x2Coord,0,z2Coord>,
          <x2Coord,y1Coord,z2Coord>,<x2Coord,0,z2Coord>,
          <x1Coord,y2Coord,z1Coord>,<x1Coord,0,z1Coord>
          #if(UseColors)
            texture { Colors[int(rand(R)*ColorsAmnt)] }
          #end
        }
      #else
        triangle
        { <x1Coord,y1Coord,z1Coord>,<x2Coord,y1Coord,z2Coord>
          <x1Coord,y2Coord,z1Coord>
          #if(UseColors)
            texture { Colors[int(rand(R)*ColorsAmnt)] }
          #end
        }
        triangle
        { <x2Coord,y2Coord,z2Coord>,<x2Coord,y1Coord,z2Coord>
          <x1Coord,y2Coord,z1Coord>
          #if(UseColors)
            texture { Colors[int(rand(R)*ColorsAmnt)] }
          #end
        }
      #end
      #declare y1Coord=y1Coord+MeshHeight/TriangleAmnt.u;
    #end
    #declare Ang=Ang+360/TriangleAmnt.v;
  #end
  
  #if(!UseColors)
    pigment { rgb 1 }
  #end
}

--------------------------------------------------------------------------

  These were the results:

- Test 1: 54 triangles.
  --------------------

#declare TriangleAmnt=<3,9>;
#declare UseUnion=no;
#declare SmoothTriangles=no;
#declare UseColors=no;

Time For Trace:    0 hours  0 minutes  24.0 seconds (24 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  0 minutes   1.0 seconds (1 seconds)
Time For Trace:    0 hours  0 minutes  20.0 seconds (20 seconds)

- Test 2: 600 triangles.
  ---------------------

#declare TriangleAmnt=<10,30>;
#declare UseUnion=no;
#declare SmoothTriangles=no;
#declare UseColors=no;

Time For Parse:    0 hours  0 minutes   3.0 seconds (3 seconds)
Time For Trace:    0 hours  0 minutes  29.0 seconds (29 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  0 minutes   3.0 seconds (3 seconds)
Time For Trace:    0 hours  0 minutes  26.0 seconds (26 seconds)

#declare UseUnion=no;
#declare SmoothTriangles=yes;

Time For Parse:    0 hours  0 minutes   3.0 seconds (3 seconds)
Time For Trace:    0 hours  0 minutes  29.0 seconds (29 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  0 minutes   4.0 seconds (4 seconds)
Time For Trace:    0 hours  0 minutes  28.0 seconds (28 seconds)

#declare UseUnion=no;
#declare UseColors=yes;

Time For Parse:    0 hours  0 minutes   4.0 seconds (4 seconds)
Time For Trace:    0 hours  0 minutes  31.0 seconds (31 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  0 minutes   4.0 seconds (4 seconds)
Time For Trace:    0 hours  0 minutes  29.0 seconds (29 seconds)

- Test 3: 15000 triangles.
  -----------------------

#declare TriangleAmnt=<50,150>;
#declare UseUnion=no;
#declare SmoothTriangles=no;
#declare UseColors=no;

Time For Parse:    0 hours  1 minutes   5.0 seconds (65 seconds)
Time For Trace:    0 hours  0 minutes  33.0 seconds (33 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  1 minutes   8.0 seconds (68 seconds)
Time For Trace:    0 hours  0 minutes  38.0 seconds (38 seconds)

#declare UseUnion=no;
#declare SmoothTriangles=yes;

Time For Parse:    0 hours  1 minutes  11.0 seconds (71 seconds)
Time For Trace:    0 hours  0 minutes  33.0 seconds (33 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  1 minutes  14.0 seconds (74 seconds)
Time For Trace:    0 hours  0 minutes  44.0 seconds (44 seconds)

#declare UseUnion=no;
#declare UseColors=yes;

Time For Parse:    0 hours  1 minutes  14.0 seconds (74 seconds)
Time For Trace:    0 hours  0 minutes  35.0 seconds (35 seconds)

#declare UseUnion=yes;

Time For Parse:    0 hours  1 minutes  19.0 seconds (79 seconds)
Time For Trace:    0 hours  0 minutes  45.0 seconds (45 seconds)

- Test 4: 102000 triangles.
  ------------------------

#declare TriangleAmnt=<150,340>;
#declare UseUnion=no;
#declare SmoothTriangles=no;
#declare UseColors=yes;

Time For Parse:    0 hours  8 minutes  13.0 seconds (493 seconds)
Time For Trace:    0 hours  0 minutes  36.0 seconds (36 seconds)
Peak memory used:         13636712 bytes

#declare UseUnion=yes;

Time For Parse:    0 hours 19 minutes  47.0 seconds (1187 seconds)
Time For Trace:    0 hours  2 minutes  34.0 seconds (154 seconds)
Peak memory used:         70480190 bytes


-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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