Performance concerns from using multiple materials

I want to visualize my mesh with multiple textures, so I am using multiple materials.

I first define a variable for my mesh material to be an array of THREE materials.

Then, since I am using a BufferGeometry, I am calling the addGroup method to specify which vertices get to use which material.

When I render the scene however, orbiting and panning the camera (i am using OrbitControls) seems to be very sluggish.

I switched to using a single MeshBasicMaterial on my mesh to test whether the multiple materials was the issue, and when I did everything was back to normal speed.

The model I was having issues with wasn’t even a big model. It was a utah teapot model around 400kb.

Is there a way to use multiple textures on my mesh without keeping an array of materials for each texture, or am I missing something here?

No, when using the built-in materials, you need multiple ones if you want to use multiple diffuse textures per model. Keep in mind that using multiple materials will lead to multiple draw calls and a possible performance degradation.

Consider to merge textures so you can sample the surface color information from as few images as possible.

As an example, the following texture contains all surface color information of the following soldier model: https://threejs.org/examples/webgl_animation_skinning_blending

1 Like