View previous topic :: View next topic |
Author |
Message |
Hans_Poskocil_
New Member


Joined: 01 Aug 2016 Posts: 15
54 Bank Notes
Items
|
|
Hi,
I want to ask how to make sectors on the new map or "clear map" for better optimization in game?
I have inserted 6000 objects in scene2 and scene.4ds on my map and the gameplay has deteriorated.
thx Safry |
|
Back to top |
|
 |
ASM.
Mafiascene Veteran Modder


Joined: 10 Jan 2014 Posts: 327
677 Bank Notes
Items
|
|
I think Boz' 4ds Manager can convert specifically crafted mesh objects to sectors (and portals?).
What kind of map are you working on? Sectors are primarily aimed at interiors so if you're creating a huge indoor complex then yes, using properly placed sectors and portals will probably give you a significant performance boost.
If you're working on an outdoor map, sectors most likely won't help you much I'm afraid. Here're some ideas:
- Consider using instancing. That is, instead of placing thousands of individual models on the map, merge a bunch of these models into a single mesh. This way you can cut down on the number of objects in the scene and drawcalls required to render them. So for example, let's assume you want to place a group of 10 tree models somewhere on the map and each tree model has two materials (trunk and leaves). If you simply place 10 individual models on the map, the game needs to issue 10 * 2 = 20 drawcalls to render them if they're all visible at once. On the other hand, if you merge these 10 trees into a single mesh, the entire group can be rendered with only two drawcalls and the engine only needs to manage a single object (as opposed to 10).
- Create a deeper scene hierarchy. This is based on how I think LS3D does frustum/occlusion culling (which might be wrong, mind you). So, instead of having a flat scene hierarchy, introduce a few additional parent objects. For example, instead of
Code: |
Primary sector
+ object1
+ object2
...
- object6000
|
restructure your scene to
Code: |
Primary sector
+ base1
+ object1
...
- object2000
+ base2
+ object2001
- object4000
+ base3
+ object4001
- object6000
|
That's of course just an example and you'd probably want to subdivide the baseX even further if you really have this many objects. The idea here that the game/engine probably leverages the scene hierarchy for culling and skips iterating over, say, object2001 - object4000 if it has determined that base2 is not in the current view (at least that's what I do in MWE v0.4.1+). That being said the scene layout does not help on its own and just allows the game/engine to take a few shortcuts if it's given the right opportunities. For instance, it's not going to help much if you have a huge view distance and the player can access areas where the entire map or large parts of it is/are visible.
Depending on your map type/layout, occluders might help. They typically work well if you have a lot of large features like buildings or mountains/hills on your map that obstruct the view in many places. Some guy over at mafia-game.ru forums released occlconv some time ago that can be used to create occluders from regular meshes I think.
Keep dynamlic lighting to a minimum. I think (!) the game does all dynamic lighting in software on the CPU. If that's indeed the case, you should be able to reduce the CPU workload a bit by computing (vertex) lightmaps for most objects in the scene to make them statically lit. On the other hand I could imagine the engine has a caching mechanism inplace so it doesn't need to re-evaluate lighting each frame if the lighting environment hasn't changed.
Add additional LOD levels to your models. For small models like hydranths, trashcans, bushes, lamps etc. a single LOD level with low'ish draw distance might help, too so the corresponding instances fade out and are not rendered at all if they're too far away from the camera.
Note that these optimization tips are largely based on assumptions on how the game/engine works under the hood. I haven't personally tested them in the field yet and measured their impact. |
|
Back to top |
|
 |
Hans_Poskocil_
New Member


Joined: 01 Aug 2016 Posts: 15
54 Bank Notes
Items
|
|
Back to top |
|
 |
ASM.
Mafiascene Veteran Modder


Joined: 10 Jan 2014 Posts: 327
677 Bank Notes
Items
|
|
That map looks great, good work!
So yeah, I think you'll probably want to use sectors for the basement part (even if optimization wasn't a concern) so you can setup proper indoor lighting for it. I think 4ds Manager (or was it LS3D Sandbox?) ships with a tutorial on how to convert meshes to sectors/portals.
Regarding the hierarchy, the baseX frames are just an example. You could also perfectly do
Code: |
Primary sector
+ object1
+ object2
...
- object2000
+ object2001
+ object2002
...
- object4000
+ object4001
+ object4002
...
- object6000
|
What primarily matters in the end is the spatial coherence of the objects in a hierarchy. Organizing the scene like I proposed does not help if the objects in a hierarchy are wildly distributed across the map as the combined bounding volume of that hierarchy encompasses the whole map then. One way could be to use certain street segments as parents and then add some connected street segments as well as the buildings/vegetation/lamps etc. lining them as children. |
|
Back to top |
|
 |
Hans_Poskocil_
New Member


Joined: 01 Aug 2016 Posts: 15
54 Bank Notes
Items
|
|
Do you mean this Boz 4ds full manager?
I yesterday tested removing dynamic object etc. doors (cyrca 50) and I think it helped.
In map I have a lot of dynamic object in pizzeria restaurant... chairs, tables, pictures,... (etc. 70) I try removing this objects and I replace them with static objects...
But I know the sectors have to come XD |
|
Back to top |
|
 |
ASM.
Mafiascene Veteran Modder


Joined: 10 Jan 2014 Posts: 327
677 Bank Notes
Items
|
|
Hans_Poskocil_ wrote: |
Do you mean this Boz 4ds full manager?
|
Yes.
Hans_Poskocil_ wrote: |
I yesterday tested removing dynamic object etc. doors (cyrca 50) and I think it helped.
In map I have a lot of dynamic object in pizzeria restaurant... chairs, tables, pictures,... (etc. 70) I try removing this objects and I replace them with static objects...
|
What do you mean by dynamic object? Physics actors like those used for these gray boxes (bedna02.i3d) that are scattered across Lost Heaven? |
|
Back to top |
|
 |
Hans_Poskocil_
New Member


Joined: 01 Aug 2016 Posts: 15
54 Bank Notes
Items
|
|
Back to top |
|
 |
flovivi
Junior Member


Joined: 22 Dec 2014 Posts: 65
325 Bank Notes
Items
|
|
I think the second attempt is much better!
The reason everything is dark is because you did not assign any light source to the sector. You need an environment light to add basic lighting and then maybe add some real-time lights.
The reason you turn invisible for a while, I don’t really know. But I’m pretty sure you will figure it out when you play around for a while. You already did good! Sectors are a pain in the ass, but very important for adding realistic lighting to indoor and outdoor scenes. Sectors are also very useful for preventing you from hearing the street noise when you are inside a building.
Suddenly feel the urge to reinstall the modding tools for mafia...
Amazing how a game so old which I know for so many years can entertain me still. |
|
Back to top |
|
 |
Hans_Poskocil_
New Member


Joined: 01 Aug 2016 Posts: 15
54 Bank Notes
Items
|
|
Back to top |
|
 |
ASM.
Mafiascene Veteran Modder


Joined: 10 Jan 2014 Posts: 327
677 Bank Notes
Items
|
|
The culling errors you get are most likely due to erroneous portals. I don't currently know what boz' tutorial says on how to generate/convert them but make sure to follow the instructions to the letter.
Also, from the looks of it some of the restaurant's interior meshes are still attached to Primary sector. This would explain why the walls and floor for instance disappear once you enter the restaurant while they're perfectly visible from the outside. |
|
Back to top |
|
 |
|
|