|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi, I am trying to build a scene with many trees though many of the trees can be
the same just rotated or scaled slightly. My current setup is as follows
#declare leaf1 = mesh { smooth_triangle ... }
#declare leaf2 = mesh { smooth_triangle ... }
#declare tree = object { union {
mesh { triangles for a branch }
mesh { triangles for another branch}
.... // for all branches
object { object { object { leaf1 scale<x,y,z> } matrix ...} translate<x,y,z> }
object { object { object { leaf2 scale<x,y,z> } matrix ...} translate<x,y,z> }
.... // continues for all leaves
}
translate<x,y,z> // to place the base of the model at <0,0,0>
scale<x,y,z> // to adjust the size of the model
}
Then in my program I instance this tree object many times with
object { tree scale<x,y,z> rotate<x,y,z> translate<x,y,z> }
But this causes POV-ray to run out of memory very quickly so I don't think this
is instancing the geometry properly.
From reading the manual it says that mesh's can be instanced but is it because I
have a bunch of mesh's in a union that this does not work?
Is the only solution to this to make one massive mesh which has all branch
geometry and all leaf geometry inside it and then instance that?
Thanks
-Steve
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
slongay <slo### [at] gmailcom> wrote:
> Is the only solution to this to make one massive mesh which has all branch
> geometry and all leaf geometry inside it and then instance that?
The larger the single mesh, the more memory savings when you copy that
mesh.
If you want to instance humongous amounts of such meshes, you should try
to make them as big as possible (ie. put as many of the triangles of the
model inside a single mesh as possible). That doesn't necessarily mean that
you must put your entire tree inside one single mesh, but you could for
example create an entire branch (with hundreds of leaves) as a single mesh
and then copy that around. (You could create different branches to get
variety, and copy them.)
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
slongay wrote:
> Hi, I am trying to build a scene with many trees though many of the trees can be
> the same just rotated or scaled slightly. My current setup is as follows
>
> #declare leaf1 = mesh { smooth_triangle ... }
> #declare leaf2 = mesh { smooth_triangle ... }
>
> #declare tree = object { union {
> mesh { triangles for a branch }
> mesh { triangles for another branch}
> .... // for all branches
> object { object { object { leaf1 scale<x,y,z> } matrix ...} translate<x,y,z> }
> object { object { object { leaf2 scale<x,y,z> } matrix ...} translate<x,y,z> }
> .... // continues for all leaves
> }
> translate<x,y,z> // to place the base of the model at <0,0,0>
> scale<x,y,z> // to adjust the size of the model
> }
>
>
> Then in my program I instance this tree object many times with
>
> object { tree scale<x,y,z> rotate<x,y,z> translate<x,y,z> }
>
> But this causes POV-ray to run out of memory very quickly so I don't think this
> is instancing the geometry properly.
>
> From reading the manual it says that mesh's can be instanced but is it because I
> have a bunch of mesh's in a union that this does not work?
>
> Is the only solution to this to make one massive mesh which has all branch
> geometry and all leaf geometry inside it and then instance that?
>
> Thanks
> -Steve
>
>
>
Funny you should ask about mesh trees. I'm just about finished making my
own POV tree generator. And I use one 'massive' mesh2 for the Tree and
one for the Leafs. That really doesn't bother me. In my earlier attempts
I used a 'mesh' with 'smooth_triangle' as you have. But I dropped them
because they where not flexible enough and kind of hard to work with.
Sense it seems you have a good looking tree using them, my hat is off to ya.
Now on to your problem. But, first some questions.
(1) How many different trees do you have?
(2) How detailed are they?
(3) How many are you planing to place?
Here's my shot in the dark:
(1) You probably need at least two different trees if your placing a lot.
I've done a forest seen from far away and used several.
Scaling and rotation only goes so far in making a tree look
different.
(2) The farther away a tree is the less detail it has to have.
If it's real far some times all it needs is its leafs.
(3) The number of trees you want to place and the number of trees that
will fill the space may be different.
But I ramble.
If you like I'll put My tree generator in P.B.utilities
along with a test scene in p.b.scene_files
Have Fun!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it slongay who wrote:
>Hi, I am trying to build a scene with many trees though many of the
>trees can be
>the same just rotated or scaled slightly. My current setup is as follows
>
>#declare leaf1 = mesh { smooth_triangle ... }
>#declare leaf2 = mesh { smooth_triangle ... }
>
>#declare tree = object { union {
>mesh { triangles for a branch }
>mesh { triangles for another branch}
>.... // for all branches
>object { object { object { leaf1 scale<x,y,z> } matrix ...} translate<x,y,z> }
>object { object { object { leaf2 scale<x,y,z> } matrix ...} translate<x,y,z> }
>.... // continues for all leaves
>}
>translate<x,y,z> // to place the base of the model at <0,0,0>
>scale<x,y,z> // to adjust the size of the model
>}
>
>
>Then in my program I instance this tree object many times with
>
>object { tree scale<x,y,z> rotate<x,y,z> translate<x,y,z> }
>
>But this causes POV-ray to run out of memory very quickly so I don't think this
>is instancing the geometry properly.
>
>From reading the manual it says that mesh's can be instanced but is it
>because I
>have a bunch of mesh's in a union that this does not work?
>
>Is the only solution to this to make one massive mesh which has all branch
>geometry and all leaf geometry inside it and then instance that?
Paul T. Dawson released the wonderful meshtree.inc back in 1999, which
creates a tree as one large mesh. It was fast and memory efficient on
1999 hardware. On modern computers it's blindingly fast. There's a demo
scene that comes with it that plots 999 copies of a moderately detailed
tree. On my machine it takes 4 seconds to parse and uses a peak memory
of 9.7 Mb. It might be worth taking a look at how he did that.
It may well be possible to do it slightly more simply now that POVRay
has mesh2.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks for the replies. I will try a few of those solutions and get back to you
with the results.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
So I tried combining my trees into two big meshes, one for the leaves and one
for the branches.
This works, but I have to say that it is really quite ugly. The leaves are one
of three meshes but transformed differently. So when I roll out my leaves into
one big mesh I have to transform the triangles for each leaf and write them our
one by one. The file which contains my leaf mesh ends up being 841mb for an
average sized tree! Obviously I have some optimizing I can do, it takes POVRay
27 minutes just to parse the file, but it only takes up 545mb in memory once
parsed.
But I guess my real question is: Is there any way to do a hierarchical
instancing in POVray? So I can just declare my leaf mesh's and then say where
they are in the scene with-out having to combine them all into one big mesh? I
believe you guys have already said no but I just wanted to rephrase my question
to be sure.
Thanks
-Steve
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"slongay" <slo### [at] gmailcom> wrote in message
news:web.48f8150ade4da0652ebc1c00@news.povray.org...
> So I tried combining my trees into two big meshes, one for the leaves and
> one
> for the branches.
>
> This works, but I have to say that it is really quite ugly. The leaves are
> one
> of three meshes but transformed differently. So when I roll out my leaves
> into
> one big mesh I have to transform the triangles for each leaf and write
> them our
> one by one. The file which contains my leaf mesh ends up being 841mb for
> an
> average sized tree! Obviously I have some optimizing I can do, it takes
> POVRay
> 27 minutes just to parse the file, but it only takes up 545mb in memory
> once
> parsed.
>
> But I guess my real question is: Is there any way to do a hierarchical
> instancing in POVray? So I can just declare my leaf mesh's and then say
> where
> they are in the scene with-out having to combine them all into one big
> mesh? I
> believe you guys have already said no but I just wanted to rephrase my
> question
> to be sure.
You can separate out the definition of your leaf coordinates from the mesh
declaration, which seems to me to give you the best of both worlds. You get
a clean, small scene file where you define your leaf shapes and normals and
you get the speed of using a mesh, without large amounts of IO to perform.
The following example declares two leaf shapes as arrays of coordinate pairs
(Vertices and Normals).
The mesh definition selects randomly between the two available leaves and
calls a macro to add the necessary number of smooth triangles, scaling,
rotating and translating the leaves into position (into a random position in
this case).
I should mention that this scene file is just intended to illustrate the way
you could code stuff and I know that the rendered image looks nothing much
like a tree :-). With 100,000 leaves this took about 30 minutes to render on
a 4-way 2.3GHz machine and with 1000 leaves just a few seconds.
Regards,
Chris B.
camera {location <0,5,-1> look_at 0}
light_source {<-10,50,-10>, rgb 1}
#declare Leaves = 1000;
#declare MySeed = seed(1);
#declare Leaf1 = array[6][3] {
{0,0,0},{0,1,0},
{0,0,1},{0,1,0},
{1,0,0},{0,1,0}
};
#declare Leaf2 = array[12][3] {
{0,0,0},{0,1,0},
{0,0,1},{0,1,0},
{1,0,1},{0,1,0},
{0,0,0},{0,1,0},
{1,0,1},{0,1,0},
{1,0,0},{0,1,0}
};
#macro DrawLeaf (Leaf)
#declare Rotation = <rand(MySeed),rand(MySeed),rand(MySeed)>*360;
#declare Translation = <rand(MySeed),rand(MySeed),rand(MySeed)>-0.5;
#declare Scale = <rand(MySeed),rand(MySeed),rand(MySeed)>*0.1+1;
#local J = 0;
#while (J<dimension_size(Leaf,1)/6)
smooth_triangle {
#local K = 0;
#while (K<3)
#declare Vertex =
<Leaf[J*6+K*2][0],Leaf[J*6+K*2][1],Leaf[J*6+K*2][2]>;
#declare Normal =
<Leaf[J*6+K*2+1][0],Leaf[J*6+K*2+1][1],Leaf[J*6+K*2+1][2]>;
#declare Vertex = vrotate(Vertex*Scale,Rotation)+Translation;
#declare Normal = vrotate(Normal,Rotation);
Vertex Normal
#local K = K + 1;
#end
}
#local J = J+1;
#end
#end
#declare Tree = mesh {
#local I = 0;
#while (I<Leaves)
#if (rand(MySeed)<0.5) DrawLeaf(Leaf1)
#else DrawLeaf(Leaf2)
#end
#local I = I+1;
#end
pigment {rgb <0,1,0>}
}
object {Tree}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|