Mesh Optimization

Standard

Below is my custom version of a greedy mesh optimizer for voxel data in Unity3d translated from JavaScript to c# using the original awesome mind bending code of Mikola Lysenko.

meshopt

This is useful if you need to use mesh for collision data and it can drastically improve speed when building/rebuilding game objects. I’ve added a method of excluding some data from generating mesh which is great for blocks which the player should fall through.

Don’t forget to include the original copyright if you use it in your project or share it. Feel free to also credit this site if you wish.

It’s worth noting that there is a kind of “bug” in Mikola’s code which is possibly only apparent when used with Unity3d/c# which returns incorrect normals on 3/6 sides of the cube. This is corrected in the c# below.

If you have a more efficient mesh optimizer you’d like to share. please do! dev@nuzly.com

c#

JavaScript

3 thoughts on “Mesh Optimization

  1. Krythic

    Do you have a github page or something, where I can view the code together with your Chunk class and Mesh class? Thanks.

    • ndev

      Not currently. The Mesh class is a part of UnityEngine. I will post a copy of a Chunk class for reference but it’s really just a place to store all the related data; vertices, triangles, uvs, colour & sub-material data for the final mesh.

Leave a Reply

Your email address will not be published. Required fields are marked *