Jump to content
  • Advertisement
Sign in to follow this  
solenoidz

Gloomy endless woods...

This topic is 2810 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

[color=#1C2837][size=2]Hi guys.
[color=#1C2837][size=2]I'm trying to implement big forest over a terrain, but I'm not really sure how to approach such a problem. Here are some thought floating around my head.
[color=#1C2837][size=2]I wonder am I on the right track here, or I'm completely lost..
[color=#1C2837][size=2]

[color=#1C2837][size=2]

[color=#1C2837][size=2]-make a mesh, containing several tree models. Lets say - 10x10 trees in a single mesh.
[color=#1C2837][size=2]-on a grid pattern around the camera and way ahead the camera view, position that mesh and render it several times on the grid patches that fall in view frustum.
[color=#1C2837][size=2]-in order to position the trees in the mesh above the terrain height, use vertex texture fetch in the vertex shader and offset the Y position of the vertices, according to the terrain height sampled under that vertex.
[color=#1C2837][size=2]-Of course, I need to skip rendering tree of there are roads, rocks, buildings and such bellow.
[color=#1C2837][size=2]-I can sample a distribution map to see where on the terrain I need to place trees. If there shouldn't be trees, I can move the vertices bellow the ground for example to hide the tree. But on the road edge for example if there is a tree, that would lead to annoying distortions, when I hide the vertices that fall over the road and show those that fall over the nearby terrain.
[color=#1C2837][size=2]Maybe I need to hide the entire tree, if any of it's vertices are above the road. But in the vertex shader, all the 10x10 trees are in a single mesh, and there is no separate tree to hide.
[color=#1C2837][size=2]It all seems ugly and wrong to me.
[color=#1C2837][size=2]I have a feeling, that I need to use instancing. How can I render a bunch of trees in one draw-call, position every one of them over the terrain (VT fetch again?) and skip those trees, that fall over a road, rocks, buildings etc ?
[color=#1C2837][size=2]

[color=#1C2837][size=2]Thank you for your time.
[color="#1C2837"]

[color="#1C2837"]

[color=#1C2837][size=2]

Share this post


Link to post
Share on other sites
Advertisement
Trees (good looking ones anyway) are probably a really tough thing to get right. I don't think you're going to get away with just one mesh, you probably need a LOD scheme to do different things from distance to the player. A close up tree with a lot of leaves and branches could probably take up a big chunk of rendering time, and if you just blindly stamp this in 1000 places it's not going to run at interactive rates.

I would probably not use a "grid of trees" as your base mesh, as this is going to be very noticeable and repetitious from ingame. I would probably create a handful of different tree models at different level of detail, from close up (detailed mesh + detailed leaves), medium distance (low poly mesh with maybe a couple billboard leaf chunks), to distant (flat billboard). And then use some noise algorithm to sprinkle these randomly around your terrain.

As far as instancing, that can be a performance boost dependent on the API you're using, but I feel like you've got a lot more thinking to do before you get to the point where you really need to hone the performance.

Share this post


Link to post
Share on other sites
One approach for the position of trees I do remember is in the Nvidia OpenGL SDK 10 - the demo called "Cascaded shadow Maps".

The author used a top down render of the terrain, prepared offline in greyscale, then positioned where they wanted trees by placing a white pixel(s), using photoshop or similar.
Then testing for this when initialising the program and storing the position by scaling the pixels position to the actual dimensions of the terrain.

So when they render the scene they iterate through the stored position vectors, and draw a tree at that position.
This could be extended perhaps to test for other specific colours to indicate different tree types. Red = ..., etc, and store this with position.

You would want to make it more efficient since they dont have many trees in this demo, so perform a visibility test for each position to see if its within frustum before bothering to draw etc.

Anyway just thinking on my feet, no experience of this :)

Another recent article comes to mind which discusses the merits of Imposters for trees, i.e. LOD as mentioned above.
http://www.gamasutra.com/blogs/DavidRosen/20101004/6126/Imposters.php

Share this post


Link to post
Share on other sites
I haven't implemented this yet but it's a goal of mine.

As a preliminary plan I'm looking at generating details procedurally for the nearest LOD. It seems to model an accurate forest environment will require specifying 'interior' and 'edge' zones because trees grow differently and usually grow together to form a solid canopy.

For medium LOD some kind of combination of procedural followed by imposters may be used. At far enough distance eventually it might become generic (non-procedural) billboards.

The furthest LOD ie miles distant could be simple polygons.with clever texturing.

I would love to see some implementations so send me a message if you make a demo you could show off :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!