25 minutes ago, scarypajamas said:
I have researched occlusion culling and I worry about the accuracy of a hardware solution since there will be latency between whats currently visible versus what was last reported visible by the GPU. The player might turn around instantaneously or might teleport causing brief popping artifacts. A software solution might work.
I also have to consider the visibility of the player from the perspective of the NPC's so this algorithm may run, not just for the players view frustum, but the NPC's as well.
You can reproject the depth buffer from the previous frame. (There should be an article here on gamedev.net. Quite a lot games use GPU occlusion queries. IIRC Cryengine uses it and there should be a paper.)
You can also render occluders for the current frame at first and do frustum and occlusion culling on GPU to avaid a read back.
Personally i implented a software approach using low poly occluders:
Put occluders, batches of world geometry, character bounding boxes etc. in an octtree and render coarsely front to back.
Raster the occluders to a framebuffer made of span lists (so no heavy per pixel processing). Test geometry BBox against framebuffer and append to drawlist if it passes.
Advantage: If you are in a room, not only geometry but also occluders behind walls will be rejected quickly because the octree BBox already fails the visibility test and the whole branch gets terminated. Very work efficient. Can cover dynamic scenes or open / closed doors.
Disadvantage: Because the whole system relies on early termination parallelization makes no sense.
Unfortunately i don't know in which situations my method can beat others because i did no comparisions, but you can think of it.
I also remember a paper or article about how an older version of Umbra worked, but can't give any link. They managed to use something like a low resolution framebuffer by rastering portals instead occluders to ensure correctness. The diffulicty is to extract those portals as a preprocess... IIRC
For line of sight tests you sould use simple raytracing. A full blown visibility determination is demanding even for a single camera and no good option for NPC vs. Player even if first person.
I don't think any recent game still uses the same system for collision detection and visibility - Quake was really a special case here.