How to create occlusion mesh for your static
Posted: 2014-03-12 22:14
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](http://i.imgur.com/26RLqQT.jpg)
Here is the occ mesh:
![Image](http://i.imgur.com/tw6MHn8.jpg)
And here are the two images blended together.
![Image](http://i.imgur.com/QVtAfOJ.jpg)
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](http://i.imgur.com/p884biU.png)
![Image](http://i.imgur.com/TF0sz1Z.png)
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](http://i.imgur.com/aRNZKm6.png)
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](http://i.imgur.com/rLd89f5.jpg)
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](http://i.imgur.com/TYMU1gV.png)
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
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 ![Smile :)](./images/smilies/icon_e_smile.gif)
-lucky
PS: Thanks to [R-DEV]Rhino for some of your pictures, I hope you dont mind me using them![Smile :)](./images/smilies/icon_e_smile.gif)
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](http://i.imgur.com/26RLqQT.jpg)
Here is the occ mesh:
![Image](http://i.imgur.com/tw6MHn8.jpg)
And here are the two images blended together.
![Image](http://i.imgur.com/QVtAfOJ.jpg)
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](http://i.imgur.com/p884biU.png)
![Image](http://i.imgur.com/TF0sz1Z.png)
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](http://i.imgur.com/aRNZKm6.png)
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](http://i.imgur.com/rLd89f5.jpg)
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](http://i.imgur.com/TYMU1gV.png)
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
![Smile :)](./images/smilies/icon_e_smile.gif)
-lucky
PS: Thanks to [R-DEV]Rhino for some of your pictures, I hope you dont mind me using them
![Smile :)](./images/smilies/icon_e_smile.gif)