I am experiencing the use of the StaticModelGroup class. My goal is to create and display several gates from one unique model file called “Models/Gate.mdl”.
When I execute that code, I see no gates displayed while in my debug window, I see the message:
“Creating gate node n°0”
…
If I set the number of gates to create to 1 in the for loop, meaning that I only create one single gate, it works fine. I see the unique gate displayed in my view port.
The code seems to be quite correct and it works for one gate. But it does not work for more that one (2, 3, and more).
I am turning around and for the moment, I cannot figure out what is wrong with my code. Or maybe I forgot something ?
I am very interested if you might have some ideas that can help me solve that issue.
For information, my code is inspired from the sample HugeObjectCount provided in Urho3D engine. Such example works fine, but not mine and I do not really see the differences between both programs.
Instead of using your gate.mdl , try using one the Urho’s default models (box.mdl , cone.mdl , cylinder.mdl , etc) and see if it works with those models.If it works , it means something is wrong with your gate model.
thanks for your suggestion. I gave it a try with some objects : Box, Cone, Cylinder, … but the result is always the same. If I add only one node in the group, it is properly displayed. Otherwise, I do not see anything.
I have added printing of some debug message each time I create a node in my for loop and here is what I get :
Creating gate node n°0
Group number of occluders : 62
Group number of instances : 1
Creating gate node n°1
Group number of occluders : 124
Group number of instances : 2
Creating gate node n°2
Group number of occluders : 186
Group number of instances : 3
Creating gate node n°3
Group number of occluders : 248
Group number of instances : 4
Every new node seems to be properly created and added into the group. The number of instances within the group is incremented by one each time a new node is added, and this is also the case of the number of occluders.
So, what’s wrong ??? This is really making me crazy
Any clue that can help me solving that situation is welcome. In the mean time, I keep trying to check what are the differences between the HugeObjectCount demo (which works !) and my program.
It’s highly likely that Urho and some graphics drivers interact in a way that cause this bug. May be an actual error in Urho code, but on e.g. Nvidia cards (and older Intel) I haven’t been able to reproduce. Realistically, this probably needs someone with the issue occurring to debug it and post a fix to the renderer internals, if possible.
Thanks for the tip.
In my code, I first check for HW instancing capabilities, and I disable dynamic instancing depending of the capabilities.
So, I added the following line in my Start() function:
No, the engine should refuse to erroneously enable instancing if not supported. However, GetInstancingSupport() check is for ancient hardware and mostly not relevant anymore, except for mobiles & web, as on desktops it should always be true and we have already dropped Shader Model 2 support (on which it could be false.) So on a desktop machine, that particular error is something else; not GetInstancingSupport() being false.
EDIT: will have to review this a bit. The renderer allows instancing to be enabled even without support, but it should later understand this situation and not attempt to actually render instanced. This is probably not a good idea, as it makes the code more fragile / errorprone.
I guess, what’s weird about this issue is that the StaticGroupModel example in the HugeObjectCount works fine for you… So you definitely have support now that I think about it. Very odd
It could also be something like that the instancing is in a bad shape initially (for some reason), but calling Renderer::SetDynamicInstancing() again recreates the instancing vertex buffer and fixes it.
in my Start() function, hoping it will set to a stable known internal state, it does not work anymore, on final.
I guess the issue I have has something to deal with my hardware. Since I have other computers at home (with different hardware) I will check for the issue on them.
Ok. Reviewed the code. At least just manually setting instancingsupport to false in Graphics caused the rendering to happen correctly without instancing.
One more thought regarding this, if you were to call GetSubsystem()->GetInstancingSupport() before the window is opened and the graphics context exists, it would return always false. However, this should not be the case when the Engine & Application classes are used normally, since the Start() would be executed when the engine is initialized and the window is already open.
thanks for those explanations. I check for dynamic instancing support in the Start() function so I assume that it is the right place to do that as you said.
I also tried my application on another computer running a Linux Mint distro, with a GeForce GTS450 graphic board (an old one ;)), and with the nvidia driver 375.66.
The GetInstancingSupport() returns true but I still have to force Dynamic Instancing to false in order for my objects to be properly displayed, otherwise it does not work (nothing is displayed).
For information, I compiled my app against the latest development release of Urho3D (the git clone was done yesterday).
Could you publish the model somewhere, or send to loorni@gmail.com? I could test if it’s a combination of vertex attributes that is not encountered with the Urho default models, and which breaks Urho’s handling of instancing attributes on OpenGL, regardless of the driver.