POV-Ray : Newsgroups : povray.newusers : a realistic algorithm for making a tree Server Time
27 Nov 2024 15:43:12 EST (-0500)
  a realistic algorithm for making a tree (Message 1 to 6 of 6)  
From: Justin Smith
Subject: a realistic algorithm for making a tree
Date: 14 Oct 2002 00:25:03
Message: <web.3daa4414952fe8767dde8b6f0@news.povray.org>
I'm trying to figure out how to code the trunk and branching structure of a
normal deciduous tree. I took a look at some of the existing trees out
there, and it seems that using blobs is the way to go. I think I want to
use an isosurface with blob-like combinations, so that I can use a pigment
with the function to easily roughen the surface of it.

Well, there is a point to this post. I am stuck on a few things, so I want
to ask for some suggestions:

What is a good size for the individual pieces of the iso-blob relative to
the width of the trunk?

When I get to a fork in a branch, and have it go calculate one path off the
fork, how do I get it to go back to the fork to draw the other branch?
(This is the part I am the most confused over, and it seems even more
difficult when I get to the end of a branch that may be 4 or 5 "levels of
forks" down from the main trunk.)

When I add leaves, how can I place them to be relative to where the branches
are? (I'm not going to know ahead of time where the branches end, since
that'll be up to random variables, so that I can use this to create several
trees in the same scene that aren't the same).

I know there are existing tree macros out there, but I'm just the sort that
likes to make my own stuff.

Also, I am trying to get a feel for using blob-like combinations in an
isosurface, but the following code won't work. What am I doing wrong?

isosurface
{
  #declare Blob_Threshold = .05;
  #declare iter = 0;
  function
  {
    (1+Blob_Threshold)
    #while(iter < 50)
 -pow(Blob_Threshold,f_sphere(x-(rand(Seed)+.5),y-(iter/2),z-(rand(Seed)+.5),.3))
      #declare iter = iter + 1;
    #end
  }
  contained_by { box { -30,30 } }
  max_gradient 2.4
  texture
  {
    pigment
    {
      color rgb .9
    }
  }
}


Post a reply to this message

From: Tim Nikias
Subject: Re: a realistic algorithm for making a tree
Date: 14 Oct 2002 01:17:45
Message: <3daa5379@news.povray.org>
Regarding your iso, I can't help. Have no clue of
them yet as well.

Regarding your scripting of trees:
In order to make branches, you could use loops. Determine
(using some random value) how many branches you want,
and then run a loop with some parameters that "memorize"
the forking position and width at that point, perhaps even
the direction of the tree there.

Another approach would be using recursive macros, which
are designed to call themselves, if another set of branches is
to be made. I guess this would be the easiest approach,
cause I'm not too sure how to set up the above mentioned loops
to cover branches up to X-number of depth.

When using both these approaches, all you need to know, is
when you're placing your last branches, you'll want to stick
the leaves to those. For the recursion approach, just check in
which depth you're calculating, and then use the appropriate
depth. For the loops, its just about the same.

And if this is just way ahead of you (if you don't have a
clue what I'm talking about with loops and recursion etc) I
suggest you download some of those tree-programms and
look at their code to learn. Its good reference, and its a
working example (which I couldn't cook up right at this
moment without writing my own tree generator).

Regards,
Tim


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde

> I'm trying to figure out how to code the trunk and branching structure of
a
> normal deciduous tree. I took a look at some of the existing trees out
> there, and it seems that using blobs is the way to go. I think I want to
> use an isosurface with blob-like combinations, so that I can use a pigment
> with the function to easily roughen the surface of it.
>
> Well, there is a point to this post. I am stuck on a few things, so I want
> to ask for some suggestions:
>
> What is a good size for the individual pieces of the iso-blob relative to
> the width of the trunk?
>
> When I get to a fork in a branch, and have it go calculate one path off
the
> fork, how do I get it to go back to the fork to draw the other branch?
> (This is the part I am the most confused over, and it seems even more
> difficult when I get to the end of a branch that may be 4 or 5 "levels of
> forks" down from the main trunk.)
>
> When I add leaves, how can I place them to be relative to where the
branches
> are? (I'm not going to know ahead of time where the branches end, since
> that'll be up to random variables, so that I can use this to create
several
> trees in the same scene that aren't the same).
>
> I know there are existing tree macros out there, but I'm just the sort
that
> likes to make my own stuff.
>
> Also, I am trying to get a feel for using blob-like combinations in an
> isosurface, but the following code won't work. What am I doing wrong?
>
> isosurface
> {
>   #declare Blob_Threshold = .05;
>   #declare iter = 0;
>   function
>   {
>     (1+Blob_Threshold)
>     #while(iter < 50)
>  -pow(Blob_Threshold,f_sphere(x-(rand(Seed)+.5),y-(iter/2),z-(rand(Seed)+.
5),.3))
>       #declare iter = iter + 1;
>     #end
>   }
>   contained_by { box { -30,30 } }
>   max_gradient 2.4
>   texture
>   {
>     pigment
>     {
>       color rgb .9
>     }
>   }
> }
>
>


Post a reply to this message

From: Warp
Subject: Re: a realistic algorithm for making a tree
Date: 14 Oct 2002 01:57:06
Message: <3daa5cb2@news.povray.org>
Justin Smith <t74### [at] yahoocom> wrote:
> I'm trying to figure out how to code the trunk and branching structure of a
> normal deciduous tree. I took a look at some of the existing trees out
> there, and it seems that using blobs is the way to go. I think I want to
> use an isosurface with blob-like combinations, so that I can use a pigment
> with the function to easily roughen the surface of it.

  Well, if you have a couple of months of spare time to wait for the
render to finish... why not? ;)

  Really, I don't understand why blobs would be the way to go in order to
create trees. In order to make a tree which looks real, you need hundreds
of thousands of small details (leaves, branches, etc). If you make a blob
or isosurface with hundreds of thousands of components, then you'd better
have months of spare time...

  The classical and best approach is to use a triangle mesh. A mesh can
have all the details you need (thousands, hundreds of thousands, millions
of triangles) while still being quite fast and efficient.
  As a bonus, if you copy the tree several times into the scene, it will
take only the memory needed for one tree.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Justin Smith
Subject: Re: a realistic algorithm for making a tree
Date: 14 Oct 2002 02:40:04
Message: <web.3daa65f2d5efdad77dde8b6f0@news.povray.org>
Warp wrote:
>Justin Smith <t74### [at] yahoocom> wrote:
>> I'm trying to figure out how to code the trunk and branching structure of a
>> normal deciduous tree. I took a look at some of the existing trees out
>> there, and it seems that using blobs is the way to go. I think I want to
>> use an isosurface with blob-like combinations, so that I can use a pigment
>> with the function to easily roughen the surface of it.
>  Really, I don't understand why blobs would be the way to go in order to
>create trees. In order to make a tree which looks real, you need hundreds
>of thousands of small details (leaves, branches, etc). If you make a blob
>or isosurface with hundreds of thousands of components, then you'd better
>have months of spare time...

Hm. The reason I decided on blobs is that that is what the other
tree-generators I found use. I figured they'd go with a mesh or an
isosurface, but they went with blobs.

The leaves are not part of the blob, btw... separate triangle-based objects.

>  The classical and best approach is to use a triangle mesh. A mesh can
>have all the details you need (thousands, hundreds of thousands, millions
>of triangles) while still being quite fast and efficient.
>  As a bonus, if you copy the tree several times into the scene, it will
>take only the memory needed for one tree.

Thank you for the suggestion, I may end up doing that if I can't get
something satisfactory out of this.


Post a reply to this message

From: Christoph Hormann
Subject: Re: a realistic algorithm for making a tree
Date: 14 Oct 2002 04:11:51
Message: <3DAA7C46.7F95EB5F@gmx.de>
Justin Smith wrote:
> 
> I'm trying to figure out how to code the trunk and branching structure of a
> normal deciduous tree. I took a look at some of the existing trees out
> there, and it seems that using blobs is the way to go. 
> [...]

Why do you think so?

Meshes are surely the most efficient way to generate trees.  Surely not
the most realistic, but you won't be able to generate a tree rendering in
agreeable time with isosurfaces anyway.

> Also, I am trying to get a feel for using blob-like combinations in an
> isosurface, but the following code won't work. What am I doing wrong?
> 
> [...]

Try:

isosurface
{
  #declare Blob_Threshold = .05; 
  #declare Seed=seed(0);
  #declare iter = 0;
  function
  {
    (1+Blob_Threshold)
    #while(iter < 50)   
      #declare Rnd1=rand(Seed);
      #declare Rnd2=rand(Seed);    
    
      -pow(Blob_Threshold,f_sphere(x-(Rnd1+.5),y-(iter/2),z-(Rnd2+.5),.3))
      #declare iter = iter + 1;
    #end
  }
  contained_by { box { -30,30 } }
  max_gradient 2.4
}

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Tom Melly
Subject: Re: a realistic algorithm for making a tree
Date: 15 Oct 2002 04:50:07
Message: <3dabd6bf$1@news.povray.org>
Justin,

You'll find a tree-generation macro included with:
http://www.tomandlu.co.uk/webres/raytracing/gallery/tmwinter.zip

This was used to create the tree in:
http://www.tomandlu.co.uk/webres/raytracing/gallery/pics/tmwinter.jpg

No leaves, I'm afraid, but it wouldn't be too hard to add them.

The approach I used was basically:

Generate a single branch by joining together blob components.

Whenever you generate a component, generate a random number and use to decide
whether to fork or not

If fork, then place the current vector in an array, and increase a pointer to
keep track of how many branch vectors there are.

If unprocessed branches exist, create a new branch starting from the stored
vector.


Post a reply to this message

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