View Full Version : Changing subjects a little bit
06-14-2002, 04:56 AM
This is not OpenGL related, but since everybody is talking shaders http://www.opengl.org/discussion_boards/ubb/wink.gif let's change subjects a little bit... In my engine, per frame, I use 3 quicksorts to group faces with the same shader. But I'm gruping, not sorting, so there must be a better way to do it without using quicksort. What I need is simply an algorithm to group stuff faster than quicksort. I can't find anything like that, so can anyone help me?
06-14-2002, 05:03 AM
A simple list should be enough.
I don't think per-face shading is great, you should split your objects in subobjects based on which shader they use.
What if you just kept three separate groups and inserted the faces into groups as you iterated through the faces?
06-15-2002, 06:13 AM
how small are your lists? .. for size < 10-20 you'd probably do better with insert sort or something similiar.
06-15-2002, 06:51 AM
Why not make all like type surfaces there own objects. That way when you set your shader you can draw one object per different shader. That's what I do...but not for shaders, I don't know shaders yet; I do it for like type surfaces.
06-15-2002, 10:16 AM
If your number of objects is reasonable, you can build a list of visible objects. Then iterate over the list, once per shader, and draw only the objects that use the currently bound shader. When compared to the cost of transform and rendering (and physics/simulation) a few extra passes over your list is probably never going to show up in a profile.
On the other hand, because this traversal is so comparatively cheap, you might as well use the qsorts that you've already implemented. I doubt it'll be a performance problem. Has it shown up in a profiler yet? (There's an evaluation copy of VTune on the Intel developer site, for example)
why dont u sort before the scene starts ie not during runtime
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.