RealityKit fill the background environment

I am new to RealityKit and Metal and I am building a RealityKit app that renders a procedural LowLevelMesh road. But the left and right side of the road is a complete green terrain mesh object and it doesn't look great. What I want is to add some rocks, tall trees and dence bushes (or weed) to make it look like the player is in the woods. But when I add many of those objects then the performance drains. What is the best approach to fill background empty spaces in the scene?

Thanks for the post, hope some RealityKit experts jump quickly on this thread. However I wanted to be the first to tell you:

Welcome to RealityKit and Metal! Transitioning into 3D graphics and procedural generation is exciting.

Here comes my simple disclaimer. I’m not an expert at RealityKit, however I got before the tips that made my simple tests extremely successful and I would like to share those with you, if you require more in detail I would open up this thread to any RealityKit expert that wants to jump in here.

When you add hundreds or thousands of individual rocks, trees, and bushes as separate RealityKit Entity objects, you are overwhelming the CPU. Even if the meshes are simple, RealityKit has to calculate the transform, bounding box, and physics for every single entity, every single frame, and then send individual instructions to the GPU.

To fill dense background spaces without killing performance, you need to shift the workload. So, instead of creating 1,000 separate Entity bushes, you should generate one LowLevelMesh that contains the vertices and indices for 1,000 bushes combined into a single object. RealityKit now only sees one Entity per chunk instead of thousands. This reduces your draw calls from 1,000 down to 1. The GPU can render millions of vertices easily in a single draw call; it's the CPU telling the GPU what to do 1,000 times that causes the drain.

In other words. Use real 3D models for rocks and trees, but group them into "Chunks" using LowLevelMesh to reduce Entity counts. Do not use 3D models for grass. Use a ground texture that looks like dense weeds, or use scattered 2D alpha-cutout planes merged into your terrain mesh.

Hope this helps and I hope that makes you very successful on your project, can’t wait to know what you came out with.

Albert Pascual
  Worldwide Developer Relations.

RealityKit fill the background environment
 
 
Q