   Sorting alpha objects kills performance
  I am rendering a cluster of stars (about 50-100) in 3D, all of which consist of one billboard for the star texture and a second one for the name of the star. All is well, I''m sorting the objects correctly, no graphical glitches etc. Well, almost all is well... The sorting is killing my performance because the texture has to be changed gazillion times per frame.Is there any efficient way to sort the billboards so that ones with the same texture would be renderer after each other? After all, the stars don''t overlap very much at all, so in practice, not many of the billboards would have to be sorted. But if I don''t sort at all, there are graphical glitches when the stars do overlap...-Jussi 
  hm, how big are those stars that you cant put a bunch of them in a single texture? ;  The problem is not the stars themselves, they only use three different textures. The problem is that in addition to the stars, there are the name tags and in the future, fleets and other icons. And I can''t put all of them in a single texture... Especially not the names, since they are dynamically created. It wouldn''t be very easy to put them in the same texture with the star especially with about 100 different names.-Jussi ;quote:Original post by Selkrank  The problem is not the stars themselves, they only use three different textures. The problem is that in addition to the stars, there are the name tags and in the future, fleets and other icons. And I can''t put all of them in a single texture... Especially not the names, since they are dynamically created. It wouldn''t be very easy to put them in the same texture with the star especially with about 100 different names.-Jussi   hmm, did you try not to store every single combination of letters as a unique texture then? any hardware limitations to consider? you dont need everything in just one texture, but at least try to work with as few textures as possible. one for stars and fleets/icons, one for letter etc.. if you end up with about 4 you can just bind them all to different texture units and use the one you need. are the names right above/below the stars or in front?;  Why don''t you store whole fonts in seperate textures. Each texture has all the letters ("a..z, A..Z"), numbers (0..9) and symbols (''.'', ''?'', ''!'', etc.) one after the other. Then all you''d have to do is step through the texture and render each letter/number/symbol seperately as you needed it. This is the way I''ve seen it done in the past.-Daedalus ;  Stars are bright dots, so they are better rendered using additive blending, not alpha blending. Objects with additive blending layered on top of each other will produce the same results no matter in what order they are rendered at, so you doesn''t need to sort the stars themselves.I get that you want to have a view of a star system, where each star has a name label and the user can rotate around the star group (space strategy game?). As for star names, you can draw text boxes using your favourite method using each star screen space location. But maybe you shouldn''t show *all* names at once, since it might get a lot confusing (a mass of text, if viewed from certain angles). ;quote:Original post by M3d10n  Stars are bright dots, so they are better rendered using additive blending, not alpha blending. Objects with additive blending layered on top of each other will produce the same results no matter in what order they are rendered at, so you doesn''t need to sort the stars themselves.Additive blending has one problem: if the star is not perfect white (and not all stars are), all other objects behind the star are going to show through, which looks stupid. The correct solution would probably be to render two textures: one with normal blending and one with additive blending. But this requires sorting again...quote:I get that you want to have a view of a star system, where each star has a name label and the user can rotate around the star group (space strategy game?).You guessed right.quote:As for star names, you can draw text boxes using your favourite method using each star screen space location. But maybe you shouldn''t show *all* names at once, since it might get a lot confusing (a mass of text, if viewed from certain angles).   Actually I have thought about that, but I''m not sure if it would be good if the names were renderer after everything else... I''ll have to try that, though.Here''s a screenshot of the game to show you what I''m doing. That''s the Sun and 80 nearest stars btw. http://www.cs.helsinki.fi/u/jlepisto/mproject.jpg-Jussi ;  you only have to sort object that do have an overlap problem, others can be sorted by texture.That will definitely help.Then you can create texture pages where you store more than 1 texture in one texture. That will help a lot too.If you apply both techniques, you will be freed from your current bottleneck. ;quote:Original post by janos  you only have to sort object that do have an overlap problem, others can be sorted by texture.But how do I determine (efficiently), which objects are overlapping?-Jussi ;  Skip sorting and just turn off depth writes (NOTE: writes, not reads .. i believe it''s done with glDepthMask(0) or SetRenderState(D3DRS_ZWRITE,FALSE) ). will look OK for most particle systems 