How to ColorLerp when I use instance to make cubes

Hello everyone,

I want to know is it possible to Lerp when I use instance?
this is my PG:
https://www.babylonjs-playground.com/#ZEZLAT#18

in the original project I have 4000 cubes and for improve the rendering speed I use instance, and now I have a problem with color Lerp.

The problem is that instances MUST share the same material. This is the core limitation of instances and also why they are so fast

So in a nutshell you cannot change the diffuse color of one instance only

1 Like

Thank you so much. So what can I do instead of instances to improve the rendering speed of my project?

Maybe instances are still the good way to go if you only want to change one color. I did a video about it:

Also you may want to consider SPS:
https://doc.babylonjs.com/how_to/solid_particles

1 Like

Thank you so much @Deltakosh , I watched the video, it is great, But the problem is I must use Lerp because each cube has a specific grade for color, I try to use SPS but I couldn’t get the cube and I want to know is it possible to use Lerp in SPS?

this is my PG for SPS:
https://www.babylonjs-playground.com/#ZEZLAT#23

pinging @jerome who is the boss behind SPS

I’m not avalaible for now (in the next weeks). In your PG, you’ve got an error (please, check the console) because you don’t loop over each particle in the function initParticle that you implemented.

initParticles() is a custom function that the user can implement for his own needs in order to set all the particles, or some of them only, in their initial state… or to do anything else. It’s not called automatically by the SPS and doesn’t iterate over all the particles.

1 Like