Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

What does "Optimize Mesh" do?

Discussion in 'General Graphics' started by ArachnidAnimal, Aug 7, 2015.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,690
    In the model import section, there is an option to select "optimize mesh".
    What does this do?

    The documentation says "This option determines the order in which triangles will be listed in the mesh."

    What does this optimize: appearance, performance, build size...?

    Thanks.
     
    JorgeAmVF likes this.
  2. MXAdd

    MXAdd

    Joined:
    Apr 23, 2015
    Posts:
    74
    AFAIK it optimizes the order of vertices to maximize post-vertex-shader cache hit rate
     
    JorgeAmVF and ArachnidAnimal like this.
  3. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,690
    So this means it optimizes performance during run time?
     
    JorgeAmVF likes this.
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,699
    I thought it was more to do with turning triangle soups into `triangle strips` which have less vertex data. Particularly for procedurally generated meshes.
     
    JorgeAmVF and ArachnidAnimal like this.
  5. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    293
    I assume it does the same thing as MeshUtility.Optimize:

    So, yes, performance will be improved at runtime. It just sorts the underlying mesh data so the parts it is going to need all at once are closer together in memory. When the GPU needs to process triangle Y with vertex X, there is a greater chance it can go: "Hey, look I still have this vertex in my cache because I was just using it previously! That is very convenient, and thoughtful of whomever sorted this list!" The CPU gives him the ol' finger-guns-and-wink, and then everyone gets a pony for Christmas.
     
  6. PlyTim

    PlyTim

    Joined:
    Mar 23, 2018
    Posts:
    3
    Hi!
    Has anyone ever tried to use amd tootle or the meshoptimizer library for optimising mesh performance? I would be very interested to know if this would be a way of boosting performance. Maybe unitys built in function is not as advanced or developed?

    https://gpuopen.com/gaming-product/tootle/

    https://github.com/zeux/meshoptimizer

    Would be great if a unity dev could explain what mesh optimisation routines they use!
     
    Lahcene and (deleted member) like this.
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,677
    Both of those do roughly do the same thing as Unity’s built in optimizer to start with. They reorder the vertex and triangle lists for better efficiency. I doubt any of them are significantly better than the other in this regard.

    The one feature they both have that Unity doesn’t have is the overdraw optimization. How much this helps is highly dependent on your mesh. For simple models it won’t have any impact at all, but for complex shapes with a lot of overlapping geometry it may help to some small degree. How much depends greatly on the situation, but 99% of the time it’s unlikely to be measurable. It’s also only going to be an improvement in very specific scenarios, and can actually decrease performance in others. For example if you have a house with rooms and furnishing that’s a single material & model, this can make it slightly faster to render when viewed from the exterior, but also slower when inside. For very specific and somewhat contrived examples I could see this being helpful, like a basic model viewer (like Sketchfab) on low end hardware or high resolutions. For real gameplay use I doubt it’ll have a significant impact, and for 2D game’s with a lot of alpha usage it can actually be working against you.

    The second link has two other options, mesh compression and mesh simplification. Mesh compression is already built into Unity, and what’s in that tool wouldn’t be useful anyway since it would require deeper implementation into the engine, or only be useful for reducing load times if you wanted to manually load mesh data from disk for some reason rather than use the built in assets (which, again, can already be compressed).

    Simplification is the only thing I can see being mildly useful, either as a way to trim down messy high poly models to something more useable or to generate LODs. But there are a ton of tools out there built for that purpose already that are likely far more effective.
     
  8. PlyTim

    PlyTim

    Joined:
    Mar 23, 2018
    Posts:
    3
    Thank you very much for the detailed explanation! I think unity should pay you for all the help you have given in the forums. Whenever i needed an explanation for something regarding optimisation and rendering, i would eventually find a post from yout hat wraps everything up in a really concise manner. :)
    My use case is actually a model viewer scenario, but i guess there might be lower hanging fruit to pick first.
     
unityunity