object occlusion

Blitz3D Forums/Blitz3D Programming/object occlusion

David819(Posted 2007) [#1]
Hi, what is the best method of occlusion in a large 3d scene, for indoor and outdoor environments, i'm hoping to try and get the same sort of effect that you get in the GTA games, but not sure what the best method is and how would i go about making it. What would peoples advice be on this? thanks.


Rob Farley(Posted 2007) [#2]
well it totally depends on what you're trying to do.

GTA is pretty straight forward because the buildings generally hide everything not on the road you're on so that makes life pretty simple.

The most basic way is to set up 'zones' over your map. e.g. If you're in Zone 1 then you can see Zone 2 and Zone 7 say, when you're in Zone 2 you can see Zone 1 and Zone 3 etc etc. Based on this you hide or show stuff.


big10p(Posted 2007) [#3]
I'm not sure anyone has come up with an efficient occlusion system for B3D. You know blitz automatically occludes entities outside the view frustum, right?

I think the usual method of making things efficient is to break up your environment into smaller sections, and just let blitz do it's thing. Plus, modern GPUs are able to process a huge number of polies quickly, so adding some kind of occlusion system may not buy you much.

Not sure, TBH. Someone more knowledgeable in these matters will probably be along shortly, to clear things up. :)


David819(Posted 2007) [#4]
thanks, will use zones for the level, didn't actually know that blitz did that automatically, but for the mesh in display just wandering if there is any code about for hiding unseen triangles in a large mesh (zone) to free up graphic memory? trying to get it to run as efficiently as possible. thanks


GfK(Posted 2007) [#5]
GTA is pretty straight forward because the buildings generally hide everything not on the road you're on so that makes life pretty simple.
Apart from the bits where you fly planes etc.

The view depth in San Andreas was unbelievable.


Rob Farley(Posted 2007) [#6]
there is any code about for hiding unseen triangles in a large mesh
Nah, blitz hasn't got the legs to piss with meshes at that level, break you level up into seperate chunks (entities) then just hide/show them

The view depth in San Andreas was unbelievable
Never played it, but I'll take your word for it... That sounds sarcastic doesn't it... It's not supposed to! Damn... Now it sounds really sarcastic... Should have just left it as it is... I'll get my coat.


David819(Posted 2007) [#7]
thanks for the help, will use sections for sure, will need to think on the chunks(entities) though, might need to make my own level format or sumething to manage the objects in the map (say get blitz only to load in so many objects depending on the distance of those objects from the player :S). how good is blitz with quick calculations like searching through and array of objects in a file, processing thier distance from the player and camera and then deciding if the object is to be displayed or not? thanks.


IPete2(Posted 2007) [#8]
The deal is this, if it is in front of the camera, inside the frustrum, however far away it is, it will be drawn.

So A good idea is to check the zones as suggested above or for numerous moving objects or smaller levels check entity distance.

In our motorway simulation we had almost 800 cars, buses, vans, trucks, coaches in a draw loop. Anything which was too far away was hidden, and everything else was shown. Worked very well for us.

IPete2.



IPete2.


David819(Posted 2007) [#9]
thanks will try that. thanks everyone for the help :-).


puki(Posted 2007) [#10]
Motorway simulation?

Hand it over - code and media.


John J.(Posted 2007) [#11]
You could actually implement a basic portal system in Blitz3D if you wanted to spend the time. Basically you could divide each room of your level into a separate mesh, then add simple rectangular connectors (portals) that mark the connections between these rooms. Then you could do a quick portal occlusion check like this:

0. First, hide all rooms.
1. If player is in room X, show this room.
2. Check all of room X's portals for visibility (if they appear on the screen).
2. For each visible portal, show the room it leads to.
3. For each of these rooms, check if any of their portals are visible, and repeat (of course at this point you don't check if their portals are on the screen, but rather if they are within their "parent" portal).

This way, with only a few simple 2D polygonal collision checks, you can have near-optimal occlusion in Blitz3D. Of course, you won't be able to do clipping plane optimizations like you would if you were doing this in DirectX/OpenGL, but it should be more than adequate for most tasks (certainly better than the plain octree/frustum culling discussed above - that has nothing to do with occlusion, which is fairly critical in large indoor environments).


Trader3564(Posted 2007) [#12]
what is a portal in this matter? i always wondered that. thanks!


John J.(Posted 2007) [#13]
what is a portal in this matter?

If I was to summarize portals, I'd put it like this:

A portal is simply a marker which tells a portal occlusion manager how rooms are connected. Unlike "general purpose" occlusion, which calculate what is occluded, portal occlusion does the opposite: it calculates what is not occluded. Portals are markers indicating areas (doorways, windows, etc.) that should not occlude other rooms. This way, unless you're looking through a doorway, the only thing that's being rendered is the room you're currently in - even if your level has 100,000 rooms, literally (although if this was the case you'd have to implement a dynamic loading system ;) ).