Instancing and Level-Of-Detail

For this project, I dove into instanced rendering in Unity. I created a tool that allowed the user to switch between instanced rendering and typical object instantiation, both utilizing level-of-detail, normals maps, and frustum culling. I also allowed the user to dynamically change the type and total number of meshes, enter or exit debug mode, and show normal maps or not. Together, these pieces help provide optimization while not sacrificing high fidelity visuals. Here are a couple video examples and information on benchmarks, difficulties, and my source code!

1) Dynamic Instancing and Level of Detail

  • Dynamic switching between instanced rendering and Unity’s built-in GameObject Instantiation
  • Ability to dynamically change which meshes to render as well as the total overall number of meshes
  • Level-of-detail meshes and normals maps for each mesh (Created in Blender with Python, assigned in Compute Shader)
  • Frustum culling based on bounding box
  • User controller camera
  • Debug mode

2) Far away performance

  • From afar, the instanced rendering provides a huge boost in performance : Up to 7x the framerate.
  • The meshes shown are each ~100 faces.

3) Close up performance

  • Instanced rendering performs equal to and even less than GameObject Instantiation when dealing with high-fidelity models up close.
  • It seems to me that the choke point for instanced rendering is the number of vertices to run through. Unity must do some higher level optimization than I did, such as using spatial data structures instead of lists of meshes.
  • Implementing occlusion culling in the Compute shader could improve performance drastically, however Unity does not automatically perform that on GameObjects, so it would not be a benefit over using GameObject instantiation
  • Closest meshes are ~10000 faces with the Predator head at ~40000 faces.

Benchmarks:

  • GTX 970M GPU
  • When far away, instanced rendering performs up to 7x times higher framerates.
  • When close up, working with high fidelity meshes, instanced rendering seems to perform equal to and even sometimes worse than Unity’s GameObject Instantiation.

Roadblocks during creation:

  • This was my first time working with Compute shaders and Compute buffers, so it took a while to fully understand that I didn’t need to request data from the GPU to use in shaders as it was already there.
  • Unity automatically does a lot of things for GameObjects such as saving a transform, assigning a material, transforming by its parent, etc. I had to implement much of that by hand for each mesh, since there are many aspects of GameObjects I wanted to include, which was some new material for me.

Source Code:

  • This work was a part of Artifact-Based-Rendering, a research paper accepted and presented at IEEE Vis 2019 of which I am 4th author, found here.
  • Source code is available here.