0
\$\begingroup\$

I am creating an environment using procedural content. To optimise performance, I am batching small meshes ahead of time. For efficiency's sake, I don't want to batch objects that make only an insignificant contribution to the final frame.

My question is, how should I determine this? Is there a commonly used or provably 'correct' algorithm?

I was thinking of something like: calculate the size of the bounding box on the final frame based on the camera parameters and see if its below a certain threshold.

Is there a better one?

(PS. This is not premature optimisation - currently my batches go well over the 65k VBO limit - not batching small meshes may save a number of draw calls. Also to be clear, I am not asking about occlusion, I have a number of small highly detailed objects in a scene so large than some will simply not be noticeable if they are far enough away and can be safely culled.)

\$\endgroup\$
  • \$\begingroup\$ The culling is generally done at first by a bounding box inclusion test, so your approach is adequate. \$\endgroup\$ – Vaillancourt Jun 17 '15 at 11:21
1
\$\begingroup\$

Essentially what you want to do is compute the size of the object in pixels, then discard objects that are smaller than some threshold value.

Use a bounding sphere rather than a box and the calculation becomes quite easy. Pre-compute a single radius value R for each object/mesh which is the maximal distance of any vertex from the origin in the object/mesh. Then during rendering, compute the distance from the camera to the object. Divide this distance by R and compare it to a threshold value of your choosing. If the value is less than the threshold value, render the object, otherwise don't. You can even fade the object out as it approaches the threshold value to avoid objects popping in and out as you move towards and away from them.

If your camera can change field of view you should also multiply your threshold value by the ratio of the current field of view to some reference field of view, so that as you zoom in, objects will appear at the same pixel size on screen.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.