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

Octrees: Precomputed visibility and rendering approach

3 posts in this topic

Hello guys,

 

Right now i'm working on a game engine for a game i want to make, this is mainly for research and learning purposes.

 

I have most of the rendering base code done, loading meshes from a custom format aswell as materials and other stuff, however, in the last days i've been doing some research about what space partitioning method should i use for my world geometry.

 

I've been reading about KD-Trees, Octrees (and it's smaller variants) and BSP Trees, out of the three i guess i will stick with Octrees because it allows both outdoor and indoor efficient culling of geometry (or that's what i understood), the game will be mainly indoor but because of the nature of the project i wanted some generic way to make both types of scenes.

 

I've got the concept of octrees pretty well and i dont think i will have problems when implementing them (Im a self-taught graphis programmer), however there are some concepts that i dont get a clear view when i think about them, mainly precomputed visibility of nodes and what would be the most efficient way to render each visible node.

 

For the first i thought of the hardcore way, for each node check which nodes are visible (just like portals), this is kinda heavy for a complex scene but i dont mind to spend some time on precomputing visibility, the other i thought is to do the checking on the fly based on the camera frustum bounding box or the frustum planes themselves.

 

The other is once you determine which nodes are visible, what would be the most efficient way to render them.

 

The first approach i thought was to build a list of indices of the visible triangles and send them to the rendering API to be processed, main problem with this is that is kind of CPU intensive i guess since you would have to iterate over all the nodes, grab the indices of the polygons inside them and copy them over the active index buffer.

 

The second was to make a index buffer for each visible node and render each node manually, main problem with this is the memory overhead (i guess that DX/OGL uses extra memory per each created index buffer besides the memory needed to hold the indices itself) and the increased draw calls, both for the drawing itself and the switching between index buffers.

 

The third is to precompute a index buffer of the visible polygons for each node, same issue with memory as the second method.

 

I ask the help and opinion of the experts over here about what would you guys recommend me in order to create the best possible design.

 

Thanks!

Edited by Lambdacerro
0

Share this post


Link to post
Share on other sites
I suggest splitting your static data on node boundaries after you have your visibility graph, since this allows you to associate data with nodes of your tree partition. Then you just draw the static geometry associated with that node if the node is visible. If you have instanced geometry in a node, you can just conservatively make the whole object visible - just be sure to do a scoreboard/mailbox check so that you don't draw it once for each visible node it intersects. You may want to do the same for non-instanced geometry if your subdivision is very fine and results in a lot of splits (since this will result in more draw calls).

For dynamic objects, you can easily (via a hierarchical test) figure out which nodes it intersects, and if it intersects a visible node, then it is treated as visible.

BTW, How do you intend to compute the PVS for the nodes? (which approach/algorithm - it's a difficult problem)

For best results, I suggest a general axially aligned BSP tree, since you ideally want to keep your leaf nodes cubic.
0

Share this post


Link to post
Share on other sites

I suggest splitting your static data on node boundaries after you have your visibility graph, since this allows you to associate data with nodes of your tree partition. Then you just draw the static geometry associated with that node if the node is visible. If you have instanced geometry in a node, you can just conservatively make the whole object visible - just be sure to do a scoreboard/mailbox check so that you don't draw it once for each visible node it intersects. You may want to do the same for non-instanced geometry if your subdivision is very fine and results in a lot of splits (since this will result in more draw calls).

For dynamic objects, you can easily (via a hierarchical test) figure out which nodes it intersects, and if it intersects a visible node, then it is treated as visible.

BTW, How do you intend to compute the PVS for the nodes? (which approach/algorithm - it's a difficult problem)

For best results, I suggest a general axially aligned BSP tree, since you ideally want to keep your leaf nodes cubic.

 

Thank you for the answer, the AA BSP Tree might be a good idea.

 

I already thought about how to filter dynamic objects just in the same way you said, basically each entity would know in which cell its located so the entity knows what's visible (useful for IA), same as player basically.

 

My idea to compute the PVS was to go raycast from each cube corner to all the other cubes, main problem with this is that it will be really expensive based on the fact that each cube have 8 childs, i was thinking to just raycast to the "bigger" cubes (either by area or polygon count) this way i would be able to still skip rendering of hidden geometry and not take ages to compute the visibility.

0

Share this post


Link to post
Share on other sites

My idea to compute the PVS was to go raycast from each cube corner to all the other cubes, main problem with this is that it will be really expensive based on the fact that each cube have 8 childs, i was thinking to just raycast to the "bigger" cubes (either by area or polygon count) this way i would be able to still skip rendering of hidden geometry and not take ages to compute the visibility.

 

I think that you will find that you need to ray-cast from a lot more than the corners to prevent popping/false-invisibility.  If you subdivide far enough, this won't be an issue, but then you land up with an extremely dense octree that takes ages to compute (most of the computation is redundant since you are mostly sampling the same lines again and again). For best results you will likely need to densely sample the full line space between your source and destination nodes.  This can be done by ray-casting from all over the surface of your source node (to all over the surface of your destination node, stopping if visibility is established).

 

This problem has been well researched.  You should check out:

http://dcgi.felk.cvut.cz/home/bittner/publications/agvs/agvs.pdf

and

http://www.cg.tuwien.ac.at/.../WONKA-2006-GVS-Preprint.pdf

for CPU based sampling approaches tha attempt to minimize the number of rays cast.

 

You can also use the GPU to do the visibility determination for you, or compute it exactly:

http://nirenstein.com/wp-content/uploads/2012/10/thesis.pdf

Chapter 4 talks about using the GPU for sampling visibility.  The hardware at the time was dated: I expect that today you could avoid the readback by using occlusion queries or compute shader processing of the z-buffer.  Chapters 5 and 6 talks about computing the exact visibility set, but the math is a bit hairy, and it is probably overkill for mose use 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