Planetside Software Forums

General => Terragen Discussion => Topic started by: bigben on October 25, 2008, 01:00:43 AM

Title: Growing leaves
Post by: bigben on October 25, 2008, 01:00:43 AM
I've had this idea for a while, so it's about time I finished it off.

I've started rendering a short animation that will simulate the growht of leaves on a tree.  The method is realtively crude, but it should work reasonably well at medium distances from trees.  It's fairly simple to implement, using a greyscale image map and a colour adjust shader used as an opacity function in addition to the existing leaf's opacity image.  The tricky part is creating the "growth map".  My first trial uses a crude combination of radial fills, scaled and masked to the leaves, and combined to accomodate overlapping leaves.  I'll see how this one looks before even thinking of trying a more sophistacted growth map, as the extra effort may not be worth it.

[attachimg=#3]

The mask includes 3 growth sequences controlled by the greyscale values of the growth map.

Fingers crossed
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 02:40:24 AM
A variant of this might be able to randomize the growth stages in populations. 
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 02:48:40 AM
That could easily be done by multiplying the Age node by an additional mask controlling the variation in age. This mask would also have to be animated to produce an end result of 100% coverage. In theory it's quite feasible. Rendering a few small key frames first before starting a proper series.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 02:55:17 AM
At the moment I'm populating my glen with forests.  I'm thinking of ways to get a good mix of young, mature, dying, and dead trees.  Could we use a fractal mask to blend a population among them for stills, that is, not animated but a one time calculation?
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 03:45:58 AM
You may want to look at my post on creating multiple masks from a single image map.  You can take the same approach with a PF as well.

One possible approach is to create a PF mask for the overall distribution distribution of trees/ clearings.  From here you then need to make a number of different versions of the same mask using colour adjust nodes to isolate different ranges values and combine these using multiply/add/subtract scalars to build up density masks for each population.

Take it slowly...  ;)

Younger trees are at a higher denity at the edges of the forest (lower values of mask)
Oldest trees are at a higher density at centre of the forest (high values of the mask)
Middle aged trees are in between these two populations.

I'll try and make up a simple demo mask for you.

Here are some intermediate keyframes of my leaf growth. The next series will be even closer to the tree to show a bit more of the detail changes.
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 04:27:35 AM
Quote from: gregsandor on October 25, 2008, 02:55:17 AM
At the moment I'm populating my glen with forests.  I'm thinking of ways to get a good mix of young, mature, dying, and dead trees.  Could we use a fractal mask to blend a population among them for stills, that is, not animated but a one time calculation?

OK, here's a quick demo of a possible masking solution. I've fed them into surface layers to preview the distribution.  One advantage of this setup is that it's highly configurable using the black and white levels and gamma adjustments.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 04:28:47 AM
Thanks!  I'll test it now.
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 04:42:24 AM
Could you post an image of your test.  I haven't actually applied this to a population set yet  ;)
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 04:58:18 AM
Sure.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 06:47:30 AM
Result
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 07:18:07 AM
Zoomed in to the 5m terrain
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 08:11:48 AM
With trees?   ;)
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 04:22:34 PM
A little closer and higher quality. Detail 1, AA6.

The partial leaf shape is good enough for animation purposes at this distance.  :)

Zooming in a bit more for the final sequence so you can see exactly what's going on. (Detail 0.5, AA3 in the sample below)
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 04:56:11 PM
With trees?  The renders I posted are the forest mask, now I'll put the trees on.  By the way those shots you posted look good.  I especially like the progression at top of thread.
Title: Re: Growing leaves
Post by: Mohawk20 on October 25, 2008, 05:09:17 PM
Very interesting test!

I'd like to use this for my Genesis Project anim I'm working on currently.
Now I animate the size of the whole tree, first only hight and then width, with a litlle bounce, resulting in a sort of comical effect. I'll post an animated gif here when the anim is done rendering.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 05:54:59 PM
...
Title: Re: Growing leaves
Post by: Mohawk20 on October 25, 2008, 06:07:54 PM
I'd say you would have to make the trees a lot smaller for good scale....
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 06:11:00 PM
I'm taking a side track at the moment; I want to see if I can use my forest mask on the Y axis to control blending between the fully opaque leaf and bigben's gradient mask, so the trees in whitest areas will be fully opaques and at the grey-black areas will have thinner leaves.
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 07:00:36 PM
Quote from: gregsandor on October 25, 2008, 06:11:00 PM
I'm taking a side track at the moment; I want to see if I can use my forest mask on the Y axis to control blending between the fully opaque leaf and bigben's gradient mask, so the trees in whitest areas will be fully opaques and at the grey-black areas will have thinner leaves.

This is a little more complicated, because you're trying to mask leaf surfaces at a tree level within a population.  From memory you need to include something like a Voronoi 3D diff scalar to provide masking at this scale. Your garden variety PF is only useful at the leaf level for surfacing, or for controlling distribution of a population.

Another thing to take into consideration with the demo distribution mask in this post is that you may have to decrease the object spacing below what you think it should be because much of the mask will have values <1, which will decrease the density of trees.  I've moved my leaf growing animation to my PC at work and am running a test on this one now.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 07:46:19 PM
Well, that explains my headache...  I haven't been able to get a blend yet.  Currently trying just to blend two colors in the color function.  I'don't know how to use the 3d voronoi node, so I'll plug one in and see what happens.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 07:52:04 PM
...
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 08:09:49 PM

I guess I'll go back to using separate populations using the mask you set up.
While I'm thinking of it it would be nice to be able to use the same method to vary the scale of the objects in a single population.
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 10:15:17 PM
It may well be simpler to create an extra population for the dead/dying trees. It's relatively difficult getting good variation at the tree level of a population.

I've started another post where it might be more appropriate to move this offshoot from my original topic. http://forums.planetside.co.uk/index.php?topic=5049.msg52266#msg52266 (http://forums.planetside.co.uk/index.php?topic=5049.msg52266#msg52266)  It might make easier reading when I get some more samples of growing leaves to add here.
Title: Re: Growing leaves
Post by: gregsandor on October 25, 2008, 10:21:23 PM
...
Title: Re: Growing leaves
Post by: bigben on October 25, 2008, 10:37:07 PM
Try decreasing the spacing in the populations.
Old x 0.7
Medium x 0.5
Young x 0.3

.. and post results in http://forums.planetside.co.uk/index.php?topic=5049.msg52266#msg52266 (http://forums.planetside.co.uk/index.php?topic=5049.msg52266#msg52266) ;)
Title: Re: Growing leaves
Post by: bigben on October 26, 2008, 07:00:48 PM
OK. Back on topic...  here are a few early frames from the up close animation showing the beginnings of the leaf stem.  The model is the public XFrog birch.

Switching to a progressive render (updating my render management database)
Title: Re: Growing leaves
Post by: bigben on October 27, 2008, 02:18:40 AM
into the prgressive render now.  Here's frame 64 with a closeup of a partial leaf.  Don't ask me where the small artefacts are coming from  (look like flies around the leaves) I have no idea. I can't find anything in the mask images.

Detail 0.7, AA 3

You can clearly see the shape of the gradient used for the mask... an ellipse centred at the base of the leaf... but it gives a reasonable impression of a leaf from a small distance further away.
Title: Re: Growing leaves
Post by: gregsandor on October 27, 2008, 02:47:29 AM
This looks great.
Title: Re: Growing leaves
Post by: bigben on October 27, 2008, 06:39:48 PM
OK, here's a sequence that shows images from each stage.
1° stem > petioles > leaf blade.
Title: Re: Growing leaves
Post by: old_blaggard on October 27, 2008, 06:58:58 PM
Very nice! I wish that there was a way to do this from within TG2 without having to reload the models every frame.
Title: Re: Growing leaves
Post by: bigben on October 27, 2008, 07:09:15 PM
This is all done within TG2! The only animation here is a single colour adjust node on an opacity function derived from an image map.
Title: Re: Growing leaves
Post by: gregsandor on October 27, 2008, 08:03:23 PM
The models aren't being replaced.  The opacity of the leaves is being changed.
Title: Re: Growing leaves
Post by: old_blaggard on October 27, 2008, 09:09:19 PM
Ah, yes, you're right, silly me. For some reason I was thinking of Bigben's age variations project, which I believe does require a separate model for each age, and if you wanted to have an animation of a tree growing, you would have to have one model per frame.
Title: Re: Growing leaves
Post by: bigben on October 27, 2008, 09:40:01 PM
Quote from: old_blaggard on October 27, 2008, 09:09:19 PM
...For some reason I was thinking of Bigben's age variations project, which I believe does require a separate model for each age, and if you wanted to have an animation of a tree growing, you would have to have one model per frame.

That's my next project using Arbaro and multiple XML docs to generate an OBJ model on the fly.... more swaying in the wind than growing, although growing grass should be feasible.  Growing trees would be a bit trickier as there would probably be a lot of jitter in the leaves as the branches grow, but it may still be very effective. It would partly depend on the grwoth rate.
Title: Re: Growing leaves
Post by: bigben on October 28, 2008, 07:08:11 AM
OK, the 1/8th render pass is complete.  Posted a 3 frames per second animation at http://podcast.bigben.id.au/channel0/leaf-growth/ (http://podcast.bigben.id.au/channel0/leaf-growth/)  I'm starting a second sequence of a whole tree for comparison.
Title: Re: Growing leaves
Post by: bobbystahr on October 28, 2008, 11:28:56 AM
Quote from: bigben on October 28, 2008, 07:08:11 AM
OK, the 1/8th render pass is complete.  Posted a 3 frames per second animation at http://podcast.bigben.id.au/channel0/leaf-growth/ (http://podcast.bigben.id.au/channel0/leaf-growth/)  I'm starting a second sequence of a whole tree for comparison.

That's pretty awesome Ben....dunno how I missed this thread but now I gotta go back and read the whole thing...fortunately I'm just sittin waiting for the phone to ring...LOL.. ...
Title: Re: Growing leaves
Post by: bigben on October 28, 2008, 07:45:28 PM
Thanks Bobby

Here's the partially rendered full tree animation. every 4th frame, 6fps.  (Just play around with the slider once the movies loaded)
http://podcast.bigben.id.au/channel0/leaf-growth-2/ (http://podcast.bigben.id.au/channel0/leaf-growth-2/)

It will be interesting to see how this can be varied across a population.
Title: Re: Growing leaves
Post by: Mohawk20 on October 28, 2008, 08:06:59 PM
You might want to adjust the speed of the changes toward the end. Suddenly the leaves grow super fast...
Title: Re: Growing leaves
Post by: bigben on October 28, 2008, 09:41:14 PM
Yes it is a bit fast... but then this is the first test and it's not like a surface where you have a preview render to check.

I just used a few linear gradients for each stage and didn't actually calculate the change in density vs distance. Had I planned it a bit more I would have set a key frame for each (white level) of the animation stages. I also considered varying the mask for each leaf blade to have them start at different times. The effect would be subtle at this distance but it's easy to setup.

Key values for this mask image (now that I've looked it up)

Black level = white level
End of branch (1 -> 0.75), petiole (0.75 -> 0.56), leaf blade (0.56 -> 0.02)
Title: Re: Growing leaves
Post by: bigben on October 30, 2008, 04:18:33 AM
The second animation is complete now.

http://podcast.bigben.id.au/channel0/leaf-growth-2/ (http://podcast.bigben.id.au/channel0/leaf-growth-2/)

Sorting out an issue with IE7 and the plugin. If you have this browser try http://podcast.bigben.id.au/files/leaf_growth2/ReadMe.html (http://podcast.bigben.id.au/files/leaf_growth2/ReadMe.html)
Title: Re: Growing leaves
Post by: Mohawk20 on October 30, 2008, 04:37:57 AM
Once you got these leaves sorted, add a little animation in front of the tree itself grow from 0 to 1 size (or whatever you have it now). Could be a nice effect...