Sign in to follow this  
lurky

Vegetable rendering problem

Recommended Posts

lurky    101
Hi all, i'm tried to deal with a huge landscape( 30x30 km) with dence vegetables( from 1 to 8 instances per squared meter).

Below I wrote my current solution:

1) one quadtree for entire landscape and all kinds of vegetables

2) static vb template for all kinds of vegetables(for varying densities just apply a scale( cut a part from an original array))

3) screen space masks( roads, asphalt, sand)

Each time the closest chunks are rendered, heights is applying form vertex texture( or screen space depths)

Advantages :

- minimum cpu mem loading,

-no recreation vbs in realtime,




Disadvantages

- even if no vegetables is visible( masked) IA will loaded, and primitives will be drawn,

-Need many textures for masks

- huge triangles count( over 2000000 for grass only!) caused the fixed(and big) chunk size(quadtree cannot handle more than 2048x2048 by memory requirements)

Now the question: how to render and handle a huge count of vegetables of any type without a great slowing in performance, (the method must provide a rapid managing and accurate edges - green|road interaction)?

It's is possible to paint trees with great density (like in Crysis) for scene with huge size ( I'm trying to distribute some vegetables in crysis but even for density of 4 per meter and landscape 4096x4096 it has caused out of memory exception)?


Any idea about that?

Share this post


Link to post
Share on other sites
Hiyar    130
I am not sure if I understand, what do you mean by vegetables. Tomatoes and potatoes?
If you mean grass and shrubs and little bushes. This is usually done by using a fixed grid structure (for example 16x16 meters) and generating vegetation only in close up areas.

Share this post


Link to post
Share on other sites
lurky    101
Sure, vegetation :) The grid structure - is good, it's like that I have used, but how to deal with the situation below:

-We have a tree alley along the road, 90% triangles from input assembly will be discarded( if we are using a quad 16x16 for example).

What is the solution? - to fill vb dynamically (too slow).. or to prepare & save vb's on disk( load dynamically)?

Also the Crysis has possibility to move trees from the layer individually - seems it has able to save instancing parameters individually. How to do that?

Share this post


Link to post
Share on other sites
smasherprog    568
This is not a vegetation rendering question, but one that relates to all rendering: how do you efficiently cull objects while batching as much work together as possible.
Having said that, you have to split your scene up into some type of a grid structure and then render each grid independently..

There are no special ways to do this, because it is scene dependent, meaning the method will be different for big open worlds, or closed space worlds. You should research spacial partitioning, which is the topic of your question. You can have separate buffers for your vegetation, then split the viewable space into decent size chunks, then do a simple check to see if the chunk is partially visible, if so, draw it. You are always going to have over draw. The smaller the chunks, the better the culling, however, this will increase the amount of draw calls and cpu work. This is where it will be scene dependent.

Share this post


Link to post
Share on other sites
Aqua Costa    3692
For trees, bushes, etc: Are you using multiple LOD's?
Just have to draw a tree with actual geometry if you are near it, for far away trees draw a billboard instead or a tree with low LOD.

For grass: [url="http://http.developer.nvidia.com/GPUGems/gpugems_ch07.html"]Check this link[/url]

Share this post


Link to post
Share on other sites
lurky    101
Thanks, but this papers aren't describing of rendering trees same as grass(using instancing as possible) in details and what to do with the huge landscapes with high details - 20x20km with step up to 0.25 meters?

If we're having 20x20 with detail level 1 meter we must have 10x10 mask textures with resolution 2048x2048 for 4(rgba) layers of vegetation, that is approximately 1.5Gb only for masks!




Share this post


Link to post
Share on other sites
Aqua Costa    3692
[quote name='mr. lurky' timestamp='1308646790' post='4825884']
Thanks, but this papers aren't describing of rendering trees same as grass(using instancing as possible) in details and what to do with the huge landscapes with high details - 20x20km with step up to 0.25 meters?

If we're having 20x20 with detail level 1 meter we must have 10x10 mask textures with resolution 2048x2048 for 4(rgba) layers of vegetation, that is approximately 1.5Gb only for masks!
[/quote]

Do you really need that much detail in your masks? It should be fine if you used 1024*1024 masks (or even less) also why using RGBA textures? you can combine 4 layers in a single value...
Example:
[code]
2 layers: layer "a" and "b"
if (this pixel inside layer "a")
{
pixel color = 10;
} else if(this pixel inside layer "b")
{
pixel color = 20;
} else if(this pixel inside layer "a" and layer "b")
{
pixel color = 30;
}

[/code]

and then when you read the masks you use the same technique

using a 8 bits texture it would only need 100MB

Share this post


Link to post
Share on other sites
lurky    101
[quote][Do you really need that much detail in your masks? It should be fine if you used 1024*1024 masks (or even less) also why using RGBA textures? you can combine 4 layers in a single value...
[/quote]

Thanks for good idea, with you approach we have 1channel x 4 levels, and you're right - exaclly 100 mb, but if we need 16 mask layers?

How do you think, its possible to use less(1 or 2) bits to set bound between several masks?

May be it;s patient to define structure( a floater frame) to render only nearest masks and load from disk by the moving path?

Share this post


Link to post
Share on other sites
Aqua Costa    3692
[quote name='mr. lurky' timestamp='1308651602' post='4825906']
[quote][Do you really need that much detail in your masks? It should be fine if you used 1024*1024 masks (or even less) also why using RGBA textures? you can combine 4 layers in a single value...
[/quote]
How do you think, its possible to use less(1 or 2) bits to set bound between several masks?
[/quote]
Sure, you can set layer "a" value to 1, layer "b" to 2, layer "c" to 3... etc

a 8 bit texture should allow you to create 255 combinations of layers... that should be more than enough :rolleyes:

Share this post


Link to post
Share on other sites
Hiyar    130
[font="arial, sans-serif"][size="2"]
20km x 20km ????
Is your game world really that big?
I think you should load and generate vegatation only in close areas while camera is moving (streaming in the background) and if you have large view distance use lod techniques aswell[/size][/font]

Share this post


Link to post
Share on other sites
lurky    101
[quote name='TiagoCosta' timestamp='1308652129' post='4825911']
a 8 bit texture should allow you to create 255 combinations of layers... that should be more than enough :rolleyes:
[/quote]

Thanks I will try it


Share this post


Link to post
Share on other sites
lurky    101
[quote name='Hiyar' timestamp='1308662633' post='4825962']
[font="arial, sans-serif"][size="2"]
20km x 20km ????
Is your game world really that big?
I think you should load and generate vegatation only in close areas while camera is moving (streaming in the background) and if you have large view distance use lod techniques aswell[/size][/font]
[/quote]
Exacltly this approach i've tried to implement on gpu side, but the culling and masking are applied on gpu, -> if we create small chunks near the camera, we do not manage it to cull parts smaller then some predefined size(64x64 for example). The main problem is how to cull wasted triangles BEFORE it'll be culled on the gpu side


Share this post


Link to post
Share on other sites
Hiyar    130
I thought you are asking question about how to deal with the high memory consumption. (you wrote you need 1.5Gb only for masking)
And I suggested you to stream data from disc while moving in the game world.

I dont know how exactly you generate vegatation on GPU, but you cant load all the masking data for the entire game level.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this