• 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
Doug Bischoff

Occlusion Query for Logic - not Graphics?

4 posts in this topic

I've been doing a lot of research on managing "what can each game agent see" in 3D space. The main problems being:[list=1]
[*]What is the FOV (field of view) of the object? (which in my application MAY be 360 degrees spherical, or not: we're in space)
[*]What objects may be blocking line of sight?
[/list]
At this point, I am [b]not[/b] interested in drawing these objects: I'll handle that later, though it may well be that the solutions here will inform my choice of drawing engine (Mac OS, iOS, Objective-C being my targets). What I [b]am[/b] interested in is just the game logic side of things. Pretend for a moment that there is no user interface: we're just letting a computer crunch through the 3D world.

It appears that (as one other poster put it) my problem is one of occlusion. I've researched Occlusion Querying in OpenGL and it seems very promising. All the examples, however, seem to point to "how to use this information to draw more efficiently." What I am asking is "how might it be used to inform game LOGIC?"

For example, take 5 spaceships in our solar system. All arrayed in random places. When it's each object's turn to decide "what do I do," I need to know who they can see. If there's a planet in the way, call that a "major occluder" and it will definitely hide things behind it. If it's another ship, that too could be a major occluder if it were big enough (so say we have a simple isMajorOccluder property). Smaller ships, asteriods, debris, etc. for the sake of argument would all "not count" as occluders.

What I'm trying to arrive at is, for each of the 5 ships, a simple list of what they can see.

Am I over-thinking this? Or is building the universe in OpenGL and using occlusion queries the right approach? Could someone pseudo-code how this might work?

Thanks for any advice,

-Doug
0

Share this post


Link to post
Share on other sites
[quote name='Doug Bischoff' timestamp='1352036378' post='4997162']
Or is building the universe in OpenGL and using occlusion queries the right approach?
[/quote]
This is valid. For really correct determination I would always test ship pairs. First ship is the camera, the second ship is the target. To test it, draw the whole scene without the target ship (use only approximations of the real ships, no need to render the hi-detail ships) in the zbuffer only. Then render the target ship using the occlusion query. This will work and you will get the number of covered pixels. But you need to be careful to not interference with the rendering pipeline , ie. occlusion queries are a good way to stall the render pipeline, best to check the results of the queries the next frame to avoid flushing the command queue.

[quote name='Doug Bischoff' timestamp='1352036378' post='4997162']
Am I over-thinking this?
[/quote]
Do you really need this level of accuracy ? You could use your physics engine and a hand full of ray-tests to determine the visibility too. Maybe you could use both systems, the accurate one for the players ship sensors and an not so accurate, but faster, one for AI ships. Edited by Ashaman73
0

Share this post


Link to post
Share on other sites
First of all i like the idea, but it has some potential problems.
-Possible problem is to drawing 360 fov view in single pass. If im not mistaking, projection matrix does not allow fov of 360.
-Occlusion query stalls your GPU. Perhaps not important for you, but its good to keep it in mind.
-The resolution will determain the precision of your approximation.
-If to split 360 pass into 2x 180 fov, you will still face precision problems: low approximation precision on the edges.
-also possible to split into 6x 90 fov passe, same way cubemaps are generated. i would defenatly go for this one.

Modern engines use a very simple software rasterizer to solve occlusion problems (has still same problems for your solution) to stay away from gpu.

Basic unoptimized approach would be something like:
-draw all objects that are potential occluders in on cubemap (6x 90 fov). Except the one that will be tested.
-do occlusion query test on object of interest on each of 6 rendertargets.
-sum the result.

In my opinion it will be a heavy process and not consistent.

Have you considered to do any other tests then occlusion query?
I would recommend to try something in direction of simplified object-models and raytracing heuristics.
Like:
Sphere1 - occluder
Sphere2 - object of visibility interest.
-is sphere1 aligned with sphere2 and how much? Can be tested with simple dot-product.
-how does does my current fov effect the corelation of delta distance and sphere sizes.

Good luck!
0

Share this post


Link to post
Share on other sites
[quote name='Vlad86' timestamp='1352043503' post='4997201']
-also possible to split into 6x 90 fov passe, same way cubemaps are generated. i would defenatly go for this one.
[/quote]

Ah, I like this. Doing 90 fov's would allow me to specify which 90's a particular object can "see" in. Not all will have 360 spherical "vision."

[quote name='Vlad86' timestamp='1352043503' post='4997201']
Have you considered to do any other tests then occlusion query?
I would recommend to try something in direction of simplified object-models and raytracing heuristics.
[/quote]

I am fine with simplifying the object models down to bounding boxes: I don't need massive accuracy, just consistency. My concern with doing a simple raytracing was that a large object looking at a large object around a medium object SHOULD be able to see it, but if you used a raytrace from obcenter to obcenter you may get a wrong answer. Or maybe I misundestood? Here's what I do [b]not[/b] want to have happen:
[img]http://www.ceridwenproductions.com/images/Content/GamePost1_Fig1.gif[/img]
"Blue Box" is judged to NOT be able to see "Red Box" because a ray cast from center to center passes through "Black Circle." By using a z-buffer or occlusion query I had figured that the result would be to show which objects (and if I understand occlusion query return values correctly) how MUCH of that object is visible.

[quote name='Ashaman73' timestamp='1352043295' post='4997199']
For really correct determination I would always test ship pairs. First ship is the camera, the second ship is the target. To test it, draw the whole scene without the target ship (use only approximations of the real ships, no need to render the hi-detail ships) in the zbuffer only.
[/quote]

Pretty close to what I was thinking. My process was something like this pseudo-code:
[source lang="plain"]foreach ( object ) {
setCamera ( object is camera );
foreach ( object_that_isnt_me ) {
if ( occlusion_query( me, object_that_isnt_me ) ) {
objectsICanSee[] = object_that_isnt_me
}
}
}[/source]
In other words, build an array for each object that contains every object that isn't occluded.

[quote name='Ashaman73' timestamp='1352043295' post='4997199']
Do you really need this level of accuracy ? You could use your physics engine and a hand full of ray-tests to determine the visibility too. Maybe you could use both systems, the accurate one for the players ship sensors and an not so accurate, but faster, one for AI ships.
[/quote]

Ah! Yes: I wondered if a physics engine might help somehow. The level of accuracy should be "decent" as long as it's repeatable and relatively good. I confess ignorance on how a physics engine and ray testing might help here. Could you offer a snippet that might help me understand?

Thank you both!
0

Share this post


Link to post
Share on other sites
[quote name='Doug Bischoff' timestamp='1352052064' post='4997249']
Pretty close to what I was thinking. My process was something like this pseudo-code:
?
foreach ( object ) { setCamera ( object is camera ); foreach ( object_that_isnt_me ) { if ( occlusion_query( me, object_that_isnt_me ) ) { objectsICanSee[] = object_that_isnt_me } }}
In other words, build an array for each object that contains every object that isn't occluded.
[/quote]
Remember, that you need to have a valid zbuffer to do the occlusion query, that is, you need to render the complete scene from the perspective of each object before starting the occlusion_query. Your code should look more like this:
[CODE]
foreach ( object ) {
foreach ( object_that_isnt_me ) {
setCameraPointingToTarget ( object is camera, target is object_that_isnt_me );
hide(object_that_isnt_me );
hide(object); // prevent self occlusion

renderScene();
if ( occlusion_query( me, object_that_isnt_me ) ) {
objectsICanSee[] = object_that_isnt_me }
show(object_that_isnt_me );
show(object);
}}
[/CODE]

[quote name='Doug Bischoff' timestamp='1352052064' post='4997249']
I confess ignorance on how a physics engine and ray testing might help here.
[/quote]
A raytest would just check if a ray, or line, collides with a object. The simplest way would be to just doing one ray test between the centers of two ships. This would be very fast and could run concurrently to the GPU. Though one ray test would be often not enough, I would suggest to use several rays or even better an adaptive approach (start with one => not visible, use more). This way you have finer control (LOD), take some burden from the GPU.

But eventually it is just an other option, your GPU approach is valid and what is better really depends on a lot of factors (number of obstacles, number of ship pairs, accuracy, rendering demand, mutlicore support etc. )

A naive approach of your GPU solution would be to render the models as they are, this is very similar to shadow mapping and you will not see lot of shadow maps in current gen games compared to the number of lights (handful of shadow maps vs 100th of lights). A much faster way would be to use bounding hulls consisting only of a few polys, putting the static scene into a single batch and using a low resolution map to determine the visibility. The latter would be not really a problem, especially if you only check the visibilty each X seconds. Edited by Ashaman73
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