POV-Ray : Newsgroups : povray.general : mesh vs. union of triangles speed comparison Server Time
2 Nov 2024 01:19:13 EDT (-0400)
  mesh vs. union of triangles speed comparison (Message 1 to 4 of 4)  
From: Nieminen Mika
Subject: mesh vs. union of triangles speed comparison
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

From: Nieminen Mika
Subject: Re: mesh vs. union of triangles speed comparison
Date: 20 Jun 1999 07:18:40
Message: <376cce10@news.povray.org>
Nieminen Mika <war### [at] cctutfi> wrote:
:   With a relative small amount of triangles (a few thousands) the union is

  I meant a few hundreds.


-- 
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

From: Ken
Subject: Re: mesh vs. union of triangles speed comparison
Date: 21 Jun 1999 01:36:27
Message: <376DCF1C.9BD5D2A0@pacbell.net>
Nieminen Mika wrote:
> 
>   As a result of a discussion about rendering speed of meshes and unions of
> triangles, I made this test.
> 
>   * The result:

  I question the validity of your test results. Not for the reporting
of the final results as I am sure you have reported them accurately but
the method used to obtain them is in doubt.
  When I ran my test I was using physically based text files filled
with triangles. Yours triangles were produced using while loops. I
personally think that using the program to produce the triangle union/
mesh object can and will directly affect the speed of processing the
file in both parsing times and calculation times. Simply reading a
text file and computing the position of each triangle will impact the
results much less.
  Am I correct in these assumptions or should I go bury my head
somewhere ?

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Nieminen Mika
Subject: Re: mesh vs. union of triangles speed comparison
Date: 21 Jun 1999 02:18:51
Message: <376dd94b@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
:   Am I correct in these assumptions or should I go bury my head
: somewhere ?

  The while loops cause an increase in parsing time which is exactly equal
for both methods (mesh or union). The difference in parsing time comes
_after_ the while loops are done. So it doesn't matter how long they parse,
but the difference between the parsing times is important. Thus, if for
example the union parses 2 seconds slower than the mesh, that's exactly
how much longer the union takes to parse no matter if the triangles are
precalculated or not (as long as the amount of them is the same).
  And of course the while loops do not affect the trace time in any way.
  So in my opinion the test is completely valid.

-- 
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.