project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding > Modding Tutorials
21 Oct 2018, 00:00:00 (PRT)
Register Forum RulesDeveloper Blogs Project Reality Members List Search Today's Posts Mark Forums Read
Modding Tutorials Information and tutorials related to modding BF2.

Reply
 
Thread Tools Display Modes
Old 2014-03-12, 22:14   #1
[R-CON]​lucky.BOY
PR:BF2 Contributor
Supporting Member

lucky.BOY's Avatar
Send a message via ICQ to lucky.BOY Send a message via Skype™ to lucky.BOY
Default How to create occlusion mesh for your static

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:

http://www.realitymod.com/forum/f189...structure.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:


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

lucky.BOY is offline
Last edited by [R-DEV]Outlawz7; 2015-11-20 at 17:31..
Reply With Quote
Old 2014-03-13, 04:15   #2
[R-DEV]​Psyrus
PR:BF2 Developer
Default Re: How to create occlusion mesh for your static

Quote:
Originally Posted by lucky.BOY View Post
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:
[YOUTUBEHD]LpYSGB6lskQ[/YOUTUBEHD]
Psyrus is offline Reply With Quote
Old 2015-11-19, 12:55   #3
[R-DEV]​Outlawz7
PR:BF2 Developer

Outlawz7's Avatar
Default Re: How to create occlusion mesh for your static

bytehard's wesbite link Poes poes!

leads to a picture of a cat.


Outlawz7 is offline Reply With Quote
Old 2015-11-19, 14:31   #4
[R-DEV]Mats391
PR:BF2 Lead Developer
Supporting Member

Mats391's Avatar
Default Re: How to create occlusion mesh for your static

You dont like cats?


Mineral: TIL that Wire-guided missiles actually use wire
Mats391 is offline Reply With Quote
Old 2015-11-19, 16:02   #5
[R-DEV]​Outlawz7
PR:BF2 Developer

Outlawz7's Avatar
Default Re: How to create occlusion mesh for your static

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

Fixed OP link.

http://www.bytehazard.com/bfstuff/

Outlawz7 is offline
Last edited by [R-DEV]Outlawz7; 2015-11-20 at 17:31..
Reply With Quote
Reply


Tags
create, mesh, occlusion, static
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:57.