POV-Ray : Newsgroups : povray.general : Does layout of triangles affect rendering speed in mesh(2) : Does layout of triangles affect rendering speed in mesh(2) Server Time
4 Aug 2024 20:13:46 EDT (-0400)
  Does layout of triangles affect rendering speed in mesh(2)  
From: idoit
Date: 18 Feb 2003 06:00:09
Message: <web.3e520f0043a9002e5a561bd30@news.povray.org>
Hi,

I'm generating rather large (40 Mb) meshes that consist of transparent and
abient triangles.

As I have limited (280 Mb) of memory in my mashine, it seems like the
computer starts to swap when the generated picture has certain properties.
Please see the "resulting" image below (best viewed in monspace) - the
charactes are actually many small trianges.


      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                                   yyyyyyyyyyyyyy
                                     yyyyyyyyyy
                                       yyyyy
                                        yyy

When rendering the X's the rendering of the picture almost halts (PovRay
gets about 10% of CPU usage at best). When the tracing of the picture
reaches the y's CPU usage is about 90% and rendering goes considerably
faster. I suspect this has to do with how the triangles are layed out
in memory.

Currently my mesh generator lays out the mesh as follows:
#declare triangles = mesh2 {
  vertex_vectors {
    468028,
    <-966, 0.644779, 0>, <-965, 0.644779, 0>, <-964, 0.654999, 0>, .......
    <-965, 0.644779, 1>, <-964, 0.649919, 1>, <-963, 0.648213, 1>, .......
    ........
    <0, 0.644779, 900>, <0, 0.644779, 900>, <0, 0.654999, 900>
    // The X-axis is varied first, then the Z-axis
    .......
   }
  face_indices {
    933156,
    <0, 1, 967>, <967, 1, 968>, <1, 2, 968>, <968, 2, 969>, <2, 3, 969>,
    .......
}


Could someone with intimate knowledge of the PovRay mesh data structures
or other relevant experiences advise me if rendering speed could be
improved by laying out the vertex vectors by iterating over the Z-axis
values first and keeping the X-axis constan as far as possible.

I.E. in pseudo code change:
for (z = 0; z < z_max; z++) for (x = 0; x < x_max; x++)  { print (<x,y,z>)}
to
for (x = 0; x < x_max; z++) for (z = 0; z < z_max; z++)  { print (<x,y,z>,)}

- or is the rendering speed affecte by how face indices are layed out
(not so simple to give an example, but i gues that the layout possibly also
should follow the principles laid out above.
Imporant to know is that the (orthographic) camera is facing parallell with
the Z-axis.

It is of course possible to try different aproaches and change the generator
of the trinagle mesh, but the algorithm is quite involved, and it would save
me a lot of work if someone could, if describe an exact method to lay out
the triangles, atleast give me a hint on what steps (if any!) could be taken
to improve rendering speed when generating meshes.

I will be glad to report my findings, or summarize any result (I will also
report if nothing, other than bying more memory, can be done) and would
allready now like to extend my thanks in advance if someone gives me advice
on how to improve rendering speed.

Also if anything is unclear - don't hesitate to ask (explaining
pictures in 3D is not that easy -  and I may have left out some
crucial information considered "obvious").


Best regards

Jan


Post a reply to this message

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