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.
  2. Dismiss Notice

Question optimizing a multi mesh object (car) for performance

Discussion in 'Editor & General Support' started by steveh2112, Aug 3, 2023.

  1. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    hi, i know its generally better to reduce the number of meshes in an object so there are less draw calls.

    but in the case of my car, i have a body and 4 wheels. do you think its better to combine the whole lot into a single mesh? (i don't care about rotating the wheels BTW, its static), or is it better to keep each wheel a separate mesh since only 2 wheels will likely be visible at any given time, so save on rendered polys?

    thanks
     
    Last edited: Aug 3, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    If it's a static background object with no moving part it should be a single mesh and one material. That'll be one draw call. Polycounts are clost to being irrelevant on modern computers, unless we're talking WebGL or mobile or perhaps low-end office PC with integrated graphics.
     
  3. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    its not a single material, its about 6, and no easy way to make it one (they all have normals, height maps, etc), it would take forever to combine into one texture. its a PCVR game. does that make any difference to your answer? its not like i have a performance problem at the moment but i'm just getting started populating the scene
     
  4. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    94
    Just use SRP and you won't have to bother with draw calls or inefficient batching of BIRP. Have as many materials and meshes as you want.
     
  5. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    I have no idea how to do that, way above my pay grade. i'll stick with URP for now but something to think about i guess. thanks
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    That's not how computer graphics work.

    Every single poly is "rendered" if it is in the scene view and not otherwise culled.

    Culling occurs for various reasons, but hiding behind a dynamic object like a car certainly isn't one of those reasons.

    Even a poly facing away from the camera is technically "Rendered," inasmuch as some portion of the geometry pipeline must compute the dot product from the camera and decide it is facing away.

    You should fire up the Frame Debugger (Window -> Analysis -> FrameDebugger) because it's kinda fun to see what is what as your scene is assembled. Let's you step-step-step through all the parts of it.
     
  7. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    94
    Just make sure SRP Batcher is active in your URP asset and use shaders made with Shader Graph or just default URP shaders, that's mostly it.

    https://docs.unity3d.com/Manual/SRPBatcher.html
     
  8. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,362
    Some extra info on that, srp batcher can (mostly) batch different materials together if they have the same shader. That should be achievable for most of the objects
     
  9. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    thanks i will because i notice i'm getting over a thousand draw calls even when i'm not really facing that much
     
  10. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    sorry i'm confused with the docs, it says
    Using the SRP Batcher in URP
    To activate the SRP Batcher in URP:

    1. In the Project window
      , select the URP Asset.
    2. In the Inspector for the URP asset, enable SRP Batcher. If this option is not visible, follow the instructions below.
    How to show Additional Properties for the URP Asset
    Unity doesn’t show certain advanced properties in the URP Asset by default. To see all available properties:

    • In the URP Asset, in any section, click the vertical ellipsis icon (⋮) and select Show Additional Properties.
    is it talking about this
    upload_2023-8-3_14-23-28.png
    because i don't see the show additional properties thing
    upload_2023-8-3_14-25-6.png
     
  11. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    No, wrong asset. You're looking at the global settings (that's featured in the next section of the docs). You want the actual render pipeline settings, with is assigned in the Render Pipeline section of the Project Settings. If you haven't created one, there's a link in that page on how to make one.
     
  12. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    thanks, it looks like i have SRP batcher enabled all along
    upload_2023-8-4_16-16-1.png
    my performance is quite good really, 70fps (limited by virtual desktop link to VR headset ) for a RTX 3060 laptop
     

    Attached Files:

  13. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,362
    Few things:
    1. Disable SSAO. This kills performance, especially for VR
    2. Disable HDR, no VR set uses it atm
    3. Lighting and shadows can impact performance quite a bit
    4. For mobile 1.6mil tris is very high, for desktop vr it's fine
     
  14. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    94
    Just make sure you have a small amount of SRP batches in this list and how many drawcalls are inside one batch probably doesn't matter. You should probably focus on GPU optimization, primarily fillrate - avoiding microtriangles and transparency overdraw. Use GPU profiler tab in profiler.
     
  15. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    i just "discovered" occlusion culling (kind of like how Columbus discovered America) and now i'm down to about 400 draw calls, which still seems high, but manageable