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

Portal visibility culling

7 posts in this topic

I have a couple of questions about portal systems for visibility determination that I couldnt find any info on and I hope somebody here could answer.

How do you keep track of which cell the player is currently in? Do you contain each cell in a bounding box? if so, what about cells that aren't box shaped?

Also I have read that a good method is to project the portal into screen space and check which objects in the connecting cell are within the 2d bounds of the portal. Could anybody explain how to do this I dont really understand how to project the portal from world to screen space and test collisions with objects this way.

thanks,
0

Share this post


Link to post
Share on other sites
[quote name='lukesmith123' timestamp='1342472858' post='4959744']How do you keep track of which cell the player is currently in? Do you contain each cell in a bounding box? if so, what about cells that aren't box shaped?[/quote]If your cells aren't box shaped, they should probably be [url="http://en.wikipedia.org/wiki/Convex_polytope"]convex polytopes[/url]., which can be described as an array of planes ([i]if a point is on the 'inside' of every plane in the array, then it's inside the polytope[/i]). You can start by checking against each cell's bounding box first ([i]which might give more than 1 result[/i]), and then do the more expensive plane test for every cell that passed the first test.
[quote]Also I have read that a good method is to project the portal into screen space and check which objects in the connecting cell are within the 2d bounds of the portal. Could anybody explain how to do this I dont really understand how to project the portal from world to screen space and test collisions with objects this way.[/quote]To project a point from world to screen, you multiply it with the view-projection matrix.
1

Share this post


Link to post
Share on other sites
Ok, so would you check the players bounds against all of the cell bounding boxes each frame? or would you need to keep track of the players movement through portals to speed this up?


So when you project the corners of the portal into screen space and build a 2D bounding box from them how do you project the objects to screen space and get a 2D box from those? Would you take the corners of the objects bounding box and project them to screen space and then create the smallest 2D box from the 8 corners?

Thanks so much for the tips!
1

Share this post


Link to post
Share on other sites
[quote name='lukesmith123' timestamp='1342513169' post='4959924']
Ok, so would you check the players bounds against all of the cell bounding boxes each frame? or would you need to keep track of the players movement through portals to speed this up?[/quote]In theory, the latter is optimal. However, it's probably complicated to implement, wheras the former option is simple (if somewhat brute force). I'd probably default to the first option, and only worry with the complexity of actually tracking the player if it turned out to be prohibitively slow.
[quote]So when you project the corners of the portal into screen space and build a 2D bounding box from them how do you project the objects to screen space and get a 2D box from those? Would you take the corners of the objects bounding box and project them to screen space and then create the smallest 2D box from the 8 corners?[/quote]Yes, you could project all 8 points and take the min/max to get their 2D bounds.

Also, I forgot to mention before that projection requires a few more steps than just "[i]multiply with the view-projection matrix[/i]". After that multiply, you've got a vec4 result -- to convert that to a 2D position you've then got to perform perspective division, which means divide the result by it's own [font=courier new,courier,monospace]w[/font]/[font=courier new,courier,monospace][3][/font]/[font=courier new,courier,monospace]4th[/font] component. That then gives you a 2D point from (-1,-1)to(1,1), so you've then got to remap it if you want a (0,0)to(1,1) value, e.g. [font=courier new,courier,monospace]final = result * 0.5 + 0.5[/font]

Alternatively, you can turn this around and transform your portal's 2D bound into a 3D frustum. If you take the 4 corners of that bounding rectangle, and unproject them (mul with inverse viewproj matrix) with z=0 and z=1, then you get 8 3D points that are the bounding frustum of the portal. This frustum (bounding volume of the 8 points) is equivalent to 6 planes -- instead of the above 2D test, you could test each object's 3D bounds against this 3D frustum.
2

Share this post


Link to post
Share on other sites
One thing, with the last point you made, would that not be a much slower method than just creating a frustum from the 4 corners in the first place?

Also do you have any opinion on whether projecting to screen space vs creating frustums from the portals is faster?
0

Share this post


Link to post
Share on other sites
Yes the screen space idea is probably simple and fast. I mentioned the 3D case just to get you thinking about other possibilities.

e.g. A more advanced 3D version would take the 2D outline of each portal (could be more than 4 sides -- e.g. an octagonal window portal) and create a plane from the observer's position and each of those lines, so the 3D 'frustum' for testing is an extruded octagon instead of an extruded rectangle.
2

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