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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Optimizing Leaves Mesh

Discussion in 'General Graphics' started by barrenhook, Aug 6, 2023.

  1. barrenhook

    barrenhook

    Joined:
    Feb 8, 2014
    Posts:
    2
    Hey all,
    I'm working on a mobile game where players can grow procedural generated trees, and plant these trees into their forest. I have the procedural tree generation working with no issues, the issue I'm facing is that each procedural tree is ~20K Vertices. Since this is for mobile, 20K vertices per tree is unacceptable, especially when the forest contains hundreds of trees.

    About 95% of the vertices comes from the leaves meshes, which consists of hundreds of quads placed randomly on a unit sphere. My question for you all, how can I achieve a similar aesthetic but reduce the amount of vertices? I can always add LOD, but I'd rather try optimizing it first.

    Full Tree:
    ProceduralTree.png


    Leaves Mesh, which is about 1000 Vertices: ProceduralLeaves.png
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,497
    There are multiple things to look at, especially for tiles GPUs/mobile.
    If the performance is fine, you could keep it like this. Even older low end phones should do fine with 20k verts, especially if you use cheap shaders.

    You could maybe make the quads larger/longer, so it sticks out on 2 sides instead of being on 1 side, potentially halving the quad count
     
  3. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    568
    I'm not an expert for tile-based rendering on mobile GPUs but according to this Unite 2022 presentation, you want to avoid alpha cutout. Read the comments as well, though.
     
  4. barrenhook

    barrenhook

    Joined:
    Feb 8, 2014
    Posts:
    2
    That's a great suggestion! I changed my code to have the quads stick out all four sides, and I got a 4x vertex improvement. Cheers!

    PS, screenshot of the new Leaves mesh:
     

    Attached Files:

    DevDunk likes this.