Tinting instanced mesh [SOLVED]

I have simple mesh using standard material with texture.
I want to tint (mix/multiply some solid color with the texture) each instance basing on its position (or some other external parameter).
How can I achieve this effect? Is it even possible with standard material?
I’ve tried using vertexColor and standard material an I get some flickering. I don’t even know if it should work.

EDIT: OK, solved with instancedBuffers from the example. Used the second type of interface. I can’t tell how flickering dissapeared. I simply changed the way the buffers are registered as now I’m not using Mesh:setVerticesBuffer.
To all newcomers like me. You have to set vertexBuffer values for both source mesh and instances.

    mesh.registerInstancedBuffer("color", 4); 
    box.instancedBuffers.color = new BABYLON.Color4(Math.random(), Math.random(), Math.random(), 1);
    let instance = box.createInstance("box1");
    instance.instancedBuffers.color = new BABYLON.Color4(Math.random(), Math.random(), Math.random(), 1);

2 Likes

This is beautiful Is the game playable ??

No. At the moment only thing agents can do is walk over the map. This is a playground for using tensorflow and machine learning driven game logic.

3 Likes

Keep us up to date it sounds like an amazing project :slight_smile:

1 Like