Very slow interactive 3d-model


(Rowdysign) #1

Hello everyone,

I have been working on some interactive 3d-models for a client of mine for the previous weeks. It uses the Sketchfab API. Me and my client are very positive about the result, so are his customers. Thanks Sketchfab :slight_smile: The interactive functionality allows users to check various product options for various safety showers. You can check 1 of the 2 models here

I now finished a second interactive model, which you can check here. When you just select certain product options (like changing colors, toggling hip nozzle, LED-light, etc) and not rotate, pan or zoom the scene, the interactive model only slows a little bit, which I think is acceptable. Alternatively, when you just rotate, pan or zoom the scene (and not changing colors, toggling product options) the model also does not slow down a lot. However, if you do both (changing colors, toggling product options and then rotate, pan or zoom) the model slows down considerably! Perhaps like 80% or so.

It's quite strange for me, because the former model (the MB250) did not slowed down that much when you rotate and toggle. The difference in vertices and faces between the 2 model is also not very big, so I don't think that is the problem. I export all my models from Blender and I always export them manually (by uploading a zip file of the blend file). I also tested the Blender to Sketchfab export plugin. I noticed that the "static model" in Sketchfab (the model without the API functionality) is really fast (faster then my manually uploaded models). It's also very fast when you rotate, pan or zoom the model. However it's the same story when I import that model in my interactive scene: when toggling product options and rotate, etc, the model slows down rapidly.

I have to say, I do not use the hide() and show() methods of the Sketchfab API, I use the setMaterial() method instead. With setMaterial I set materials to fully transparant in order to "hide" them. This allows me to "hide" certain product options when you visit the model at Sketchfab itself.

Does someone has a solution for this problem?


#2

The performance bottleneck here is number of unique meshes and materials. If you have any opportunity to merge meshes or reduce the number of unique materials, you should do it. More details here.

Using setMaterial() is definitely the way to go for changing colors/textures. But for adding or removing optional components, hide() and show() is probably better.


(Stephomi) #3

As @james said, merging the materials should help a lot.

Currently, when you set a material fully transparent, we still draw the meshes (for nothing...).
On top of that, transparent meshes are way slower than opaques meshes because of gpu alpha blending and other reasons.
So in your case, even if you display all your meshes (fully opaque), you will get better performance.
So indeed, "hide" and "show" is definitely the way to go.


(Rowdysign) #4

Thanks for the help, I will try your answers shortly, I will let you know if it helped.