Oclusion testing in a FPS,
Members - Reputation: 1144
Posted 24 January 2012 - 02:30 AM
Im working on a FPS using my own engine. I allready subdivide the map and use frustum culling to greatly reduce the amount of geometry i draw but its not enough it seems. When im standing on the outskirts of the map looking into it the frame rate drops even though im in a small little room and im staring at a wall. Im a little unsure of how to go about implementing oclusion testing in a FPS.Testing all the ojects against all the other objects that might be infront of it seems way too expensive. Im guessing I might have to do something like set up volumes and link objects to them. Like if the player is in volume X only objects a,b and c could possibly be vissible to him. (objects a,b and c being stationary. Like walls) or something like that. I could create a script to create these volumes on the maps and store it in the map files so the game doesnt need to do it. Does this sound like a feasible idea? or is there maybe a better solution that im missing.
Thnx in Advance!
Members - Reputation: 375
Posted 24 January 2012 - 03:22 AM
That's what I used and it worked great for my purposes.
I'm pretty sure there are loads of improvements you can do to it to make it work better for your particular purposes, like bunching close objects together when querying, and other tricks that take advantage of the overall designs of your maps.
However, note that I'm that sure there are plenty of data structures better suited for rough occlusion culling for FPSes than occlusion testing all objects I'm pretty sure, but it kind of depends on your ambition.
Members - Reputation: 1399
Posted 24 January 2012 - 03:56 AM
define a number of objects that can act as occluders (large in occlusion value, walls, boxes, simple buildings and low in poly count)
then for each frame grab the nearest 5 to 50 to ? of them depending on horse power, render those to a small buffer on the cpu.
next step is to test bounding boxes against this buffer, not the bb for every object but bb's from either a spatial structure or a custom set, you could divide your scene into a grid.
that way if you have some dense areas containing a large number of small objects or a large number of polygons, they can be culled away very quickly
it is by no means perfect occlusion culling but it is instant and gets a good ratio culled, so might work out for you.... if you have a massive open space with only small occluders it probably will not work so well.
(if you have raised terrain you can just plant in some planes that run along under any ridges and then you can really quickly (after drawing a few simple polys on the cpu) you can cull away objects on the other side of raised terrain pretty easily)
Members - Reputation: 1399
Posted 26 January 2012 - 10:55 AM
http://bwhiting.co.uk/b3d/occlusion/ <-- demo app here (will need flash player 11.1 - http://get.adobe.com/flashplayer/ )
What you will see (after a small wait while it loads)... is a simple terrain model with some boxes on it.
The boxes represent areas that will contain some complex data. i.e. a high poly model or 2 or 50 or whatever
The boxes will dissapear as soon as the high poly models are loaded in (in our case a lovely t-rex model)
The boxes are then occlusion tested against some predefined geometry that mimics some sections of the terrain.
You can see this in real time in the bottom left hand side of the screen where the occlusion buffer is rendered for your convenience as well as some dots representing the success/failure of bounding box occlusion queries.
As you can see, from some angles you can cut down the number of polygons sent to the GPU massively (from 3 million polys down to a few hundred thousand)
This was a super quick test just to try out an idea, it is not optimised and could run a great deal faster but you should get the idea.
If anyone is interested in the implementation details I could do a thorough write-up explaining how it all works.
Crossbones+ - Reputation: 2551
Posted 26 January 2012 - 05:15 PM
Members - Reputation: 647
Posted 26 January 2012 - 07:10 PM
Areas with tall occlusions of interior walls or buildings would be the best place to apply this technology.
It really all depends on your scene. Unfortunately our game has equal of both.
Members - Reputation: 1399
Posted 28 January 2012 - 04:04 PM
With regards to generating a low poly occlusion mesh, when i threw that terrain together in max, a plane with a much lower resolution (10x10 as opposed to 50x50) was used with the same displacement map and slightly tweaked values...and it generated a really good mesh! BUT! because it was an organic mesh, not a plane or box, it either needed to be z sorted or drawn with a z-buffer... which would slow things down considerably. At the moment no z-buffer is used when drawing the occluders.
The same thing should also be able to work just fine indoors too, just grad the nearest few walls and use them. that way if you indoor level could be divided into chunks, whole segments could be disregarded pretty quickly..
Have put together a few other scenes, and will make 2 more demos on Monday and upload them, this time there will be some dynamic objects and a better test environment (I hope... two hills, a tunnel, a room*, and a building**)
** a box
* an open box