A big problem with BGE is the rasterizer and scenegraph performance, especially if thousands of objects are put in a scene. I have looked at the source code of the rasterizer and tried to figure out how the rendering speed could be improved.
There is actually a function to optimize the mesh structure, but it is commented out, because of some serious issues that comes with it (quadratic build time…). The idea is to join meshes in a certain radius to render them more effectively. I made some tests with a c++ kd-tree library to speed up optimization time.
In my tests it shows up that it’s possible with joined meshes to render a lot more objects with much better speed. The video shows 20k, individual lowpoly objects that are batched together in about 50 render batches.
To compare the speed up:
Blender 2.58.1: 10 fps with about 80ms rasterizer time consumption
With optimized Mesh structures: 8 ms rasterizer time consumption and 40 fps with all 20K objects being displayed at the same time!
You can notice a drastic performance drop in scenegraph, if all objects show up in the camera frustum. This also should be a target for improvement.
Another thing is the request for level of detail. All solutions with python or logic bricks are wasted time. The decision for changing lod levels have to be done as efficient as possible and should be implemented right in the bge core.
There comes a lot of questions to mind, when thinking of improvements:
- how to optimize scenegraph? (currently dbvt from bullet is uesed)
- how to integrate a efficient lod right into object culling mechanism
- how to optimize rendering speed correctly (background optimization with threads?)
…
UPDATE:
=============================================
Here you can find a windows 32 bit build that contains:
- blender 2.59.1 with pepper branch merged
- level of detail (basically working, but need a lot of improvements and bugfixes still…)
- batch counter
- poly counter
- group references and improved KX_GameObject python API
- some UI tweaks (enable/disable counter, optimization)
- blenderplayer
- extended python API for KX_Scene to change global lod factor
Download:
Windows 32 bit build:
http://dl.dropbox.com/u/2779060/Lod-Project/win32-Level-of-Detail-vc.zip
Example file:
http://dl.dropbox.com/u/2779060/Lod-Project/Lodbench.zip
=============================================
Get the actual source code for my development branches on gitorious:
git clone git://gitorious.org/~moerdn/blenderprojects/moerdn-bge-sandbox.git bge-sandbox
cd bge-sandbox
git checkout -b my-local-static origin/ras-static
Any information or idea on this topic would be much appreciated.
greetings,
moerdn