Terrain management on iOS for iPads?

Started by
5 comments, last by MichaelDeCicco 11 years, 4 months ago
I've been looking around the internet for the past week on and off and can't find anything about what sort of terrain management system would be the best for specifically the iPads.

I wanted to implement ROAM but I can't seem to understand certain aspects of it for some reason and it's taken a massive amount of effort to not only have time to program recently but also understand the concept of the ROAM algorithm. So before I put the effort into it, would it be a lost cause due to the possible performance issues? What would be the best kind of algorithm to use on the iPad? Should most of the work go to the CPU or the GPU?
Advertisement
This is the technique I'm planning to use:on iOS http://www.gamasutra.com/view/feature/1754/binary_triangle_trees_for_terrain_.php. I don't really know ROAM, but at a glance I think this BTT solution is a little simpler to get your head around.

In terms of performance on iOS, your main concern should probably be to minimise draw call count.
Thanks for the link and the advice, I'll report back how it goes when I finish.
The best for iOS devices is GeoMipmaps.
GeoClipmaps is the best overall, but requires vertex-shader texture reads.
GeoMipmaps is the next overall best and is fully compliant with the capabilities of iOS devices, as it requires no vertex-shader texture reads. Unity 3D proves that GeoMipmaps are viable and fast on iOS devices.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

So I'm having a hugely difficult time visualizing some aspects of this in my head, which is a big part of the way I program things. There's that and some other things I can't seem to understand about terrain lod, specifically geomipmapping. I am starting to get a handle on it, but no matter how many threads or pages I read I just can't seem to get a clear view of what I'm programming.

So let me get this straight:

  1. With geomipmapping you start with a quadtree.
  2. That quadtree is subdivided enough times to give you the number of patches you want along the sides of the terrain.
  3. Each leaf node has an index buffer for each level of detail, each connected to a single vertex buffer (assuming the main vertex buffer is below 5MB)
  4. Magic stitching happens that I still don't have a clue about that fixes gaps between patches with differing lod values


Is this even near the ballpark?
GeoMipmapping does not use quad-trees (although it can). It typically uses grid-based tiles that are subdivided. You are describing progressive GeoMipmapping which is more advanced than you probably need.
GeoMipmapping can be very simple to implement in its most basic form. It is just a grid of terrain chunks that decrease in resolution by half the further away they are from the camera. You can decide which LOD to apply to any check using metrics as simple as this or optionally more complicated such that you account for view angle over the chunk etc.

You can also worry about the gaps later. Get the basic implementation down first and then you will start to understand the rest.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I only use the quadtree for culling purposes, the leaves of the quadtree hold the geomipmapping grid and the leave spaces are defined as the bounding box of the vertices used by that terrain patch. The branches are defined as a bounding box that contains all of its children. That way I can cull it all. That's not important though.

So here's what I have:
Terrain patches have MaxLOD number of index buffers which reference a vertex buffer for that patch, I realize that using vertex buffers for each patch isn't efficient enough, but it's just to get it working first.

At initialization the vertex buffers are created and then each lod level is created like this:
[source lang="cpp"]void GeoPatch::GenerateBuffers(const Vector2f &TopLeft,i32 Size,UHeightMap *HeightMap)
{
Vertices.Clear();
Vertices.SetRenderPrimitives(GL_TRIANGLES);
Vertices.ToggleVertexTexCoords();
Vertices.SetMaterial(UMaterial::GetBasicTextureMaterial());
Vertices.GetMaterial()->SetTexture(0,HeightMap->Map);

Vector2f TexScale = Vector2f(1.0f / HeightMap->Map->GetTexDimensions().x,1.0f / HeightMap->Map->GetTexDimensions().y);

for(u16 y = 0;y <= Size;y++)
{
for(u16 x = 0;x <= Size;x++)
{
u16 cx = TopLeft.x + x;
u16 cy = (HeightMap->Map->GetTexDimensions().y - TopLeft.y) + y;
Vector2f c(cx,cy);

Vertices += HeightMap->GetVertexAtPos(c);
Vertices.SetTexCoord(c * TexScale);
}
}

#define Idx(x,y) (((y) * (Size + 1)) + (x))
u16 Sy = TopLeft.y + Size >= HeightMap->Map->GetTexDimensions().y ? Size - 1 : Size;
u16 Sx = TopLeft.x + Size >= HeightMap->Map->GetTexDimensions().x ? Size - 1 : Size;

Indices[0].Clear();
Indices[0].Vertices = &Vertices;
for(u16 y = 0;y < Sy;y++)
{
for(u16 x = 0;x < Sx;x++)
{
Indices[0] += Idx(x + 0,y + 0);
Indices[0] += Idx(x + 0,y + 1);
Indices[0] += Idx(x + 1,y + 1);

Indices[0] += Idx(x + 0,y + 0);
Indices[0] += Idx(x + 1,y + 1);
Indices[0] += Idx(x + 1,y + 0);
}
}

for(u8 Lod = 1;Lod < Parent->MaxLOD;Lod++)
{
Indices[Lod].Clear();
Indices[Lod].Vertices = &Vertices;
u8 Skip = Lod * Lod;

for(u16 y = 0;y < Sy;y += Skip)
{
for(u16 x = 0;x < Sx;x += Skip)
{
Indices[Lod] += Idx(x + 0 ,y + 0 );
Indices[Lod] += Idx(x + 0 ,y + Skip);
Indices[Lod] += Idx(x + Skip,y + Skip);

Indices[Lod] += Idx(x + 0 ,y + 0 );
Indices[Lod] += Idx(x + Skip,y + Skip);
Indices[Lod] += Idx(x + Skip,y + 0 );
}
}
}
#undef Index
}[/source]

The code is pretty straightforward, Size = size of terrain patch, TopLeft = top left of terrain patch, Heightmap = the heightmap..

That's not important either. Just know that it sort of works even though it presents some graphical errors probably from not using power of two + 1 size heightmaps or whatever has to happen there. I'm sort of fuzzy on that and haven't found anything around the internet that clearly defines it.

I haven't implemented anything to choose LOD yet

This topic is closed to new replies.

Advertisement