View Full Version : Modelling How to create occlusion mesh for your static

2014-03-12, 22:14

this quick tut is supposed to teach you how to create an .occ mesh for your static. If you don't know how to create a static yet, use this tutorial:


For this tut you will need
3ds max 9 (not 2014, not 2009, but 9)
bfmeshview and occlusion mesh export script, both from ByteHazard (http://www.bytehazard.com/bfstuff/)
I also used bf tools for 3ds max 9, which you might not need in this tut but they are still a must-have.

Lets go through some theory before we start.
Occ meshes are used to raise the fps in some situations, where some objects are obstructed from your view by large structures in front of them. What the engine does is that before rendering each frame it renders a scene with only .occ meshes in it, checks what objects are fully hidden behind those meshes and then it culls those objects (doesnt render them at all).

This adds a little more workload for the GPU by rendering the extra scene, but at the same time it relieves it off rendering other, more complex objects, because they get culled. What this means in practice is that it helps the performance when you are moving through densely built-up areas like cities with lots of tight hallways and high walls, because even if there is lots of objects around you, a big portion of those gets culled so the fps doesnt drop so much.

This method isnt miraculous though, as when you look upon above described area from a high vantage point, like from in inside an aircraft or from a tower, only very few objects will get completely blocked and occ meshes wont help you at all.

Okay, but how does it look? Well, it needs to be made from quads only (no tris at all) and it has to be VERY simple.

Here is muttrah_houses_1b in bfmeshview:

Here is the occ mesh:

And here are the two images blended together.


The occ mesh needs to be inside or at the very edge of the visible mesh, and shouldnt include any enterable areas or areas with holes in them. If your wall has a big hole in it, dont put occlusion mesh over it, the game would then cull a player even if he was standing right on the other side of the wall.

So what statics should be getting a occlusion mesh? Big non-enterable structures, walls that are high enough, terrain covers, you get the idea.

Lets finally make one, shall we?

For an example I will create an occ mash for this wall, it is already exported and ingame so i dont need to worry about that. It is pretty high, so it obscures a lot of my vision even when im quite away from it:


So how do I make an .occ for it? I import it into max (if you are creating a occ mesh for your own static you already have a scene), copy its LOD2 over because it had the best shape (for simple objects this can work, for more complex ints best to just create a box), turn that into quads and delete the top face since it wont ever obstruct anything:


Then I use the occexp script from bytehazard to export it and place and name it correctly. You have to put it into the same folder as the .con and .tweak files are, NOT into the "Meshes" folder:


Now we can have a look in bfmeshview at both meshes side by side, turn on the grid and see if it's correctly scaled:


If its not, you have to play with the scale setting of the xport script till you get the scale spot on.

And you are good! To further test it and see if editor likes what you done you can load up the static in it, use console comand
objectDrawer.drawDebugPlanes 1
to render the occ mesh and use Render->Toggle draw static meshes to hide your static and you should be able to see the occlusion mesh perfectly :)


PS: Thanks to [R-DEV]Rhino for some of your pictures, I hope you dont mind me using them :)

2014-03-13, 04:15
This method isnt miraculous though, as when you look upon above described area from a high vantage point, like from in inside an aircraft or from a tower, only very few objects will get completely blocked and occ meshes wont help you at all

And they will in fact potentially hurt performance due to the processing overhead that they introduce. For example on one of Rabbit's WIP progress maps, there is a lot of dense foliage but the large buildings are rather spread out, and turning off occlusion culling in fact improved my fps by about 6-10 in the dense areas.

I made most of the current .occ meshes in PR, and if I were to do it again I would've simplified a lot of them... although I'm not sure if it would make that much of a difference.

When considering whether to make an OCC mesh or not, just imagine yourself in game, and how often you'd be close enough to the static for it to 100% block anything.

And be very careful that at no point the OCC mesh will be larger than the static... or this happens:

2015-11-19, 12:55
bytehard's wesbite link Poes poes! (http://www.bytehazard.com/)

leads to a picture of a cat.


2015-11-19, 14:31
You dont like cats?

2015-11-19, 16:02
I like occlusion mesh export script and sites I can download it from.

Fixed OP link.