Advice for an rts


06-05-2014 02:42:27

Hi, here is a view from my wip project.
when i select units, i want to display healthbars and text but i am getting a fps drop with only text.
the current healthbars are billboards and the labels are mygui textbox widgets.
this scene normally renders at about 290 fps and as you can see it drops to 145 when 370 units are selected.
the batch count change is only 3, 2 for billboards and 1 for textboxes i think.
is this a normal drop or can i do sth. to get better performance.
thanks in advance.


06-05-2014 14:15:02

First of all try to remove text boxes and billboards (one by one) to make sure what slows your game down. If text boxes are drawn in one batch (and in your case they should) then MyGUI would not take many resources, since it is same as rendering mesh with single texture and less than thousand of triangles.

I guess that you have problem with raytracing, that you do for each selected unit every frame to see where to place billboard and health text.


06-05-2014 22:12:05

thanks for the reply. there is no ray tracing but there is a conversion from world to screen space which is negligible.
i found out that there is an extensive use of "findwidget" calls so i stored the pointers of created widgets and now with 500 units it drops from 240 to 200 which is more acceptable.
it seems that widget rendering is super fast but updating the widgets in real time has some costs.
i will replace the billboards with "whiteskin" widgets and see how it performs.


06-05-2014 23:10:26

here is what i tried:

500 units -> 500 red bars, 500 green bars, 500 text. bars are whiteskinned widgets.

with no selection 500 unit renders at 240 fps.
with all 1500 widgets without updating renders at 220 fps.
updating positions of all 500 red bars -> 165 fps.
updating positions of all 1000 (red/green)bars -> 165 fps.
updating all 1500 widgets (bars+text) -> 150 fps.

using billboards for the healthbars seems more suitable as they have a tiny effect on the frame rate.


07-05-2014 13:06:57

Just one more thing to test: try to call update position logic (i.e. calculate new position for widget), but do not actually apply it to widget. I want to be sure, that moving widgets cause slowdown, but not calculating their new positions.


07-05-2014 14:09:46

ok here are the results:

-no selection 250 fps
-only rendering text : 230 fps
-render + calculate but not apply : 227 fps
-render+calculate+apply : 210 fps


09-05-2014 00:57:32

Would you mind sharing how did you perform the world->screenspace projection? Like how did you actually get to use MyGui to display health and text information above your objects?
I'm currently trying to use mygui to display health and text over my npcs, but I don't know how to start because mygui doesn't attach to a scenenode directly.
I guess this would benefit several other people here as well.

Edit: I know how to handle the world to screenspace coordinates, but how do you actually go about re-sizing mygui widgets according to how far or near is the object is from the camera? Do you do that manually by calculating the distance of the scenenode from the camera position, then do a linear re-sizing according to that to the widget?


18-05-2014 18:36:11

sorry for the late answer.

world to screen is sth. like this:

Vector3 screenPoint = camera->getProjectionMatrix() * camera->getViewMatrix() * worldPoint;

then i add any widget to scene:

MyGUI::Gui::createWidget<MyGUI::TextBox>("TextBox", x, y, w, h, align, "Middle", name);

i do not resize the widgets, it stays the same size. you can try altering the font size but i think it wont seem nice at all.