# Solid Particle System - Multiple material mesh

**URL:** <https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637>\
**Category:** Questions\
**Created:** [September 13, 2019, 4:24pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637 "2019-09-13T16:24:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidworkman9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidworkman9/32/2373_2.png) [@davidworkman9](https://forum.babylonjs.com/u/davidworkman9)\
**Post date:** [September 13, 2019, 4:24pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/1 "2019-09-13T16:24:54Z")

</div>

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%.

Playground:  
[https://playground.babylonjs.com/#A5JH0F](https://playground.babylonjs.com/#A5JH0F)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)\
**Post date:** [September 13, 2019, 4:42pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/2 "2019-09-13T16:42:50Z")

</div>

A playground link would be helpful here. 🙂

---

<div class="post-metadata">

**Author:** ![davidworkman9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidworkman9/32/2373_2.png) [@davidworkman9](https://forum.babylonjs.com/u/davidworkman9)\
**Post date:** [September 13, 2019, 4:44pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/3 "2019-09-13T16:44:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)\
**Post date:** [September 13, 2019, 4:54pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/4 "2019-09-13T16:54:07Z")

</div>

From what I am [reading](https://doc.babylonjs.com/how_to/solid_particle_system#colors-and-uvs) the SPS uses only 1 material.

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

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 13, 2019, 4:56pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/5 "2019-09-13T16:56:04Z")

</div>

The best for SPS is @jerome

---

<div class="post-metadata">

**Author:** ![adam](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@adam](https://forum.babylonjs.com/u/adam)\
**Post date:** [September 13, 2019, 5:00pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/6 "2019-09-13T17:00:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davidworkman9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidworkman9/32/2373_2.png) [@davidworkman9](https://forum.babylonjs.com/u/davidworkman9)\
**Post date:** [September 13, 2019, 5:15pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/7 "2019-09-13T17:15:48Z")

</div>

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:  
[https://playground.babylonjs.com/#A5JH0F#1](https://playground.babylonjs.com/#A5JH0F#1)

And creating a separate SPS for each mesh with a unique material:  
[https://playground.babylonjs.com/#A5JH0F#2](https://playground.babylonjs.com/#A5JH0F#2)

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [September 13, 2019, 7:18pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/8 "2019-09-13T19:18:21Z")

</div>

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](https://doc.babylonjs.com/how_to/solid_particle_system#colors-and-uvs)

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 😊 ).  
In this case, build your SPS mesh first from its models, then only apply the multimaterials to the SPS mesh (not to the model).

---

<div class="post-metadata">

**Author:** ![davidworkman9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidworkman9/32/2373_2.png) [@davidworkman9](https://forum.babylonjs.com/u/davidworkman9)\
**Post date:** [September 13, 2019, 7:36pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/9 "2019-09-13T19:36:58Z")

</div>

Thanks @jerome, my models are fairly simple, no textures just material colours. If you take a look [here](https://playground.babylonjs.com/#A5JH0F#2) I’m only attempting to render meshes that are of one single material however nothing has any colour?

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [September 14, 2019, 5:07am UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/10 "2019-09-14T05:07:30Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [September 14, 2019, 5:19am UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/11 "2019-09-14T05:19:55Z")

</div>

example [https://playground.babylonjs.com/#A5JH0F#4](https://playground.babylonjs.com/#A5JH0F#4)  
the model has vertex colors, so the particles

---

<div class="post-metadata">

**Author:** ![davidworkman9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidworkman9/32/2373_2.png) [@davidworkman9](https://forum.babylonjs.com/u/davidworkman9)\
**Post date:** [September 14, 2019, 11:23am UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/12 "2019-09-14T11:23:50Z")

</div>

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](https://playground.babylonjs.com/#A5JH0F#5)), 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.

Edit:  
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.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [September 14, 2019, 11:44am UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/13 "2019-09-14T11:44:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [November 14, 2019, 1:23pm UTC](https://forum.babylonjs.com/t/solid-particle-system-multiple-material-mesh/5637/14 "2019-11-14T13:23:33Z")

</div>

Support for MultiMaterial finally added [MultiMaterial Solid Particle System](https://forum.babylonjs.com/t/multimaterial-solid-particle-system/6987)
