POV-Ray : Newsgroups : povray.advanced-users : Povtree macro (mesh created at parsing whith loops) seems to waste memory : Re: Povtree macro (mesh created at parsing whith loops) seems towaste memo= Server Time
19 Apr 2024 16:49:28 EDT (-0400)
  Re: Povtree macro (mesh created at parsing whith loops) seems towaste memo=  
From: Warren
Date: 21 Jul 2018 12:15:00
Message: <web.5b535bf878ec913520df21d60@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> On 21-7-2018 12:31, clipka wrote:
> > Am 21.07.2018 um 11:46 schrieb Warren:
> >
> >> - If I stick to the TOMTREE-1.5.inc file and choose not to generate a mesh file
> >> with povtree , I get a CSG object , i.e, a union of blob and mesh (only the
> >> leaves are meshes; the trunk, twigs, branches and ramifications are blob of
> >> spheres (no cylinders, but that's a detail). And there can be height fields too
> >> (though I'm not sure), there are height fields objects in 'TOMLEAF.inc' which is
> >> a file used with TOMTREE-1.5.inc.
>
> In TOMtree, leaves can be defined as height_fields instead of spheres. I
> /think/ this can be defined also in POVtree but I seem to remember (it's
> been a long time since I last used the program) that this generates an
> error. Never corrected at the time, /if/ it was ever reported to Gena
> Obukhov...
>
> > ...
> >> But Clipka said that blobs, height fileds and meshes share their bulk data among
> >> copies. So, if I understand that the CSG mesh file that contains FOLIAGE and
> >> WOOD is not copied each time a new sample of it is created, why is this not the
> >> case of the CSG object generated by TOMTREE-1.5.inc ?
> >
> > You say that "the leaves are meshes"; if by that you mean that there is
> > a leaf mesh, and the foliage of a single tree is multiple copies of that
> > mesh, that does explain the symptoms.
>
> When the tree is exported as a mesh, FOLIAGE is a mesh{} of /all/ the
> leaves of the tree, not individual meshes for each leaf.
>
> >
> > While meshes do share their bulk data when copied, they each carry their
> > own individual overhead, which is heavier than one might think.
> >
> > If you use one mesh per leaf, you have a lot of overhead per triangle in
> > the mesh, and thus the data sharing reduces the memory footprint only by
> > a marginal fraction.
>
> Not the case with POVtree (see above).
>
> >
> > If instead of one mesh per leaf you use one huge mesh for the entire
> > foliage of the tree, you only have one instance of the overhead. You do
> > have much more bulk data, and unless the leaf mesh is trivially simple
> > this may actually leave you with a larger total memory footprint for a
> > single tree; but as soon as you create multiple instances of that tree,
> > the impact of the bulk data on the total memory footprint quickly
> > diminishes.
> >
>
> That is what happens with POVtree meshes indeed.
>
> >
> >> The CSG object generated by TOMTREE-1.5.inc (from Tom Aust) is a 'compound'
> >> object. That means it is a 'mix' of several different objects, which explains
> >> like clipka said that it is an object that is therefore copied each time you
> >> create a new sample of it ?
> >> Whereas the object that is a union of WOOD and FOLIAGE is not a 'compound'
> >> object, that's a mesh even if there is a union of these two meshes.
> >>
> >> Is this the cornerstone that explains that one is copied and the other not?
> >
> > The term "compound object" in the context of POV-Ray is typically used
> > in the sense of "non-primitive", i.e. an object that is comprised of
> > other objects. Whether the members of such compound object are of same
> > type or different types is irrelevant, as there's no special processing
> > happening in same-type cases.
> >
>
>
> --
> Thomas

I said that there is an individual mesh for a leaf sample, that's because the
content of my tree parameter kapokTree.tree is like this (an excerpt):

//--------------------------------------------------------
//BARK
#declare SUNKEN_TRUNK_COLOR=<0.4609, 0.4726, 0.4257>;
#declare RAISED_TRUNK_COLOR=<0.375, 0.3359, 0.2892>;
#declare FOLIAGE_COLOR_AT_BRANCH_END=0;
#declare TRUNK_SCAR_WIDTH=1;
#declare TRUNK_SCAR_HEIGHT=5;
#declare HORIZONTAL_SCAR_SHRINKING=0.3;
#declare VERTICAL_SCAR_SHRINKING=1.5;
#declare SCAR_DEPTH=-1;
#declare BARK_PROFILE=0;
#declare BRANCH_BARK_PROFILE_CHANGE=0;
#declare BRANCH_BARK_PROFILE_TAPER_OFF=1;
#declare ROOT_BARK_PROFILE_CHANGE=0;
#declare PALM_TRUNK=0;
//FOLIAGE
#include "povtree/TOMLEAF.inc"
#declare Mesh6a = mesh {
 triangle{<0.35, 0.05, 0.5>, <0.6, 0.0, 0.5>, <0.0, 0.0, 2.9802322E-8>}
 triangle{<0.6, 0.0, 0.5>, <0.55, 0.05, 0.25>, <0.0, 0.0, 2.9802322E-8>}
 triangle{<0.0, 0.0, 2.9802322E-8>, <0.75, 0.05, 0.19999999>, <1.0, 0.0, 0.0>}
 triangle{<0.0, 0.0, 2.9802322E-8>, <0.75, 0.05, -0.19999999>, <1.0, 0.0, 0.0>}
 triangle{<0.0, 0.0, 2.9802322E-8>, <0.54999995, 0.05, -0.25>, <0.59999996, 0.0,
-0.5>}
 triangle{<0.0, 0.0, 2.9802322E-8>, <0.34999996, 0.05, -0.5>, <0.59999996, 0.0,
-0.5>}
};
#declare LEAF_TYPE=Mesh6a;
#declare LEAVES=75*BUNCHES;
#declare LEAF_LENGTH=15;
#declare LEAF_BREADTH=10;
#declare LEAF_HEIGHT=2;
#declare MAX_LEAF_TILT=30;
#declare MAX_LEAF_TURN=30;
#declare LEAF_INCLINATION=60.0;
#declare LEAF_INCLINATION_SCOPE=10;
#declare BOTTOM_COLOR_1=<0.3, 0.54, 0.18, 0.0, 0.0>;
#declare BOTTOM_COLOR_2=<0.3, 0.54, 0.18, 0.0, 0.0>;
#declare TOP_COLOR_1=<0.3, 0.54, 0.18, 0.0, 0.0>;
#declare TOP_COLOR_2=<0.3, 0.54, 0.18, 0.0, 0.0>;
#declare COLOR_TURB=0.5;
#declare TRANSITION_BOTTOM_TOP=0.5;
#declare TRANSITION_TURB=0.5;
#declare FOLIAGE_GLOSS=0.1;
#declare FOLIAGE_FILTER=0.0;
#declare FOLIAGE_TRANSPARENCY=0.0;
//BLOSSOM
#declare BlossomMesh5 = mesh {
 triangle{<0.2, 0.0, 0.0>, <0.29999998, 0.34471983, 0.41372478>, <0.29999998,
-0.035702735, 0.53733164>}
 triangle{<0.2, 0.0, 0.0>, <0.29999998, -0.2869514, 0.45569602>, <0.3,
-0.5220655, 0.13208927>}
 triangle{<0.2, 0.0, 0.0>, <0.3, -0.5220655, -0.13208918>, <0.3, -0.28695148,
-0.45569602>}
 triangle{<0.2, 0.0, 0.0>, <0.3, -0.035702825, -0.53733164>, <0.3, 0.3447198,
-0.41372487>}
 triangle{<0.2, 0.0, 0.0>, <0.3, 0.5, -0.2>, <0.3, 0.5, 0.2>}
};
#declare BLOSSOM=BlossomMesh5;
#declare BLOSSOMS=0*BUNCHES;
#declare BLOSSOM_LENGTH=20;
#declare BLOSSOM_WIDTH=20;
#declare BLOSSOM_INCLINATION=0;
#declare BLOSSOM_COLOR=<1, 1, 1>;

//---------------------
But like you said, the leaf sample mesh must take some transforms , probably
lots of translations and rotates , that's why you don't retrieve it's original
mesh (the numbers) in the final mesh. I do agree with you. ;-)


Post a reply to this message

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