Jump to content

CreateInstance slower than Clone


pichou
 Share

Recommended Posts

I try to optimize one of my scene and to do so I adapt my code to use createInstance instead of clone.

But as a result my scene (fps) is slower with createInstance than with clone when it should be the opposite right?

To sum up my code, here is the steps I follow : 
- import mesh
- clone mesh and add material (because one mesh can have 2 different materials)

- create instance mesh

- add in the scene

At the third step, I get a better fps when I use clone instead of createinstance.

Do you have an idea? Thanks!

Link to comment
Share on other sites

Instances are much better performance-wise, so you must have a bug somewhere.

Look at these 2 examples:

https://www.babylonjs-playground.com/#2I6IG4#4

This example uses animated clones, and with 100 clones I get between 50 and 60FPS.

 

https://www.babylonjs-playground.com/#2I6IG4#5

This example uses instances of the same animated model, and with 600 instances, I get mostly a solid 60FPS, with some drops to the heigh 40's, mid 50's.

Link to comment
Share on other sites

OK,

It's weird because I don't have the same result with your playgrounds. I only get around 15 fps with your useinstance example. I use chrome and my computer is an asus Zenbook 3 with a core I7.

Another thing with my project is that after a few seconds it freeze my tab, I can't refresh or acces to the console when the scene is still rendering correctly (with a bad fps though). So as you say I must have a bug but can't figure out what it is.
I only use around twenty shape in my scene which have diffuse,  specular and bump texture and half of them are instance/clone of an other.

What do you advise me to test?

 

Link to comment
Share on other sites

Just my 2 cents.  Using an i5, & a GTX 1050, both ways get me 60 (with intermittant drops when moving camera).  If you have an i7, then this is probably related to your GPU.  Turn on debug on one of those playgrounds.  Go to stats,  see if instances are implemented in hardware.  See Below.  If not, your question is answered.

stats.thumb.jpg.cb03a3e0bf2b0c50efcd5b24df53429d.jpg

Link to comment
Share on other sites

Also, I did a check of specs of your ZenBook.  It has no dedicated GPU, but rather an Integrated Intel HD Graphics 620.  Your options become quite limiting, and sounds like your project is just too big for hardware, judging by the freezing.  If you plan on publishing this for others, you could just suffer through, and test occasionally on a machine with an actual GPU.  Most develop on fast GPU machines, and have a mobile or under powered machine as a tester, but you have what you have.

Link to comment
Share on other sites

Oh I didn't know about the debug console of the playground, very useful. All the extension are put to yes.

OK so you are saying my machine is the problem? I have always notice that it is not very performant with games but not that much!

Then I will test my project on friends computer to confirm that. I guess I will have to find another computer so that I can develop with correct rendering. What are the other important specifications to look out except the GPU?

Link to comment
Share on other sites

Yes, likely.  In general, it is always good to have more than one device with different performance capabilities though.  Switching up occasionally, helps spot issues earlier in dev cycle.

As far as an ideal graphics dev machine.  An i5 is a good choice, possibly with a higher mhz.  Anything more will create blindspots where you will not notice that you are very CPU bound till later than you would like.  Plus you can save here. 

Having an M2 socket for a solid state boot drive is a good sign you have a recent motherboard.  I rebuilt my desktop in the last year.  The motherboard has an M2.  I never got the memory drive, as sleep is a good substitute to powering off.  An old motherboard, when it is a new machine is not a good sign.

Having 2 sets of sims for memory is good.  Also ensure that both are not being used, so that you can expand memory without throwing away the existing.  2 8gb sims, and I can have an Eclipse IDEwith multiple projects open, multiple browsers with scenes, & Blender all open, all in memory with ease.  You cannot mix memory sizes, so bigger is better.

Power supply is starting to become a non-issue, as GPU's are requiring less & less power.  The GTX 1050 is not the fastest, but is a short card (2 slots) that needs no supplemental power connection.  If you also plan on playing commercial games as well, you might wish more though.

Link to comment
Share on other sites

Ok I figured out what was my problem!

With one mesh I was cloning a lot of other mesh as "tools" (line, sphere, disc...) which I use for attacks and other animations. I replace those cloning by instance and this is a lot better. I have between 35 and 45 fps even on my "shitty" computer! ;)

Sorry for the false alert but I am glad I have learn new stuff on babylonjs and performance issues thanks to you @JCPalmer and @Raggar. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...