[?] Occlusion mesh
-
lucky.BOY
- Posts: 1438
- Joined: 2010-03-03 13:25
[?] Occlusion mesh
Hi,
I wanted to ask about the technicalities of occ meshes. I know what is the function of them, but i dont know how to make one and attach it to a static. How does one go about doing that?
thanks,
-lucky
I wanted to ask about the technicalities of occ meshes. I know what is the function of them, but i dont know how to make one and attach it to a static. How does one go about doing that?
thanks,
-lucky
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
Well first of all, what static are you making this .occ mesh for? Not all statics should have .occ meshes, only the ones that are large enough to commonly block the view of other objects behind them, which basically comes down to large walls and large buildings. If the large building is enterable with lots of windows then making .occ meshes for them can be a problem and in some cases not possible as otherwise you could stop the players within the building which you could see though the window being from being drawn, or the landscape behind the building that you can see though two windows though the building from being drawn. If the object is too small like a low wall that will only fully hide stuff when you are fully prone behind it probably isn't worth making an .occ for as it will do more harm than good performance wise as calculating when the .occ is obscuring an object or not takes some effort, but if it hides significant stuff a lot of the time that generally pays off. As such you need to ask yourself, and probably us too to begin with if this is the right object to make an .occ mesh for 
As for making them, they are really just a series of quad planes (can't use tris) on the very edge or inside of an object with each quad plane acting as its own barrier to my knowledge.
Anyways here's the muttrah_houses_1b in BFMeshView:

Here's its .occ mesh:

And here's them together (done though photoshop of just taking a ss of both from the same view then blending them together):

In this case its just a simple box, missing off the extra bits from the larger part since its not worth making another box to cull those little bits and note its inside the balconies etc as players can walk on there.
You can look at other .occ meshes with BFMeshView in the same way which you can get from here if you don't have it: BfMeshView
You can also view them in the editor but it isn't as good. But I normally use the editor for testing, although note the level editor won't take into account object movement so you have to save the object in its location, then reload the editor in order to test it fully otherwise the .occ mesh will be left where the object first began, if just put into the map, where you first dragged and dropped it in but testing though the editor dose mean you can test things like props inside a building, although you may need to remove many faces of the building in order to see if its actually working as if its a good .occ mesh, you won't be able to tell without
As for exporting, this script will do it, can't fully remember how since I use a modified, automated version of this script myself that exports the static with the .occ mesh being part of it, but from memory you select the mesh, run the script and then put in the scale and the dir to the folder and the objects name and hit export. But can't remember fully but its very important to test as the scale setting isn't always right by default, depending on the units of your scene etc.
As for making them, they are really just a series of quad planes (can't use tris) on the very edge or inside of an object with each quad plane acting as its own barrier to my knowledge.
Anyways here's the muttrah_houses_1b in BFMeshView:

Here's its .occ mesh:

And here's them together (done though photoshop of just taking a ss of both from the same view then blending them together):

In this case its just a simple box, missing off the extra bits from the larger part since its not worth making another box to cull those little bits and note its inside the balconies etc as players can walk on there.
You can look at other .occ meshes with BFMeshView in the same way which you can get from here if you don't have it: BfMeshView
You can also view them in the editor but it isn't as good. But I normally use the editor for testing, although note the level editor won't take into account object movement so you have to save the object in its location, then reload the editor in order to test it fully otherwise the .occ mesh will be left where the object first began, if just put into the map, where you first dragged and dropped it in but testing though the editor dose mean you can test things like props inside a building, although you may need to remove many faces of the building in order to see if its actually working as if its a good .occ mesh, you won't be able to tell without
As for exporting, this script will do it, can't fully remember how since I use a modified, automated version of this script myself that exports the static with the .occ mesh being part of it, but from memory you select the mesh, run the script and then put in the scale and the dir to the folder and the objects name and hit export. But can't remember fully but its very important to test as the scale setting isn't always right by default, depending on the units of your scene etc.
- Mats391
- PR:BF2 Lead Developer
- Posts: 7643
- Joined: 2010-08-06 18:06
Re: [?] Occlusion mesh
How about making occ meshes for terrain? E.g. on fools road you wouldnt have to load trees from both sides of a hill.[R-DEV]Rhino wrote:Well first of all, what static are you making this .occ mesh for? Not all statics should have .occ meshes, only the ones that are large enough to commonly block the view of other objects behind them, which basically comes down to large walls and large buildings. If the large building is enterable with lots of windows then making .occ meshes for them can be a problem and in some cases not possible as otherwise you could stop the players within the building which you could see though the window being from being drawn, or the landscape behind the building that you can see though two windows though the building from being drawn. If the object is too small like a low wall that will only fully hide stuff when you are fully prone behind it probably isn't worth making an .occ for as it will do more harm than good performance wise as calculating when the .occ is obscuring an object or not takes some effort, but if it hides significant stuff a lot of the time that generally pays off. As such you need to ask yourself, and probably us too to begin with if this is the right object to make an .occ mesh for![]()
But i dont want to derail this topic, so feel free to ignore this
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
I'm not 100% sure but I think terrain dose have an .occ mesh built into it, but never looked into it much. But yes if it doesn't, mappers could make a .occ mesh and stick it inside a big hill.[R-CON]Mats391 wrote:How about making occ meshes for terrain? E.g. on fools road you wouldnt have to load trees from both sides of a hill.
But i dont want to derail this topic, so feel free to ignore this![]()
-
lucky.BOY
- Posts: 1438
- Joined: 2010-03-03 13:25
Re: [?] Occlusion mesh
Im mainly asking because we are now going through a lot of statics in PR:WWII and optimizing them, so i figured we might as well do .occ meshes for some of them to get some more performance improvement.
Anyway to have an example I can learn it on, lets take a wall like this:


So how do I make an .occ for it? I imported it into max, copied its LOD2 over because it had the best shape, turned that into quads and deleted the top face since it wont ever obstruct anything:

Then I used the occexp script from bytehazard to export it and placed and named it correctly. Assuming the grid in bfmeshview is always the same size it should even be correctly scaled:

But will the game use it now? Do I need to do something, and how do I tell if its being used? I tried loading the static in editor but couldnt find how to view and occ mesh.
Anyway to have an example I can learn it on, lets take a wall like this:


So how do I make an .occ for it? I imported it into max, copied its LOD2 over because it had the best shape, turned that into quads and deleted the top face since it wont ever obstruct anything:

Then I used the occexp script from bytehazard to export it and placed and named it correctly. Assuming the grid in bfmeshview is always the same size it should even be correctly scaled:

But will the game use it now? Do I need to do something, and how do I tell if its being used? I tried loading the static in editor but couldnt find how to view and occ mesh.
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
Ye it looks good, although best way to fully check the size is open the static in BFmeshview, then put the screen as you want then drag and drop the .occ into the window and it will use the same view location and to be sure just take a SS before and after and blend them with PS using the opacity on the top layer. But ye if the scale is off its normally horribly off and if the grid is correct, it looks right but would check with the above method to be sure 
As for the editor command, its objectDrawer.drawDebugPlanes 1 (had to look it up
) but it will show the planes in a box if they are at an angle so its not the simplest way to see them but for this object it should show them just fine 
Also go render>Toggle Draw Static Meshes to turn them off in the level editor to more easily see the debug planes.
Also depending on how much your optimizing those statics, unless the lods somehow have less channels in their material or something, there isn't any point in having those lods which I'm guessing are all excatly the same as lod0, just uses up more LM space where it could just be using the mipmaps of the lod0 LM instead of lots of clones of itself.
As for the editor command, its objectDrawer.drawDebugPlanes 1 (had to look it up
Also go render>Toggle Draw Static Meshes to turn them off in the level editor to more easily see the debug planes.
Also depending on how much your optimizing those statics, unless the lods somehow have less channels in their material or something, there isn't any point in having those lods which I'm guessing are all excatly the same as lod0, just uses up more LM space where it could just be using the mipmaps of the lod0 LM instead of lots of clones of itself.
-
lucky.BOY
- Posts: 1438
- Joined: 2010-03-03 13:25
Re: [?] Occlusion mesh
Good point with the LODs, ill get rid of the unneeded ones.
However, i tried that command in editor, hid the staticmesh and it didnt show anything. Im guessing it doesnt load the .occ mesh? Isnt there some line i have to add to the con or tweak file or something like that?
However, i tried that command in editor, hid the staticmesh and it didnt show anything. Im guessing it doesnt load the .occ mesh? Isnt there some line i have to add to the con or tweak file or something like that?
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
Nope it just needs to be in the main folder (not the mesh folder) along side the .con and .tweak files with the same name as the object like so:lucky.BOY wrote:However, i tried that command in editor, hid the staticmesh and it didnt show anything. Im guessing it doesnt load the .occ mesh? Isnt there some line i have to add to the con or tweak file or something like that?

Then the game loads it automatically.
-
lucky.BOY
- Posts: 1438
- Joined: 2010-03-03 13:25
Re: [?] Occlusion mesh
So much for placing it correctly :/
With it being an occlusion MESH one would think it belongs into the Meshes folder
On the bright side, i moved it over and it works, yay!

Thanks a bunch
With it being an occlusion MESH one would think it belongs into the Meshes folder
On the bright side, i moved it over and it works, yay!

Thanks a bunch
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
- Mineral
- Retired PR Developer
- Posts: 8534
- Joined: 2012-01-02 12:37
- Location: Belgium
Re: [?] Occlusion mesh
Oh Dice and logic never really went well in my experience
Nice work lucky. Perhaps it's worth writing this up in a massive quick tutorial and posting it in the tut section if you got the time? Will be nice for other static modelers in the future.
Nice work lucky. Perhaps it's worth writing this up in a massive quick tutorial and posting it in the tut section if you got the time? Will be nice for other static modelers in the future.
-
lucky.BOY
- Posts: 1438
- Joined: 2010-03-03 13:25
Re: [?] Occlusion mesh
I tried to post in a way so you can do it according to this thread, but it is true that this will get drowned soon. But sure, i can turn this into a tut, I already got all the pictures and everything.
EDIT: Nope, apparetnly I dont have permission to make new threads there.
EDIT: Nope, apparetnly I dont have permission to make new threads there.
Last edited by lucky.BOY on 2014-03-11 19:26, edited 1 time in total.
-
Tim270
- PR:BF2 Developer
- Posts: 5166
- Joined: 2009-02-28 20:05
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
-
Gracler
- Posts: 947
- Joined: 2009-03-22 05:16
Re: [?] Occlusion mesh
Are the planes counted as two sided or just one sided? I tried following this but in MeshView things look reversed.
The planes facing the camera are being culled and the back-faces are being rendered? I tried flipping the planes which did reverse the problem but is this a normal behavior you think?
Edit: I guess it is normal looking at the screenshots, but it is still weird that the backfaces are reversed for me between 3ds max and MeshView when viewing an occlusion mesh.
The planes facing the camera are being culled and the back-faces are being rendered? I tried flipping the planes which did reverse the problem but is this a normal behavior you think?
Edit: I guess it is normal looking at the screenshots, but it is still weird that the backfaces are reversed for me between 3ds max and MeshView when viewing an occlusion mesh.
Last edited by Gracler on 2014-03-12 15:54, edited 4 times in total.
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
They are one sided and if you used the Mirror tool, rather than the mirror modifier it can cause the faces to be flipped after exporting, even thou in max they look fine. A reset xform may solve the problem.Gracler wrote:Are the planes counted as two sided or just one sided? I tried following this but in MeshView things look reversed.
The planes facing the camera are being culled and the back-faces are being rendered? I tried flipping the planes which did reverse the problem but is this a normal behavior you think?
Edit: I guess it is normal looking at the screenshots, but it is still weird that the backfaces are reversed for me between 3ds max and MeshView when viewing an occlusion mesh.
-
Gracler
- Posts: 947
- Joined: 2009-03-22 05:16
Re: [?] Occlusion mesh
Oh I see. Yep I did mirror that because I put it on the wrong end to begin with like an idiot
, and thought I could cut a corner by using mirror.
I will see if reset xform fixes it. Thanks Rhino as always your fast and spot on
.
Edit: yep reset xform fixed it
I will see if reset xform fixes it. Thanks Rhino as always your fast and spot on
Edit: yep reset xform fixed it
Last edited by Gracler on 2014-03-12 16:18, edited 1 time in total.
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00
Re: [?] Occlusion mesh
Ye, best just to never use the mirror tool, always creates more problems than its worth. Just add the mirror modified which has no problems and is more flexible too 
-
Gracler
- Posts: 947
- Joined: 2009-03-22 05:16
Re: [?] Occlusion mesh
I wonder how I best would make a mesh for this building?

The nearest ground floor part is enterable and everything else is not. Would those 5 faces be efficient enough you think?

The nearest ground floor part is enterable and everything else is not. Would those 5 faces be efficient enough you think?
-
Rhino
- Retired PR Developer
- Posts: 47909
- Joined: 2005-12-13 20:00



