GarageGames / Torque3D

MIT Licensed Open Source version of Torque 3D from GarageGames
http://torque3d.org
MIT License
3.35k stars 1.2k forks source link

Instancing used excessively for single models #678

Open jamesu opened 10 years ago

jamesu commented 10 years ago

In https://github.com/GarageGames/Torque3D/blob/d5beea41c882a1ec5454813ee9d4ffbb2345ff1d/Engine/source/ts/tsMesh.cpp#L244 a mesh will be drawn using an instancing material hook if it has less than 200 vertices in it. However this is not too optimal in all cases as for instance you might have several different models with < 200 verts in them with no commonality between them.

Drawing a single model with instancing is not a particularly good use of rendering time, especially in OpenGL as the renderer needs to stuff the model position in another vertex buffer, as opposed to just setting the uniform modelview.

Thoughts anyone? Personally I would have thought specifying this elsewhere like in the material itself would make more sense.

Bloodknight commented 10 years ago

Questions...

What is the real cost overhead, and is this instantly recovered if the same model is used twice? What is the cost of instancing a model with variety of vert thresholds, 500, 1000, 2000, 5000, 10000? What is the cost of instancing vs not instancing 2 models at a variety of vert thresholds 500, 1000, 2000, 5000, 10000?