Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: 300+ BillboardText cause low FPS...normal? Alternatives?  (Read 406 times)
chuck123
Community Member
*
Posts: 9


« on: July 21, 2008, 03:32:20 PM »

Hey...really enjoying playing with TV3D...still very new at this but very impressed with the amount of info in the forums.

Based on this post http://www.truevision3d.com/forums/tv3d_sdk_63/floating_text_labels-t2524.0.html and the associated tutorial I'm using TextureFont_DrawBillboardText to draw up to 240 labels floating above an equal number of cylinder meshes placed in 3D space.

When I draw the billboardtexts within the main loop the FPS drops below 100 Cry.  If I comment out the drawing of the  billboardtexts the FPS speeds along above 600 FPS.  This doesn't surprise me since, as far as my naive noob understanding goes, the engine has to redraw 240 billboardtexts at each main loop pass but this would seem to be how TextureFont_DrawBillboardText works (ie. is called within the main loop) and the post above seems to suggest this the most efficient way to produce this kind of effect.

I am a complete fool thinking I can draw all these billboardtexts?  I there some other way to do this?  Do you realize how much I hope one of you can help this poor noob?

Code:
while (DoLoop == true)
            {
                Check_Movement();
                globals.TV.Clear(true);
                globals.Atmos.SkyBox_Render();
//start of billboardtext drawing
                for (int MapNum = 0; MapNum < 10; MapNum++)
                {
                    foreach (SubjectCircle myCircle in Maps[MapNum].ScCircles)
//Exactly 24 iterations here
                        if (myCircle != null)
                            myCircle.DrawLabels();
/*DrawLabels function is strictly a single call to TextureFont_DrawBillboardText whose parameters (ie. text label and its position) depend on the calling myCircle object */
                }
//End of billboadtext drawing
                globals.Scene.RenderAllMeshes(true);
                globals.TV.RenderToScreen();
                }
            }


Thanks for any help.
Logged
Raine
Customers
Community Member
*****
Posts: 1189


« Reply #1 on: July 21, 2008, 04:03:45 PM »

I'd love to help more, but right now I can only recommend to not use foreach and stick with a simple for... add a line where you check for a keypress and keep adding billboards until you notice a big slowdown.
Logged

Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #2 on: July 21, 2008, 04:27:23 PM »

I'd love to help more, but right now I can only recommend to not use foreach and stick with a simple for... add a line where you check for a keypress and keep adding billboards until you notice a big slowdown.

I don't think that foreach is the culprit here. Especially for like 600 iterations...
For the record, using the "foreach" keyword makes the C# compiler create an iterator in the background and using it to loop instead of relying on index/collection size. So it does add junk on the stack, and when using it a LOT it might cause performance issues by invoking the garbage collector or swapping RAM (I think).

Do you use Action_BeginText() and _EndText()? This will speed up batches of sprite rendering quite a bit. I'm not 100% sure it works with billboards, but it should.

Also rendering a large number (200+) shapes individually is always slow in DirectX. That's why particle systems or minimeshes uses geometry instancing or point sprites, it's inevitable. So if you can somehow save your words/sentences as textures and change to minimeshes, it should be a lot faster, but might not be practical. By any means try Begin/End first.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Raine
Customers
Community Member
*****
Posts: 1189


« Reply #3 on: July 21, 2008, 04:46:29 PM »

Zak's right, foreach isn't surely the problem there. By the way, I have a distant memory of Sylvain saying that Begin / End text wasn't needed for texture fonts... if he could confirm this, it'd be nice (but the begin/end for 2d rastering was still needed).

On crappy hardware (like my old laptop), even billboard text would cause slowdowns... what box are you using TV on?

Logged

chuck123
Community Member
*
Posts: 9


« Reply #4 on: July 21, 2008, 05:56:50 PM »

The box is a beast  Grin...Dell T5400 Workstation...plus a 2nd quad-core... 8 Gigs, NVIDIA Quadro FX 1700 (512 Megs)...sooooo much fun...downside is that everything else I use seems dreadfuly slow.

I don't use begin_text and end_text...didn't know about it...will look into it. 

Have changed the ForEach to a classic for...no discernable effect.

I've simplified the main loop to further isolate the issue.

Code:
while (DoLoop == true)
            {
                Check_Movement();
                globals.TV.Clear(true);
                globals.Atmos.SkyBox_Render();
                 for (int MapNum = 0; MapNum < Maps.Length; MapNum++)
                {
                    for (int cNum = 0; cNum < Maps[MapNum].ScCircles.Length;cNum ++)
                    {
                        if (Maps[MapNum].ScCircles[cNum] != null)
                        {
                            int ScaleXY = 15;
                            TV_3DVECTOR circPos =
                                Maps[MapNum].ScCircles[cNum].CircleMesh.GetPosition();
//Huge performance hit follows
                            globals.TextManager.TextureFont_DrawBillboardText("Hello",
                                            circPos.x, circPos.y + 15 + ScaleXY - 8,
                                            circPos.z, globals.Globs.RGBA(0.0f, 1.0f, 1.0f,
                                            1.0f), globals.Arial12, ScaleXY,
                                            ScaleXY);                       
                        }
                    }
                }
                                                   
                globals.Scene.RenderAllMeshes(true);
                globals.TV.RenderToScreen();

Thanks for all help. 
« Last Edit: July 21, 2008, 11:43:58 PM by chuck123 » Logged
Hawthorne
Customers
Community Member
*****
Posts: 233


« Reply #5 on: July 22, 2008, 11:07:21 AM »

  globals.TextManager.TextureFont_DrawBillboardText("Hello",
                                            circPos.x, circPos.y + 15 + ScaleXY - 8,
                                            circPos.z, globals.Globs.RGBA(0.0f, 1.0f, 1.0f,
                                            1.0f), globals.Arial12, ScaleXY,
                                            ScaleXY);                       
                        }
 

This is what is killing your speed.

You would do better to create your billborad texture once and save it to something and use it. Creating it for each pass in the itteration is what's eating your time up.

-Pat
Logged
chuck123
Community Member
*
Posts: 9


« Reply #6 on: July 22, 2008, 11:19:25 AM »

Yes, I was afraid of that.

Although I'm only drawing up to 300 at a time I have almost 100 000 distinct textual labels to create and save (the constant "Hello" label was used to simplify the issue in this case)...was hoping there would be something more elegant. 

Thanks Pat...much appreciated. 

Logged
Eric
Customers
Community Member
*****
Posts: 758


« Reply #7 on: July 23, 2008, 08:35:29 PM »

also don't call the globals functions over and over if you can call them once and store the result in a variable
Logged
chuck123
Community Member
*
Posts: 9


« Reply #8 on: July 23, 2008, 09:52:43 PM »

Good point Eric... Embarrassed

Thanks for you patience
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks