Hello everybody! I’ve been using Babylon with great pleasure for the development of my RTS game.
I’m now experiencing some weird behavior with instances. I load some OBJ files, create a single mesh out of each OBJ and then create instances of those meshes. The meshes have color materials (no textures). The instances work fine when I only create instances of one mesh. When I create an instance of another mesh (so I have 2 different instances on screen, e.g. a tank and a buggy), the game starts lagging really badly.
I can have dozens of buggies OR dozens of tanks and things run smoothly. As soon as I start mixing them with only 1 of each type, things get laggy.
Does this sound familiar to anyone? What can be done about it?
I sounds utterly weird and should definitely not happen, I am unfortunately unable to repro locally (with a set of boxes and on of spheres). Could you repro your issue in the playground ?
Repro would involve loading 2 OBJs with color materials and then creating instances of the meshes loaded, giving each instance a random position on the XZ plane. Then move the camera around or start animating the instances by moving them around. Weekend is over so I’ve no more time left. I’ll try to get something up and running this week but applaud anyone beating me to the task.
Additions:
It seems I can actually have 2 types of instances, just not both visible in the current viewport! I can have, for example, 25 tanks on one side of the map working fine. If I have one tank + one buggy on the other side of map and then move my camera so that only the one tank and buggy are in view, things start lagging badly. Is Babylon doing some magic with visible instances?
This behavior happens on my laptop with a Radeon Vega 8 graphics card. My other laptop has an older card (can’t remember which one atm) and does not seem to have the issue. Perhaps this info is of some use?
Ohhhh this is interesting, your gpu might be blacklisted and would run instances in cpu emulation. If the behaviour is not easily reproducible on different hardware it is sometimes the case.
Thanks for your response, Sebavan! I didn’t know gpu’s can be blacklisted? How can I find out if mine is? And more importantly, what can I do about it?
Usually you can find extra info in chrome://gpu/ and the logs. Unfortunately not much you can do about it, but a playground would definitely help confirming that.
I just did a quick test by disabling hardware acceleration in Chrome settings and this did speed up rendering to a state where it is workable. But not smooth though, which is really bad. Glad to know though, so tanks for the suggestion, sebavan! I would never have thought of this!
So an AMD Radeon Vega 8 can’t be used properly. What could be the reason for blacklisting this card (or perhaps more AMD cards)?
Open up “chrome://flags” in the omnibar, search for ‘ANGLE’ and you’ll find the ‘Choose ANGLE graphics backend’ flag. Simply change this to OpenGL, then click the relaunch now button at the bottom of the page.
My RTS now runs smoohtly.
I found this on:
Perhaps someone will find this info useful if they encounter similar problems.