Solid Particle System - Multiple material mesh

I’m attempting to display a mesh with multiple materials in a solid particle system. The mesh appears to be fully rendered however it is 100% white, it appears to have lost all materials.

I’m really hoping there is a way to maintain materials, my previous approach using mesh instances was using 60% of the CPU on an i7, switching to SPS brought it down to 10%.


Thanks in advance!

A playground link would be helpful here. :slight_smile:

Yes, sorry I thought about that after I posted! I’ve updated the original post to include a playground link.

From what I am reading the SPS uses only 1 material.

I am not the best with SPS though, so perhaps someone better will chime in.

The best for SPS is @jerome

If your project doesn’t require that many materials, you might be able to do what I do and create an SPS for each material.

That was something I actually tried doing. But for my model it doesn’t work, I don’t believe my materials are going into the SPS at all.

Here’s a playground calling “addShape” separately for each mesh with a unique material:

And creating a separate SPS for each mesh with a unique material:

For now, the SPS is designed to use only one material as any other standard BJS mesh (the SPS is a mesh).
That said, you can still use different areas of the same texture with the .uvs property of each particle : Use the Solid Particle System - Babylon.js Documentation

You can also still use multimaterials like with any other mesh (and then get a draw call per material). I suppose that the manual vertex count management could then be quite complex (good luck :blush: ).
In this case, build your SPS mesh first from its models, then only apply the multimaterials to the SPS mesh (not to the model).

Thanks @jerome, my models are fairly simple, no textures just material colours. If you take a look here I’m only attempting to render meshes that are of one single material however nothing has any colour?

Have you read the doc ?
It’s written that you can set a different color per particle with the property particle.color that you don’t use in your example. Note well that it’s a single color for the whole particle and it’s the vertex color.
Your model seems to have several colors. The SPS only copies the model geometry to build the particle and the initial vertex colors if any (note that they’re overwritten by the value of the particle color if set).
I don’t know if your imported model has vertex colors or different materials.

If it’s got vertex colors, the SPS should copy them. If it’s got different materials, the SPS doesn’t care about the model materials. In this case, you can set your particle your own texture or colors. If you need several colors per particle, you’ll have either to deal with the particle texture or to stick together single-colored particles or to modify the model to set it vertex colors.

Has your imported model vertex colors ?


the model has vertex colors, so the particles

1 Like

I’m confused by the documentation and the statement you made before stating a SPS can have a single material. From what I’m experiencing it can have a single texture, or a single colour, not a single material. It appears to ignore anything but the texture on the material. If that’s not the case I apologize, I’m fairly new to the 3D world.

I can copy the diffuse colour over from the material of the mesh to the colour property on the particle in my example(see here), but I am unable to do anything with the any specularColor, ambientColor or emissiveColor that might be set on the material, correct? To me, someone new to this, that is not clear at all from the documentation and only through experimentation was I able to come to that conclusion.

Looking deeper into the documentation I found this:

The colors are the Vertex colors, the color related to the vertices themselves. This means that, if you also use a colored material, the vertex colors and the material colors will mix nicely.

Which implies that the color from my material will be used, but is not the case from what I can tell.

Sorry for my direct explanations, I thought you knew everything about vertex colors, etc.
Just inspect your model and check whether it has :

  • vertex colors
  • different materials
  • both

The SPS can only copy the colors and the geometry from the model, and nothing from its materials.

1 Like

Support for MultiMaterial finally added MultiMaterial Solid Particle System