How to create occlusion mesh for your static

Information and tutorials related to modding BF2.
Post Reply
lucky.BOY
Posts: 1438
Joined: 2010-03-03 13:25

How to create occlusion mesh for your static

Post by lucky.BOY »

Hi,

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:

https://www.realitymod.com/forum/f189-m ... cture.html

For this tut you will need
3ds max 9 (not 2014, not 2009, but 9)
bfmeshview and occlusion mesh export script, both from ByteHazard
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:
Image

Here is the occ mesh:
Image

And here are the two images blended together.

Image

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:

Image
Image

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:

Image

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:

Image

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:

Image

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

Code: Select all

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 :)

-lucky

PS: Thanks to [R-DEV]Rhino for some of your pictures, I hope you dont mind me using them :)
Last edited by Outlawz7 on 2015-11-20 18:31, edited 2 times in total.
Psyrus
Retired PR Developer
Posts: 3841
Joined: 2006-06-19 17:10

Re: How to create occlusion mesh for your static

Post by Psyrus »

lucky.BOY wrote: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:
Outlawz7
Retired PR Developer
Posts: 17261
Joined: 2007-02-17 14:59

Re: How to create occlusion mesh for your static

Post by Outlawz7 »

bytehard's wesbite link Poes poes!

leads to a picture of a cat.

:(
Image
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7636
Joined: 2010-08-06 18:06

Re: How to create occlusion mesh for your static

Post by Mats391 »

You dont like cats?
Image

Mineral: TIL that Wire-guided missiles actually use wire
Outlawz7
Retired PR Developer
Posts: 17261
Joined: 2007-02-17 14:59

Re: How to create occlusion mesh for your static

Post by Outlawz7 »

I like occlusion mesh export script and sites I can download it from.

Fixed OP link.

http://www.bytehazard.com/bfstuff/
Last edited by Outlawz7 on 2015-11-20 18:31, edited 1 time in total.
Image
Post Reply

Return to “Modding Tutorials”