When using InstancedMesh to create a grid of cells on a GroundMesh created from a height map, the cells are positioned at a fixed height (y = 0.001) and don’t follow the terrain relief. I need each cell to follow the terrain surface and be properly oriented according to the surface normal.
Playground:
I have made some solution https://playground.babylonjs.com/#LQ4LI1#749
but i need to support glow, highlight, or emissive for cell
2 Likes
Hi @Deltakosh and @sebavan,
I need to highlight individual cells in a grid mesh (for selected/hovered states) using GlowLayer, similar to how I change their colors via vertex colors. I have a single mesh with vertex color buffers that I update per cell.
I’ve tried using MaterialPluginBase to inject vertex emissive colors and both _useMeshMaterial = true and customEmissiveColorSelector approaches, but I’m having issues - either all cells glow with the base color or it doesn’t work as expected.
I have a workaround using a separate mesh for highlighting, but I’d like to know if there’s a better solution without additional meshes. My shader knowledge is limited.
Could you help me find the best approach? Is it possible to make GlowLayer work with per-vertex emissive colors on a single mesh?
Thanks!
Hello 
Maybe this can help :
When working with instances, you can register an instanced buffer on the base mesh :
baseMesh.registerInstancedBuffer("instanceColor", 3);
Then all instances share the same material, and you can set per-instance color (for example) :
const instance = baseMesh.createInstance("instance");
instance.instancedBuffers.instanceColor = new BABYLON.Color3(r,g,b);
Thanks, but the main goal is to make each instance glow different colors due to different emissions.