A single mesh made of 12k points with 12k different materials. Is that possible?

That’s way too many draw calls, you can make it a single if you know how to patch the material.

If you only need to highlight groups it is simple. Since you only have vertices in a single geometry you only need to add another buffer attribute and use that attribute in the shader to either hightlight or not, basically like this (not tested) assuming you added a BufferAttribute called selected

yourMaterial.onBeforeCompile = function( shader ) {

    shader.vertexShader = shader.vertexShader.replace('#include <common>', '#include <common>\n attribute float selected; \n varying float vSelected;');
    shader.vertexShader = shader.vertexShader.replace('#include <project_vertex>', '#include <project_vertex>\n vSelected = selected;');

    shader.fragmentShader = shader.fragmentShader.replace('#include <common>', '#include <common>\n varying float vSelected;');
    shader.fragmentShader = shader.fragmentShader.replace('#include <fog_fragment>', '#include <fog_fragment>\n gl_FragColor += gl_FragColor * vSelected;');


};
2 Likes