Skip to main content
gamedev.net
🔒 Locked

Render batching and sorting

Started by Prince0fPersia 3 replies 2.1k views
Original Post
Prince0fPersia
Prince0fPersia
I have read a lot of articles on render batching recently. So I understand some suggest sorting geometries by materials. Some other argue that creating multiple medium sized shared vertex and index buffers and sorting based on buffers is more efficient. I was thinking of combining this two techniques to sort based on both materials and buffers. Is this a good idea at all and if it is in terms of sorting which one has a higher priority? buffers or materials.
matches81
matches81
I'd probably try to find a balance between the two.
In most games you will have a large chunk of geometry that already exists at the beginning of a level (i.e. is created during load time). For that geometry you can probably combine the two: Sort the geometry based on the material it's going to be rendered with, and then place as many "material groups" as you can / want in one buffer. That shouldn't take too long to do and you'll end up with buffers of a sensible size (i.e. few buffer changes) and can still batch all objects using the same material.
For geometry created during gameplay you'd probably only sort by materials, because the above might be too slow to do during run-time.
Prince0fPersia
Prince0fPersia
That makes sense thanks for the reply... I have another question as well... if we have geometries with alpha blending options the scene needs to be rendered from far to near, is that correct? if it is, wouldn't that screw up the sorting?
patw
patw
Take a look at this: http://realtimecollisiondetection.net/blog/?p=86

The idea is you encode values into a 64-bit integer, and use integer compare to do your sorting.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.