• 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
BrechtDebruyne

mesh culling (octrees)

16 posts in this topic

So, I've gotten to the point in my engine where I want to implement mesh culling.

But I don't really understand octree culling that seems to be so popular:

1) If we take into account that every mesh can be moving, we would have to do [number of meshes in the scene (tested against octree leaves)]+[number of octree aabbs (tested against view frustrum)] aabb tests each frame.
But without an octree, I would just have to do [number of meshes in the scene (tested against view frustrum)] aabb tests per frame. So why would I use an octree?

2) I have read some articles that do octree culling for polygons, and not entire meshes. Why would I want to do that? It just seems like more draw calls to me. And then there's instancing as well, I don't see how it can work with that?

Thanks [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Xcrypt
0

Share this post


Link to post
Share on other sites
[quote name='Xcrypt' timestamp='1337570869' post='4941801']1) If we take into account that every mesh can be moving, we would have to do [number of meshes in the scene (tested against octree leaves)]+[number of octree aabbs (tested against view frustrum)] aabb tests each frame.
But without an octree, I would just have to do [number of meshes in the scene (tested against view frustrum)] aabb tests per frame. So why would I use an octree?[/quote]So maybe a naiive octree isn't the best data structure for your particular type of scene? N.B. there's a lot of variations of octrees that are better designed for dynamic data.[quote]2) I have read some articles that do octree culling for polygons, and not entire meshes. Why would I want to do that? It just seems like more draw calls to me. And then there's instancing as well, I don't see how it can work with that?[/quote]What was the date on those articles? 15 years ago when octrees were cool, the world rendering loop looked more like [font=courier new,courier,monospace]for each polygon: set states, draw polygon[/font] instead of [font=courier new,courier,monospace]for each batch, set states, draw triangles[/font]. Often this was done using immediate mode, instead of using batching at all...
1

Share this post


Link to post
Share on other sites
[quote name='Xcrypt' timestamp='1337570869' post='4941801']
But without an octree, I would just have to do [number of meshes in the scene (tested against view frustrum)] aabb tests per frame. So why would I use an octree?
[/quote]
As hodgman stated, octrees are not the best fitting data structure for every cases. They are very easy and good for (almost) static data, for dynamic data, take a look i.e [url="http://en.wikipedia.org/wiki/Sweep_and_prune"]sweep'n'prune[/url].

You should build an interface around a collection of data structures (i.e. use octtree for static, grid for terrain, sweep'n'prune for dynamic data) to ease its access. When you want to start with a single data structure, stick to a dynamic one (I'm still only using sweep'n'prune for static and dynamic objects in my engine).
1

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1337576381' post='4941821']
What was the date on those articles? 15 years ago when octrees were cool, the world rendering loop looked more like [font=courier new,courier,monospace]for each polygon: set states, draw polygon[/font] instead of [font=courier new,courier,monospace]for each batch, set states, draw triangles[/font]. Often this was done using immediate mode, instead of using batching at all...
[/quote]
I guess they were pretty old indeed :)

[quote name='Ashaman73' timestamp='1337579794' post='4941831']
octrees are not the best fitting data structure for every cases. They are very easy and good for (almost) static data, for dynamic data, take a look i.e [url="http://en.wikipedia.org/wiki/Sweep_and_prune"]sweep'n'prune[/url].

You should build an interface around a collection of data structures (i.e. use octtree for static, grid for terrain, sweep'n'prune for dynamic data) to ease its access. When you want to start with a single data structure, stick to a dynamic one (I'm still only using sweep'n'prune for static and dynamic objects in my engine).
[/quote]
Thanks, looking into swee'n'prune now
0

Share this post


Link to post
Share on other sites
[quote name='Xcrypt' timestamp='1337570869' post='4941801']
So why would I use an octree?
[/quote]

When a mesh moves, you can test first against the former octant's AABB to check if it still belongs there. This should account for most cases during a frame, and as an AABB <> AABB check, it should be less expensive than an AABB <> frustum check.

Also if an octant is entirely visible (inside the frustum), all its child octants and the meshes contained within are known to be visible without any further intersection tests.
0

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1337579794' post='4941831']
When you want to start with a single data structure, stick to a dynamic one (I'm still only using sweep'n'prune for static and dynamic objects in my engine).
[/quote]

I'm sorry but, I don't see how sweep and prune applies to this. It seems like something for collision detection between several AABBs, which I can imagine to be very useful in collision detection engines, but how does this apply to view frustrum culling?
0

Share this post


Link to post
Share on other sites
I'm sorry but I haven't understood if you have view frustum culling working or not?

If the problem your facing is how to view frustum cull dynamic objects, you can create the AABB and transform it to view space and do the view frustum culling in view space.

Plus, in order to speed frustum culling in my engine I group meshes in nodes, and each node has a bounding sphere. So I test if the node bounding sphere is inside the view frustum:
- if yes - all meshes of the node are inside view frustum;
- if no - all meshes of node are outside view frustum;
- if the sphere intersects the view frustum - check if the AABB of each mesh are inside the view frustum. Edited by TiagoCosta
0

Share this post


Link to post
Share on other sites
[quote name='TiagoCosta' timestamp='1337628641' post='4941992']
I'm sorry but I haven't understood if you have view frustum culling working or not?

If the problem your facing is how to view frustum cull dynamic objects, you can create the AABB and transform it to view space and do the view frustum culling in view space.

Plus, in order to speed frustum culling in my engine I group meshes in nodes, and each node has a bounding sphere. So I test if the node bounding sphere is inside the view frustum:
- if yes - all meshes of the node are inside view frustum;
- if no - all meshes of node are outside view frustum;
- if the sphere intersects the view frustum - check if the AABB of each mesh are inside the view frustum.
[/quote]
Well it's not about getting it to work - testing an AABB against a view frustrum is not particularly difficult- it's about getting a to work fast.

Your optimisation of grouping them into spheres is a good example of what I'm looking for, but I'm just wondering if there are other exotic ways of doing it.
I can't seem to find any recent articles on frustum culling either ( other than the basics [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] )
Octree looks great for static objects, but I'm not sure what to do for dynamic objects (objects that move a lot). Sweep and prune has been mentioned but that looks more like a way of testing the AABBs against each other than testing them against a view frustum, so I'm not sure how it applies to frustum culling.

A question about your culling system: based on what parameters do you group meshes into spheres? Edited by Xcrypt
0

Share this post


Link to post
Share on other sites
[url="http://publications.dice.se/attachments/CullingTheBattlefield.pdf"]http://publications....Battlefield.pdf[/url]
How many objects do you have? Less than 15k? Just use brute force and linear arrays. It's ridiculous fast.
Just tested that I can do around 1000 sphere vs frustum check in 2ms with java code on my android. My data is not even linear there are no structs on java and its cheap chinese android phone. Just pick the simplest way. Optimize it 5minutes and pick more interesting problem. If it's gonna be bottleneck its easy to optimize further or offload to another core.

[CODE]
/**
* Returns wheter the given sphere is in the frustum.
*
* @param center
* The center of the sphere
* @param radius
* The radius of the sphere
* @return Wheter the sphere is in the frustum
*/
public boolean sphereInFrustum(Vector3 center, float radius) {
for (int i = 0; i < 6; i++)
if ((planes[i].normal.x * center.x + planes[i].normal.y * center.y + planes[i].normal.z
* center.z) < (-radius - planes[i].d))
return false;
return true;
}
[/CODE]
1

Share this post


Link to post
Share on other sites
can't really access the data linearly as state caching is more important than culling. Looking at that link you give me now though, thanks for sharing :) Edited by Xcrypt
0

Share this post


Link to post
Share on other sites
FWIW I also use a system similar to what is presented in that Battlefield paper. On my Xeon W3550, my SSE optimized code clocks in at 16k sphere-frustum checks in at about 0.12ms (1 thread), which is plenty fast enough for me. It didn't take too much effort to rework the data structures so the spheres were accessed linearly in memory and really the code ended up considerably simpler (IMO).
1

Share this post


Link to post
Share on other sites
[quote name='Xcrypt' timestamp='1337635513' post='4942013']
can't really access the data linearly as state caching is more important than culling. Looking at that link you give me now though, thanks for sharing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]This doesn't make sense to me -- the culling data is positions/bounds, which aren't render-states. Storing positions/bounds in a linear array should have no impact on your render state caching/sorting.
0

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1337658931' post='4942078']
[quote name='Xcrypt' timestamp='1337635513' post='4942013']
can't really access the data linearly as state caching is more important than culling. Looking at that link you give me now though, thanks for sharing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]This doesn't make sense to me -- the culling data is positions/bounds, which aren't render-states. Storing positions/bounds in a linear array should have no impact on your render state caching/sorting.
[/quote]
Nvm that! It doesn't make much sense :) I confused it with something else.
0

Share this post


Link to post
Share on other sites
I've just recently come across this question myself so I thought I'll just add to this thread instead of creating a new one.

I'm actually more interested in the higher level design of managing a scene and incorporating multiple culling techniques rather then implementation details of said techniques. To be more specific here's a number of questions:

1) Is there such thing as a scene manager these days? If so, what is its purpose exactly? Does it manage a group of spatial views and automagically determine which one an object gets inserted into?
2) When and who determines what culling technique are applied to objects? (Eg. static vs. dynamic objects)
0

Share this post


Link to post
Share on other sites
I'm not an expert on the matter, but from what I have read in recent articles, scene graphs are a no-go today. I would like some enlightenment on the topic too.
0

Share this post


Link to post
Share on other sites
[quote name='Xcrypt' timestamp='1338340402' post='4944509']
I'm not an expert on the matter, but from what I have read in recent articles, scene graphs are a no-go today. I would like some enlightenment on the topic too.
[/quote]
Scenegraphs themselves can be useful, but having them heavily tied into other systems is a no-go. All the scenegraph should be responsible for is concatenation of transforms - and thats a distinct process that can be done in isolation before culling even begins.
0

Share this post


Link to post
Share on other sites
[quote name='Digitalfragment' timestamp='1338351404' post='4944544']
[quote name='Xcrypt' timestamp='1338340402' post='4944509']
I'm not an expert on the matter, but from what I have read in recent articles, scene graphs are a no-go today. I would like some enlightenment on the topic too.
[/quote]
Scenegraphs themselves can be useful, but having them heavily tied into other systems is a no-go. All the scenegraph should be responsible for is concatenation of transforms - and thats a distinct process that can be done in isolation before culling even begins.
[/quote]
Not to confuse the issue or nitpick, but what you are describing is a hierarchical tree and not a graph. A hierarchical tree generally has only one meaningful way to traverse, (that is from top-down) and can therefor only be optimized for a single purpose.

A scene graph in the traditional sense is a multipurpose database that can be traversed in many different ways to visit nodes in different optimal orders for different purposes. The thing about "scenegraph" is that it has turned into a blanket term that gets thrown around and misrepresented. If you're just storing a tree to do transforms to/from world space, then you don't have a scene graph so don't even call it that.

They are not an obsolete concept and they did not die out with the fixed function pipeline, as I think is a commonly held belief. They are just as applicable today as they ever were, they just didn't turn out to be all that useful in practice and are really more trouble than they are worth.

On the other hand, if you were to embed an [url="http://en.wikipedia.org/wiki/Graph_database"]existing[/url] graph database and actually squeeze some good real-time performance out of it, you'd have a potentially very powerful tool at your disposal. I just don't see the need, it's overkill in most cases.
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