• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Darkbouncer4689

QuadTree Terrain with Odd # of Vertices

7 posts in this topic

Hey all,

I'm implementing a quadtree for my terrain as the first step in GeoMipMap LoD. The problem I'm facing is that for GeoMipMap LoD one must have 2^n + 1 vertices along the width and length of the terrain. Since quadtree's split evenly into 4 boxes on each step, it would mean that I will have a huge number of triangles that get intersected right down the middle each time. That is not very ideal =(

As quadtree's and GeoMipMap LoD go hand in hand, I'm sure there must be an elegant solution for this. Anyone have any resources that I could check out?

Thanks in advance!
0

Share this post


Link to post
Share on other sites
[quote name='Darkbouncer4689' timestamp='1314935429' post='4856584']
Hey all,

I'm implementing a quadtree for my terrain as the first step in GeoMipMap LoD. The problem I'm facing is that for GeoMipMap LoD one must have 2^n + 1 vertices along the width and length of the terrain. Since quadtree's split evenly into 4 boxes on each step, it would mean that I will have a huge number of triangles that get intersected right down the middle each time. That is not very ideal =(
[/quote]

It is very ideal, because you don't split the vertices, but the the area between vertices and as you will notice, every chunk of terrain will obviously share some vertices with its neighbor. Yes, you end up duplicating a few vertices or indices (depending on your approach).

Also, there is no point in starting with the quadtree for this as you can do implement it completely without any trees. In fact, the first time around I ended up making it slower with a quadtree unless you had a few thousand chunks.

Thinks to avoid were:

-a "naive" tree implementation using pointers and wasting a ton of time chasing pointers to collect leaf nodes. Since your terrain is always a full quad tree, you don't need any pointers at all. Store each row of the tree consecutively as array and going from node to first child is a matter of (index * 4 + 1). Knowing the depth of the tree, once a node is fully visible, you can calculate the offset and number of leaf nodes and directly get to them.

-don't try to be super precise in your culling. The false positives of using spheres are more than made up for with the faster frustum test.

But first, the interesting part is deciding how you want to connect chunks of different lod. You can be lazy and just use skirts or create index buffers for connectors. Also, there is no point in storing all three coordinates per vertex. You can use offsets per chunk and a single set of x/z coordinates and index buffers. A second buffer holds only y values. That should save enough memory to allow for fairly large terrains.
2

Share this post


Link to post
Share on other sites
I thought when you have triangles that get intersected they would just get stuck at the top root node?

If I understand what you're saying, the solution is to split an intersected triangle into two triangles that will each be fully contained in their respected boxes?
0

Share this post


Link to post
Share on other sites
When you have 2^n+1 vertices you will have vertices along the edge of any 2^n division.

. . .
. . .
. . .

That is the simplest. Your leaf level triangles will always fall on boundaries. Now, higher levels in the tree will indeed be problematic. This is why when I wrote a geomimap terrain renderer I dropped the quadtree for a simple array of patches evenly chopping the world. Each having a set of index buffers defining the LOD level triangles. Your neighbor determination becomes trivial and frustum culling isn't that big a deal against the patch boundaries. Your LOD level choice is also trivial.

I have seen others want to use quadtrees as well but I also believe the 2d or 1d with fancy indicing arrays are easier to use for this style of LOD.
1

Share this post


Link to post
Share on other sites
[quote name='Darkbouncer4689' timestamp='1314941489' post='4856598']
If I understand what you're saying, the solution is to split an intersected triangle into two triangles that will each be fully contained in their respected boxes?
[/quote]

It was already mentioned, but just to be sure: there will never be "intersected triangles". You select a chunk size (32x32 should be the absolute minimum or the overhead for draw calls will kill whatever benefit the lower lod might give you). Each chunk is a leaf node in your tree. For nodes form a node in the next level of the tree. At no point should your tree care about what a vertex is, since it only deals with groups of chunks.

For a map size of 1024x1024 or less you will also have to really optimize your tree to make it faster than just culling every single chunk. In fact, you should do that and get the rest working before worrying about it. Changing culling to use a tree later on shouldn't require huge changes.
1

Share this post


Link to post
Share on other sites
Thanks for the tips guys. I was following a quadtree terrain tutorial at [url="http://www.rastertek.com/tertut05.html"]http://www.rastertek.com/tertut05.html[/url], but I'm beginning to think it it not very good unfortunately.

His method for constructing the quadtree is to have some maximum number of triangles that you want in each node, and then to keep dividing until you get down to a node with less than that max number. He then performs a geometry check for each triangle in the terrain to see if it is contained in the nodes box, and if so adds it to the quadtree's node.

I'm thinking that this isn't a very nice design and I could, as Trienco has suggested, recursively break my terrain into blocks of 4 pages until I get to some minimum page size (such as 32x32). I could then just add each page to the nodes of the quadtree in hierarchical order. It seems like this design would be much faster and less code, but I haven't gotten into the details of it yet so I'm not positive it will work.

I'll keep at it until I have a nice design!

Update:
After spending a few hours I was able to implement the design above. I am pretty happy with it. I feel like it is a better design than the tutorial I was following. Using his method a 1024x1024 terrain grid would require around 1 million triangle/box containment tests, where as this method could build a quad tree for even a 4096x4096 terrain pretty fast.
0

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  
Followers 0