Search Unity

DOTS Physics Bevel Radius Performance Testing

Discussion in 'Entity Component System' started by Saturn1004, Dec 1, 2021.

  1. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    There isn't a lot of information out there about the Bevel Radius option on DOTS Physics Shape components, so I figured I'd do my own experimentation and post the results here.

    Here's what the documentation has to say about it:
    "To improve the performance and robustness of collision detection Unity Physics allows contacts to be generated within a small tolerance of the surface of a convex shape. This tolerance is referred to as convex radius or bevel radius."

    So it sounds like Bevel Radius improves performance, but adding a bevel to a box collider makes the geometry more complex, so which ends up actually being more performant?
    Is more bevel radius always good, or does the performance start to drop off if it goes too high?

    I set up a simple test to try to answer these questions.
    The test consists of:
    A wall of 3,680 stacked DOTS physics cubes falling onto a 500x500 terrain with 513x513 heightmap with some bumps on it (To attempt to replicate a real world use case with things interacting with a more complex geometry than just a box collider.) and an FPS script to track the lowest and average FPS while the tower collapses.

    Here are the results:

    0 Bevel Radius:
    Test 1:
    Low: 104
    Avg: 209

    Test 2:
    Low: 97
    Avg: 203

    Test 3:
    Low: 104
    Avg: 220

    Test 4:
    Low: 104
    Avg: 220

    Test 5:
    Low: 105
    Avg: 211

    .05 Bevel Radius (Default Value)
    Test 1:
    Low: 108
    Avg: 219

    Test 2:
    Low: 108
    Avg: 218

    Test 3:
    Low: 109
    Avg: 219

    Test 4:
    Low: 106
    Avg: 217

    Test 5:
    Low: 107
    Avg: 222

    .1 Bevel Radius
    Test 1:
    Low: 90 (Ouch, an outlier)
    Avg: 219

    Test 2:
    Low: 114
    Avg: 225

    Test 3:
    Low: 112
    Avg: 220

    Test 4:
    Low: 110
    Avg: 221

    Test 5:
    Low: 110
    Avg: 218

    .2 Bevel Radius
    Test 1:
    Low: 93
    Avg: 223

    Test 2:
    Low: 89
    Avg: 225

    Test 3:
    Low: 105
    Avg: 213

    Test 4:
    Low: 102
    Avg: 217

    Test 5:
    Low: 95
    Avg: 218

    .3 Bevel Radius
    Test 1:
    Low: 147
    Avg: 218

    Test 2:
    Low: 111
    Avg: 221

    Test 3:
    Low: 102
    Avg: 214

    Test 4:
    Low: 112
    Avg: 211

    Test 5:
    Low: 113
    Avg: 223

    Past .3 Bevel Radius the collider starts to be more of a sphere than a cube, so I figured I'd stop here.

    Averages:

    No bevel:
    Average Low between 5 tests: 102.8
    Average between 5 tests: 212.6

    .05 Bevel (Default)
    Average Low between 5 tests: 107.6
    Average between 5 tests: 219

    .1 Bevel
    Average Low between 5 tests: 107.2
    Average between 5 tests: 220.6

    .2 Bevel
    Average Low between 5 tests: 96.8
    Average between 5 tests: 219.2

    .3 Bevel
    Average Low between 5 tests: 117
    Average between 5 tests: 217.4

    Conclusion:
    I think the obvious conclusion is that any difference is very tiny, and if I were to repeat the tests the results could easily swing in the other direction.
    However, my personal interpretation of the results is:
    1: Having some bevel radius at all seems to marginally improve performance over having no bevel radius at all. (confirming what the documentation says)
    2: Increasing bevel radius past the default of .05 might help an extremely tiny amount, but it seems like the majority of the gains are from just having any amount of bevel radius.
    So .05 is marginally better than 0.
    .3 might be extremely marginally better than .05, or at the very least definitely isn't worse.

    Hope this is helpful for other people out there that like to min-max their performance.