SPS and Reflections vs MergeMesh

So before I go down this road I was wondering if anyone has seen any performance advantages to going with an SPS for multiMaterial Mesh instances.

Currently in my scene I have a bunch of GLBs come in which get MergeMeshed with subMaterials and then when instances of them are made I add them to the mirrors’ renderlist.

Now I have noticed because I am using multiMaterials I dont really save on any draw calls which means with the two reflection textures processing and the scene at 200+ drawcalls that becomes what 200 times 3? So my FPS just tanks.

Setting the reflections to update only once every 2 frames, which helps a little but I really need to get these draw-calls down.

So before I bite the bullet and convert my asset system to an SPS system will I see a performance gain with the reflections?

I assume passing a single drawcall to the reflection texture will be way way more efficient, but maybe there is something I am not thinking about.


Freezing all active meshes then adding the reflections back to the custom render list helps a little bit, but it seems like because they have a render list with like 14 items and those items have like 6-12 sub meshes as soon as I process the reflections again I see a huge tank in performance.

Basically need to get that FrameTotal down.

The SPS is a single mesh. When using MultiMaterials with it, you’ll get exactly the same draw call number than using the same MultiMaterial with another standard mesh because the SPS automatically sorts the indices under the hood to lower the calls.

Example : if you have a standard sphere with 3 parts, each one using a standard material, it will require 3 draw calls, one per part.
If the same sphere has now 5 parts, with 3 materials, say ordered like this : mat1, mat2, mat3, mat2, mat3, this will require 5 draw calls (despite only 3 materials) when using the MultiMaterials.
Now, when using the SPS, if the particles are set 3 materials, whatever their number and order, this will require only 3 materials, just because the geometry (indices) is recomputed so that parts using the same materials are always stuck to others.

That said, if you use something else than the standard material (PBR, etc), it may need more than one draw call per part using this kind of material. The SPS will use exactly that same number of draw calls.

So maybe you can test the required draw call number just by setting your MultiMaterials to any standard mesh holding enough indices (a sphere, a tube, a ribbon of your own, etc) to hold every material from your MultiMaterials. Just order it like this : part1/ mat1, part2/mat2, etc… no repetition, no more parts than materials.

I think what is happening is each GLB is redefining the materials instead of reusing the one that is the equivalent already defined on the scene.

If I merge all like materials that should save on drawcalls dramatically then you are saying?

Merging meshes doesn’t necessarily reorder the indices according to the held submaterials of the final mesh.
The SPS can do it because it “knows” what particle has what material.

1 Like