FAQFAQ    Board RulesBoard Rules    SearchSearch    LotteryLottery    RouletteRoulette    UsergroupsUsergroups
     RegisterRegister  ProfileProfile    Log in to check your private messagesLog in to check your private messages    Shop    Log inLog in 
View posts since last visitView your postsView unanswered posts

creating sectors for better optimization?

 
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding
View previous topic :: View next topic  
Author Message
Hans_Poskocil_

New Member
New Member


Joined: 01 Aug 2016
Posts: 15

54 Bank Notes
Items

PostPosted: Sun Dec 15, 2019 10:02 pm    Post subject: creating sectors for better optimization? Reply with quote

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
View user's profile Send private message
ASM.

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 10 Jan 2014
Posts: 314

651 Bank Notes
Items

PostPosted: Tue Dec 17, 2019 12:12 am    Post subject: creating sectors for better optimization? Reply with quote

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. Thinking
  • 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
View user's profile Send private message
Hans_Poskocil_

New Member
New Member


Joined: 01 Aug 2016
Posts: 15

54 Bank Notes
Items

PostPosted: Tue Dec 17, 2019 8:32 pm    Post subject: creating sectors for better optimization? Reply with quote

Now I was trying to reduce the quality of the shadows in MWE. And from 34Mb it got down to 20Mb it brought a little improvement but not much ... How do I create another sector of base 1, base 2, ...base 60 ?

https://drive.google.com/open?id=15zOcNbHTPDBiV5KLiWOw-A2WvlIU8Brt

My work:
https://www.youtube.com/watch?v=8Oibvqa-7Fk
thx Šafry
Back to top
View user's profile Send private message
ASM.

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 10 Jan 2014
Posts: 314

651 Bank Notes
Items

PostPosted: Wed Dec 18, 2019 12:41 am    Post subject: creating sectors for better optimization? Reply with quote

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. Thinking

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
View user's profile Send private message
Hans_Poskocil_

New Member
New Member


Joined: 01 Aug 2016
Posts: 15

54 Bank Notes
Items

PostPosted: Wed Dec 18, 2019 6:33 am    Post subject: Re: creating sectors for better optimization? Reply with quote

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
View user's profile Send private message
ASM.

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 10 Jan 2014
Posts: 314

651 Bank Notes
Items

PostPosted: Wed Dec 18, 2019 11:45 pm    Post subject: Re: creating sectors for better optimization? Reply with quote

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
View user's profile Send private message
Hans_Poskocil_

New Member
New Member


Joined: 01 Aug 2016
Posts: 15

54 Bank Notes
Items

PostPosted: Thu Dec 19, 2019 4:54 pm    Post subject: Re: creating sectors for better optimization? Reply with quote

I have a progress Smile On distance sector works fine but If I enter to sector - camera skiping Sad

https://drive.google.com/open?id=100vLjwNt-WPKfBrY0qiwzsMv1z6DeoMY

the next attempt was no better

https://drive.google.com/open?id=1_QnQx2qHHn4n5Hb_-O6Bpbcg3CKK0YgN
Back to top
View user's profile Send private message
flovivi

Junior Member
Junior Member


Joined: 22 Dec 2014
Posts: 64

323 Bank Notes
Items

PostPosted: Thu Dec 19, 2019 7:15 pm    Post subject: Re: creating sectors for better optimization? Reply with quote

Hans_Poskocil_ wrote:


the next attempt was no better

https://drive.google.com/open?id=1_QnQx2qHHn4n5Hb_-O6Bpbcg3CKK0YgN


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
View user's profile Send private message
Hans_Poskocil_

New Member
New Member


Joined: 01 Aug 2016
Posts: 15

54 Bank Notes
Items

PostPosted: Thu Dec 19, 2019 8:08 pm    Post subject: Re: creating sectors for better optimization? Reply with quote

Now if the primary sector worked so it is perfect but unfortunately it turns off ...

Sad

https://drive.google.com/open?id=19fkWNW1uMa3nZ8NbSG5N2c7PgrsMaZbp

help pls...

How to make sure that the primary sector does not shut down when entering the sector?
Back to top
View user's profile Send private message
ASM.

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 10 Jan 2014
Posts: 314

651 Bank Notes
Items

PostPosted: Thu Dec 19, 2019 11:34 pm    Post subject: creating sectors for better optimization? Reply with quote

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. Thinking

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Generation Time: 0.048 | Queries: 18