0

I have to render a very large number of colored billboards in Irrlicht, but it's really slow. I use many BillboardSceneNodes:

List<BillboardSceneNode> voxels = new List<BillboardSceneNode>();
        for (int x = 0; x < 32; x++)
            for (int y = 0; y < 32; y++)
                for (int z = 0; z < 32; z++)
                {
                    Color c = new Color(r.Next(255), r.Next(255), r.Next(255));
                    BillboardSceneNode b = device.SceneManager.AddBillboardSceneNode(null, new Dimension2Df(1), new Vector3Df(x, y, z), -1, c);
                    b.SetMaterialFlag(MaterialFlag.Lighting, false);
                    voxels.Add(b);
                }

How I can optimize that? How I do occlusion culling or frustum culling with the billboards?

Giulio Zausa
  • 233
  • 4
  • 16

1 Answers1

2

Each render call has a setup and tear-down cost and you're paying this between every billboard, which will cost you a lot of time after several hundred billboards. If many of your billboards share the same texture and materials then you can group them into the same surface and render them in a single call the same way that the particle system scene node does, if you do this then you'll get a couple of orders of magnitude improvement (so several tens of thousands rather than hundreds) and shift your bottleneck to time spent uploading vertices to the video card.

If you need 100k+ billboards then you could optimize this further, instead of sending each edge and vertex of each triangle in each billboard to the card each frame, you could send a list of positions instead and render them using a shader-specific to your video driver. You'll lose some of Irrlicht's niceties like software driver support if you do this.

If this isn't good enough and you need to head into the millions then you'll need to offload all the work to the GPU and decide the positions in a vertex shader. This may not be possible in your use-case, but if you can do it then you're only limited by the computing power of your graphics card.

Gareth Davidson
  • 4,857
  • 2
  • 26
  • 45