Jump to content
  • Advertisement
Sign in to follow this  

Questions about rendering and editing large terrains?

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

1) Are heightmaps used for large terrains where overhangs and caves are modeled as meshes? If so is one heightmap used for the entire terrain?

2) What are the best modern terrain rendering techniques? (The names would suffice, i'll google them for an explanation)

3) When editing the terrain, how to optimize the intersection tests? Currently i just cast a ray and find the intersected triangle, then i loop through all the terrain vertices and test their distance to the point of intersection to find if the vertex is within the radius of the editing brush. This works fine for now (32k vertices) but i'm worried about larger terrains. And i still have to add the code for recalculating normals.

4) Can i use PhysX to do the intersection tests? Is there a function that returns ALL intersected triangles within a given radius of the ray? And would having to update PhysX's terrain representation every frame be slow?

Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
If you use a heightmap, youd definitely have to add the overhangs as extra meshes somehow, heightmaps only go up and down. The quickest way to collide with a heightmap is to just read the height off the map itself, then restrict y movement, thats the quickest and dirtiest way.


If I was going to allow overhangs, id probably use voxel terrains, they get just as big and you wouldnt need to patch in models into it, which doesnt sound like the best idea to me. Look up "voxel terrain"


Watch out for floating point accuracy when numbers get far away from the origin, float rounding can happen and your either better off with doubles or would you even believe integers solve the problem too.

Share this post


Link to post
Share on other sites

1) Are heightmaps used for large terrains where overhangs and caves are modeled as meshes? If so is one heightmap used for the entire terrain?
[/quote]

You can't model caves and overhangs with a single height map so meshes are one possible way to model overhangs and caves. Also different voxel techniques may be used.

Practically one height map is used for the entire terrain. The question is, how big height map you need and how much memory the height map can take.



2) What are the best modern terrain rendering techniques? (The names would suffice, i'll google them for an explanation)
[/quote]

Brute-force, Quad-tree terrains, geometry clip-maps (nested regular grids). The keywords here are that you want most of the level-of-detail calculations done on the GPU.


3) When editing the terrain, how to optimize the intersection tests? Currently i just cast a ray and find the intersected triangle, then i loop through all the terrain vertices and test their distance to the point of intersection to find if the vertex is within the radius of the editing brush. This works fine for now (32k vertices) but i'm worried about larger terrains. And i still have to add the code for recalculating normals.
[/quote]

You shouldn't have need to iterate through all the terrain vertices. Since your terrain is a regular 2d-grid and you know the editing brush extends, you can apply the brush to the vertices that are in the brushes range. This will lower your brush calculations from 32k to few hundred vertices I imagine.


4) Can i use PhysX to do the intersection tests? Is there a function that returns ALL intersected triangles within a given radius of the ray? And would having to update PhysX's terrain representation every frame be slow?

Thanks :)
[/quote]

Why would you have to update the Physic API's terrain presentation every frame?


Cheers!

Share this post


Link to post
Share on other sites
Well... you actually can model some overhangs with a heightmap, if you have normals (caves are a different problem). Translate (or "inflate") vertices along the normal, scaled by some factor ranging from zero to any value. It probably works just as good if you only have four additional tweakable vectors for, say, a 10x10 meter terrain area, which you can interpolate over that area and use for translating vertices. Basically that would be something like the poor man's lattice deformation. Without lattice.

I think someone on this forum named the technique "shrooming" once.

Share this post


Link to post
Share on other sites

Well... you actually can model some overhangs with a heightmap, if you have normals (caves are a different problem). Translate (or "inflate") vertices along the normal, scaled by some factor ranging from zero to any value. It probably works just as good if you only have four additional tweakable vectors for, say, a 10x10 meter terrain area, which you can interpolate over that area and use for translating vertices. Basically that would be something like the poor man's lattice deformation. Without lattice.

I think someone on this forum named the technique "shrooming" once.


The above cannot be done with just a height map. This technique was used in halo wars, essentially using a vector map rather than a scalar map to deform terrain.

Share this post


Link to post
Share on other sites
3) When editing the terrain, how to optimize the intersection tests? Currently i just cast a ray and find the intersected triangle, then i loop through all the terrain vertices and test their distance to the point of intersection to find if the vertex is within the radius of the editing brush. This works fine for now (32k vertices) but i'm worried about larger terrains. And i still have to add the code for recalculating normals.
[/quote]

I may be WAY off here, as I'm still new. But aren't height-map terrains generated from a grey scale image? If so, would it not be possible to paint the image representing the height? It might be more work to implement texture painting capabilities into your game, but if you do, you might be able to use it to edit terrain textures as well. Again, I'm still really new, but that's how I always thought terrain editors worked.

Share this post


Link to post
Share on other sites

I may be WAY off here, as I'm still new. But aren't height-map terrains generated from a grey scale image? If so, would in not be possible to paint the image representing the height? It might be more work to implement texture painting capabilities into your game, but if you do, you might be able to use it to edit terrain textures as well. Again, I'm still really new, but that's how I always thought terrain editors worked.


Yeah, you're right, and that's how I do it. Once the painting system is up and running, you can use it for material- and grass maps and whatever else too. You can use any source image as a brush. Since the GPU is so fast at rendering pixels, you can edit huge areas very efficiently. It's not hard to implement either. It basically boils down to rendering a sprite to a rendertarget.

Share this post


Link to post
Share on other sites

[quote name='samoth' timestamp='1324462324' post='4896126']
I think someone on this forum named the technique "shrooming" once.

The above cannot be done with just a height map. This technique was used in halo wars, essentially using a vector map rather than a scalar map to deform terrain.[/quote]
'Shrooming' is a much simpler technique than vector fields (and similarly, more restrictive).

In a vector field you store a full vector per texel, and use that to deform the terrain. In shrooming, you use the implicit vector derived from the heightfield to deform the terrain...

Share this post


Link to post
Share on other sites

[quote name='Burnt_Fyr' timestamp='1324482687' post='4896197']
[quote name='samoth' timestamp='1324462324' post='4896126']
I think someone on this forum named the technique "shrooming" once.

The above cannot be done with just a height map. This technique was used in halo wars, essentially using a vector map rather than a scalar map to deform terrain.[/quote]
'Shrooming' is a much simpler technique than vector fields (and similarly, more restrictive).

In a vector field you store a full vector per texel, and use that to deform the terrain. In shrooming, you use the implicit vector derived from the heightfield to deform the terrain...
[/quote]

Can you elaborate? I'm not quit picking up what your putting down. If you are deriving the normal vector from the height map, how can this be used to create overhangs? I would assume that a second channel would be necessary to store the length of the derived normal to create the overhangs.

PS: I did try to search the forums, and google, but shrooming as a search term is not exactly useful :)

Share this post


Link to post
Share on other sites

Can you elaborate? I'm not quit picking up what your putting down. If you are deriving the normal vector from the height map, how can this be used to create overhangs?

Ok, so with a standard height map, you start with a flat plain, and you move each point vertically, the distance stored in the height map.

With mushshrooming, you start with a flat plain, and you move each point along the normal vector defined by the height map, the distance stored in the height map.

It's pretty limited, and because you are encoding lengths and normal vectors in a single channel, it tends to cause terrain features to 'mushroom' (i.e. spread out with height in mushroom-like protuberances). But it does allow overhangs, and with careful use, you can make some pretty complex terrains.

I would assume that a second channel would be necessary to store the length of the derived normal to create the overhangs.[/quote]
What you are talking about there is basically a compressed form of vector fields - rather than store a 3-component normal, you store a length, and derive the normal from a single-component heightmap. It saves storage over a pure vector field, at the cost of reduced horizontal resolution.

PS: I did try to search the forums, and google, but shrooming as a search term is not exactly useful[/quote]
I believe the technique is originally from the Orange Book, which calls it 'mushrooming'.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!