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