Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Can we disable and enable static objects or not?

Discussion in 'General Graphics' started by Icaro-DLima, Jan 29, 2022.

  1. Icaro-DLima

    Icaro-DLima

    Joined:
    Aug 6, 2019
    Posts:
    25
    I have a Bomberman-like game. In Bomberman we have a lot of softblocks (blocks that don't move but can be destroyed). My game has at least 100 softblocks at the start. Each softblock uses the same mesh and material.

    These are the statistics when the game start:
    Code (CSharp):
    1. // With softblocks marked as static:
    2. Draw Calls: 179
    3. Batches: 21
    4. SetPass Calls: 16
    5. Batched Draw Calls: 742
    6. FPS: 187 (5.4 ms)

    Code (CSharp):
    1. // With softblocks marked as static after destroying all blocks:
    2. Draw Calls: 224
    3. Batches: 21
    4. SetPass Calls: 16
    5. Batched Draw Calls: 320
    6. FPS: 209 (4.8 ms)

    Code (CSharp):
    1. // With softblocks marked as non-static:
    2. Draw Calls: 527
    3. Batches: 443
    4. SetPass Calls: 16
    5. Batched Draw Calls: 320
    6. FPS: 184 (5.5 ms)

    Code (CSharp):
    1. // With softblocks marked as non-static after destroying all blocks:
    2. Draw Calls: 105
    3. Batches: 21
    4. SetPass Calls: 16
    5. Batched Draw Calls: 320
    6. FPS: 209 (4.8 ms)
    The only problem I saw was that lightmaps don't work well when I remove the softblocks, but I didn't notice anything else wrong.

    Which of these scenarios do you with its better? Mark softblocks as static or not? Why?
     
    Last edited: Jan 29, 2022
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    1,670
    And what is your FPS ?
    For all this cases ?

    Yes don't do lightmap for dynamic objects.
     
  3. Icaro-DLima

    Icaro-DLima

    Joined:
    Aug 6, 2019
    Posts:
    25
    I did the tests again and updated the results, including the FPS.
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    1,670
    So as you can see in your case it almost does not make a difference.

    And yes we can disable static objects but we cannot change position of static object, but when you have got baked lighting than disabling static object will not remove the baked shadow it casted on other objects.
    In case of bomberman I would go with fully real time lighting.
    Optional you can make some stage scene creates lights around and bake lightmap for this static scene with light probes placed around.

    Then put the blocks (non static) that makes the bomberman level and set materials to use light probes.
     
unityunity