Archived

This topic is now archived and is closed to further replies.

Tree/Forest LOD

This topic is 5353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been trying to add some kind of trees/forest to my terrain engine. I''ve implemented a semi-random tree generator simmilar to nVidia''s tree demo. Now the trouble is drawing lots of these trees. Since one tree is +2000 tris, so there is no way I can reneder more then let''s say 150 of them at decent framerate (I''ve tried just about all the tricks I know.. [all data in VRAM, cache optimized tri-strips,... ]). So I need to implement some kind of (C)LOD. I was thinking about imposters as they are used in forest scenes alot. But the problem is in how to implement them. I realy have no idea how to setup projection matrix to render them. Transformation matrix should be the same as for normal rendering, right? And even when I have it on texture, how do I make smooth transition from 3D geometry to imposter. I kind of doubt simple fade-in/out will do. Any help would be welcome (links, tips&hints, code,...). Or if you have better idea for tree/forest LOD please tell. You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
To find out more about imposters, look up billboarding on google. And if you have a tree generator kinda like nvidia''s, can''t you make the trees a different LOD in realtime, just by reducing the depth and fullness of the trees as they get farther and farther away from the camera?

-------------------
Realm Games Company

Share this post


Link to post
Share on other sites
For switching out from a model to a sprite imposter, a simple alpha-blend is actually plenty. Especially if it is likely that other things are going to be in the way.

For example of this kind of imposter switching, play the demo for Delta Force: Land Warrior, and look around on the desert/pyramid level. All around where you start, you''ll see some trees... which fade out to billboarded sprites at about 20 meters. And unless you''re watching for it, it works well!

I''ve figured out techniques for making it more seamless, but my techniques only work well in moderately-thick (2 or more trees in every 15x15 meter patch) forests...

Share this post


Link to post
Share on other sites
GreatOne : Rebuilding tree is not something you want to do in real-time. It kills your performance big time.

Would be nice to get response from someone who actualy coded this thing. Just the thing how to setup render to texture thing.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
don t know if you have ever played battlefield 1942

they do the best trees i have ever seen with only 100 polygons


what they do is render the stem with one texture


and then they use sprites for the leafs with decreasing alpha value from front to back


so you do:
- render all the stems with the same stem texture
- then render all the other stems sorted by texture of course
- render the leafs sorted by texture


trees are static geometry so you can easily sort them
created a vertex array for the stem

and one for the sprites which you use for the leafs

you do this in an model object

and for each tree you create an entity object which stores the index of the model you use
every frame your setup the sprite`s vertices
then render all the stems
and then the leafs


why?
because switching textures decreases performance and switching the rendering state to alpha blending consumes a lot of CPU power as well especially when you are drawing several thousand trees

you manage 150 with 2000 polys so you should reach an approximate number of 3000 with BF1942`s methode

nice eh?

Share this post


Link to post
Share on other sites
Basiror : I havn''t played battlefield 1942. But this is simmilar to what I have seen in Ultima Reborn. The method is actualy quite nice but doesn''t it require artist to create trees in first place? I was going more for procedural approach.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
well get photoshop
a picture of a tree with some leafs on it

create an image of 32*32 or 64*&4
copy a piece of the leafs so you can create a ball like looking sprite of leafs

and cut out the alphachannel at the positions where you have the background of your source photo

maybe you want to apply some blur effects the further you are away to make it look more realistic

Share this post


Link to post
Share on other sites
eh?

that hasn t been an offtopic reply

what i have tried to say, is that this little art work can be done by every ***** (imagine a word with 5 letters , 1st is I)

Share this post


Link to post
Share on other sites
Sorry for the comment. But trouble is that what is drawn by **** also look *realy* fake.

I would *realy* want to implement imposters... anyone please!!!

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
First of all, you should only use imposters for trees that are far from the viewpoint. Imposters look really fake, even with nVidia''s depth-texture trick that makes them more depth-correct (remember that an imposter is a single polygon, thus the depth is flat).
If the camera can go inside the forest, you should render a few trees around the camera at a full res, other trees being imposters.

I don''t get your problem about matrices. Can''t you setup the PROJECTION or the MODELVIEW matrix ? (I''m sorry to use the OpenGL convention btw )

As for the transitions, there is no solution that works for all cases. It all depends on how and where you camera can go :
- If your camera is absolutely free, you may want to regenerate imposters "when their appareance on screen changes too much". If your camera is fixed around a path, you could pre-generate imposters and then render them sequentially just like you would render a video (at a much lower framerate though).
- If the camera is really fast, you don''t really need transitions as the user/player won''t notice it in the speed effect. If the camera moves slowly, you''ll probably want to use a blending trick between two imposters.

Hope this helps

Share this post


Link to post
Share on other sites
Hi Darkwing, I''m actually doing the same thing as you. I''ve implemented a tree generator, and I currently have 64 trees per 128x128 meter patch. My LOD technique involves just making different Index buffers for each LOD level. Based on the distance from the camera, you just dont draw branches below a certain size, but always draw all the leafs. At very long ranges, you can get away with only drawing half the leafs on an entire tree, and it still looks like a tree in the distance.

Share this post


Link to post
Share on other sites
oh - another thing I tried is to just render each branch as a billboard, thus distant trees only require 2 tris per branch, and effectively still appear to be round...

Share this post


Link to post
Share on other sites
WarAmp : Can you post a screenshot/demo of this a work. I understand how it works in practice. I was thinking about it at first but then discared idea becouse I tought there will be to much "poping".

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
Ok, but you''ll have to wait until I get home form work.

There is a bit of popping, but its usually only noticeable as you come down a hill into some trees. When you are in the trees, its hard to notcie because it happens so infrequently and is mostly obscured by other trees and such.

Share this post


Link to post
Share on other sites
The Gscape engine uses this kind of LOD determination. You can make certain sets of branches of a tree ''turn off'' as camera distance is increased. Then, at a certain point the tree is changed to a billboard.

There is more about it in the documentation, specifically the last page of the Tree tutorial.

Hoffs

Share this post


Link to post
Share on other sites
I don''t know much about impostors, and you may already know what I''m saying, but I''ll take a stab anyway.
I think the the projection matrix must have the same aspect ratio as the normal rendering one. The quad(the impostor) you will use to represent the tree will get skewed a little because of the projection matrix while rendering the impostor but I think it will be negligible if there are sufficient number of impostors for a tree. There will be a min of 5 impostors for a tree (top left right front and back) but you may have to use many more to reduce popping due to direction change (this would happen very slowly as the tree is far away) and to make them look good. You select the correct impostor by finding out the direction from which you are looking at the tree.
As for the depth-correctness, its useful only when the trees intersect something. Will the far away trees intersect with anything?

Share this post


Link to post
Share on other sites
I've implemented WarAmp's idea and it works quite good. But there is very noticabile popping when you approach a single tree in the middle of nowhere. Other times looks just nice.



they also add so much to the "atmosphere" of the scene




You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on March 15, 2003 1:16:33 PM]

Share this post


Link to post
Share on other sites
Have you ever thought of using occlusion culling? If you''re looking into a dense forest, then a lot of the trees will actually be occluding other trees, so even after standard culling, you''re wasting GPU power.

Or, how about this one, i thought of it just there, so theres gonna definately gonna be problems, but i think its a pretty viable option.

Instead of procedurally generating the tree, how about you start with 2 primitives, a sphere and a cylinder, the sphere sitting on top of the cylindar. Now, make (of if you so desire, procedurally generate) displacement cubemaps, for where the branches stem off on the cylinder, and a rough shape for the leaves, and when you pass the primitives to the card, tesselate the primitives to the LOD, and filter (between mipmap levels too) the displacement cubemaps, and then displace them on the GPU. Again, chances are this wont work, but at least im trying

Share this post


Link to post
Share on other sites
Hairybudda : Occlusion is still on my "todo" list . But I''ll probably go for some kind of HOM. I have to do a bit more testing on this. Right now I''m still in stage of gathering resources about the subject. The other idea requires HW displacement mapping with cubemaps. I doubt there is any (consumer level) card out there that can do it.

bjmumblingmiles : For scene on pictures I''m getting about 30-50 fps on ATI 9000 and about 80-120 on GF4_4600 (VAR optimization). But it realy depends on the LOD settings, viewing range, water animation type,...

Share this post


Link to post
Share on other sites
quote:
Original post by _DarkWIng_
Hairybudda : Occlusion is still on my "todo" list . But I''ll probably go for some kind of HOM. I have to do a bit more testing on this. Right now I''m still in stage of gathering resources about the subject. The other idea requires HW displacement mapping with cubemaps. I doubt there is any (consumer level) card out there that can do it.


If you do the tesselation on the CPU, and instead of sending the map to the GPU as a texture (you cant do texture lookups in a vertex shader, right?) you can extract displacement values from the map and send them to the GPU as a vertex and have a shader displace them for you.
Due to some unforseen circumstances (working, girlfriends been ill) i''ve not been really up to date on the graphics card scene, but last i heard, the GFFX had an onboard tesselator to take the strain off the CPU?
Oh well, i suppose my idea needs more refining

Share this post


Link to post
Share on other sites
A tree entirely behind another one can probably be replaced by a billboard. It works better if you''ve got a few polys filling the tree with small, dense twigs and leaves.

With some careful modelwork, every time the tree gets far away enough to appear half as high, you should be able to halve the number of polygons.

As a transition from full-poly to distant billboard, you could render a tree once to a texture, use that as a billboard, then decrease the alpha, replacing it with the common texture.

Staying in the realm of billboards, distant trees which have only just become visible can all be flat.

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back

Share this post


Link to post
Share on other sites
Thsi is only an idea and I have never implemented this but reading these posts gave me an idea. Would it be possible to render the tree to a texture with alpha right before it pops then just use that as an imposter. Of course this wouldn''t work when they pop back from textures but something could be worked out.

Share this post


Link to post
Share on other sites
Occlusion algorithms can be very hard with trees since you can always see something through the leaves. Apart from NV_occlusion_query I don''t see any "realtime" technique that could perform occlusion culling with trees.

_DarkWIng_: The pictures looks great ! I still think that fractal-based models (terrain as well as trees) look very unrealistic, otherwise the rendering quality is excellent !

ps: go code support for VBO. You won''t have any excuses for rendering faster on nVidia cards than on ATi

Share this post


Link to post
Share on other sites