Skip to main content
GameDev.net gamedev.net
🔒 Locked

Terrain Patching

Started by steg May 12, 2003 at 4:48 AM 23 replies 3.6k views
Original Post
steg
steg
Hi all, When patching terrain, I take it you have a certain level of detail for each patch worked out from the viewers position. The further the viewer is away from a patch the less detail you give to this patch, is this correct ? Thus a patch the viewer is next to would say contain 20x20 quads ? Any help is much appreciated. Steve As I get older, my mind becomes more cluttered.
If it isn't working, take a bath, have a think and try again...
edotorpedo
edotorpedo

Yep, that''s about correct. Look into geomipmapping (@flipcode) for the details.

Edo
Edo
steg
steg
Thanks Edo,

Will go and take a look. I thought I would try and get it clearish in my head before reading up on it.

One more thing, is it possible to end up rendering more quads by using patches ?

Regards,
Steve

As I get older, my mind becomes more cluttered.
If it isn't working, take a bath, have a think and try again...
Hairybudda
Hairybudda
quote:
Original post by steg
Thanks Edo,

Will go and take a look. I thought I would try and get it clearish in my head before reading up on it.

One more thing, is it possible to end up rendering more quads by using patches ?

Regards,
Steve

As I get older, my mind becomes more cluttered.


I highly advise you that if you''re using patches (as in splines right?) to represent landscape geometry, that you arrange it in an indexed triangle strip, and just generate the triangles from the highest level of detail you''re willing to accept, and then interpolate the indices to get a lower level of detail in the distance if you require it.
st0ned
steg
steg
I''m actually thinking of using Quad trees now. At the moment I only use a brute force algorithm with indexed lists.

Regards,
Steve
If it isn't working, take a bath, have a think and try again...
edotorpedo
edotorpedo

quote:

One more thing, is it possible to end up rendering more quads by using patches ?



Yes, you will probably render more tris/quads than absolutely necessary. It isn''t ROAM, which always draws the optimal amount of tris.

However, this doens''t matter (much), because you will let the GPU worry about that, with virtually no CPU-strain. With current graphics cards this is the faster method.

Edo
Edo
steg
steg
Sorry to sound thick, but I''m getting confused as to which LOD to use, geomipmapping, quad trees, roam......which is the easiest to implement ?

Kind regards,
Steve


As I get older, my mind becomes more cluttered.
If it isn't working, take a bath, have a think and try again...
Sander
Sander
GeoMipMaps in combination with QuadTrees or Octrees is currently the fastest method their is on newer graphic cards. IMHO it''s also easier to implement then ROAM. GeoMipMaps are very straightforward to do except for fixing the cracks between patches of different LOD.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
steg
steg
Thanks,

I''m thinking along the lines then that you split up your terrain in patches (geomipmapping) then put these patches into a quad tree ? Is this correct or completely wrong ? I must admit that I thought geomipmapping and quads were both CLOD algorithms ?

Kind regards,
Steve


As I get older, my mind becomes more cluttered.
If it isn't working, take a bath, have a think and try again...
Sante05
Sante05
quote:
I''m thinking along the lines then that you split up your terrain in patches (geomipmapping) then put these patches into a quad tree ? Is this correct or completely wrong ?


Yes, that''s correct. I suggest you to read the paper in Flipcode about GeoMipmapping. Basically you use a quadtree where each leaf is actually a patch. Then, for each leaf you need to render, you choose its LOD based in distance, elevation, etc (again, look at the paper). It also gives some hints in how to fix the cracks between patches with different LOD.
-----DevZing Blog (in Spanish)
steg
steg
Thanks for your help,

I think I am better to start with just doing patches firstly before putting them in a quad tree, start slowly so to speak. I''ve done what most people do when doing a terrain ''engine'' (term engine used very loosely here!) :

1 - Do brute force with triangle lists
2 - Convert to using index buffers / indices
TO DO:
3 - GeoMipMapping
4 - Quad trees - place patches into quad tree
5 - Frustum culling of Quad tree

As for cracking, on quick thinking I guess this is something to do with having a higher lod next to a lower lod ?

Kind regards,
Steve


As I get older, my mind becomes more cluttered.
If it isn't working, take a bath, have a think and try again...
Sander
Sander
Yes, that is how cracks occur. There are three methods to fix cracks.

1) add extra vertices to the patch of lower LOD. This means that you need OpenGL in immediate mode and it will slow your rendering more then the other two methods. It is however the most beautifull method. It is very well explained in the geomipmap paper by Willen H. de Boer on flipcode.com

2) Use skirts. This is a relatively fast method. It''s been pointed out by gamedev''s own Trent Polack on www.andyc.org (go to #lectures, logs and the future of terrain mapping. It means that you render a vertical strip on the edge where 2 different LODs meet. It''s pretty fast but you will get texture stretching (just like when you draw cliffs with heightmaps).

3) Increase you patch size to the order of n^2+2 and only reduce the inner N^2 vertices if you increase LOD. That means, you draw the edge just like in the geomipmaps paper but you ALWAY draw the edge vertices on the lowest LOD (most vertices). I coocked this one up myself. It has advantages as well as disadvantages. On the plus: It can be precalculated and put into the vertex and indice buffer, unlike the first solution. It''s also better looking than the second solution. The problem is that you render more triangles this way than the other two methods. This could be compensated because you can prerender and index it but I have yet to test this method.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
ReType
ReType
yes, geomipmaping sounds interesting, but ii''m having problems to setup the vertex for a LOD patch... if i have lod1 and right to it lod4?
Sander
Sander
Uhh, I dont understand your question ReType, but my best guess is that you have trouble with the indices?? What you do is set all the vertexes in a vertex buffer. You can lock this for even more speed using Compiled Vertex Arrays. The you only pass a different index buffer for each lod.

    
1--2--3--4--5
| | | | |
6--7--8--9--10
| | | | |
11-12-13-14-15
| | | | |
16-17-18-19-20
| | | | |
21-22-23-24-25

Your vertex buffer: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25

Index buffer LOD 0:
1,6,2,7,3,8,4,9,5,10
6,11,7,12,8,13,9,14,10,15
11,16,12,17,13,18,14,19,15,20
16,21,17,22,18,23,19,24,20,25

Index buffer LOD 1:
1,11,3,13,5,15
11,21,13,23,15,25

Index buffer LOD 2:
1,21,5,25

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


[edited by - smarechal on May 13, 2003 3:10:40 AM]
steg
steg
Hi Sander,

I guess that index buffer is if you are using triangle strips ?

Regards,
Steve
If it isn't working, take a bath, have a think and try again...
steg
steg
Here is how I now create indices and vertices using tri-strips:


  
void CTristripsDlg::GenerateIndices(int nWidth, int nHeight)
{
short *pIndices = new short[(nWidth+1)*(nHeight)*2];
int index = 0;
int a = 1, b = nWidth+2;

CString strIndices;
for(int i=0; i<(nWidth+1)*(nHeight); i++)
{
pIndices[index] = a;
pIndices[index+1] = b;
index+=2;
a++; b++;
}

}


and for vertices....

  
void CTristripsDlg::GenerateVertices(int nWidth, int nHeight, int nVertexWidth, int nVertexDepth)
{
int index = 0;
float x = 0, y = 0, z = 0;
pVertices = new VERTEX[(nWidth) * nHeight];

for(int j=0; j<=nHeight; j++)
{
for(int i=0; i<=nWidth; i++)
{
pVertices[i+(nWidth*j+index)].x = x;
pVertices[i+(nWidth*j+index)].y = GetHeight(i,j);
pVertices[i+(nWidth*j+index)].z = z;
x += nVertexWidth;

}
x = 0;
z -= nVertexDepth;
index++;
}

}


Do you find strips quicker ?

Thanks,
Steve



[edited by - steg on May 13, 2003 10:10:11 AM]

[edited by - steg on May 13, 2003 10:11:47 AM]
If it isn't working, take a bath, have a think and try again...
steg
steg
Whoops, the anoymous poster was me - Steg!


As I get older, my mind becomes more cluttered.



[edited by - steg on May 14, 2003 4:00:50 AM]
If it isn't working, take a bath, have a think and try again...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.