Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort by texture?

Now and then the phrase "sort by texture" appears in OpenGL-related posts. While I see how this sort could be implemented for a single texture bound to a certain texture unit, I am not certain how this might be done for multiple textures bound to arbitrary texture units. Perhaps by capturing the state of the TUs into an integer id, then use the id as an index into either an array or a map? How to best do the "sort by texture" in an OpenGL application?

like image 204
user1095108 Avatar asked Aug 15 '26 10:08

user1095108


1 Answers

Treating texture units as levels in a tree and do a sorted depth-first traversal is a good starting point.

Ideally what you want to do is minimize the number of texture unit state changes which may mean that the same texture gets selected and deselected multiple times in the optimal case. You suggestion of sorting the tuples of texture IDs is a good idea as well.

like image 199
datenwolf Avatar answered Aug 17 '26 14:08

datenwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!