Search Unity

Question How to decrease or compress a mesh's vertex position precision to lower its memory usage?

Discussion in 'General Graphics' started by Jack-van-der-Bilt, Apr 12, 2021.

  1. Jack-van-der-Bilt

    Jack-van-der-Bilt

    Joined:
    Jul 13, 2015
    Posts:
    17
    Hi everyone!

    I'm wondering if I can optimize the memory usage of procedurally generated mesh at runtime by changing it's vertex position precision (if that is possible).

    Some context;
    I'm building my own voxel world generator. My chunks are 16x16x16 in size and each chunk mesh uses vertex colors to give all the individual cubes their color. Right now I am testing out different worst case scenario's and in my checkerboard test each individual chunk generates around 2mb worth of vertices data:

    upload_2021-4-12_22-41-34.png

    If I understand the inspector correctly, all vertices are stored as floats. As I only need rounded values less than 16 floats might be a bit overkill...

    Is there a way to use another data type instead, compress the precision or something else entirely just to lower the memory usage?

    Before people are going to give obvious and/or wrong answers like: "Use less vertices", "Are you using culling or other optimizations", "Do you really need this many vertices"; I need this many vertices. I can't lower the amount as this is the worst case scenario. All possible optimizations like culling and greedy messing are already applied. Right now I can only do data type / lower level optimizations. I'm trying to make the worst case scenario less worse.

    Thank you to anyone trying to help! I'm still new to unity and to the community (even though my account is a couple years old somehow?) so forgive me if I have missed something in the documentation or don't communicate properly.
     
  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400