Interactive grid on custom 3D mesh

CellHighlight

Hey guys ! I’ve asked a question previously regarding covering a custom 3D FBX mesh with a grid of custom cells, and @prisoner849 was very helpful on that post by providing the insight above on how to implement.

However, my main concern is that the shader approach uses realtime mouse position as uniform and applies a color to the cell.

What would be the best approach if I would like to pre-fill some cells on reload of the website, basically having an ID or coordinates for each cell and sending a highlightCell function that could do that. Does this still work using this shader approach ? Or would i have to do another ways of customizing the FBX mesh, or use something else ? Would be grateful for any insight here.

Thanks !

Not sure if it will help here, but there is a color coding approach to object selection.

Basically, you change all mesh materials to have a flat color and then render the scene to a texture. Each object’s color serves as an ID. Since you know mouse position, you can get the color from the texture and know what object you are hovering above. Then you can change its properties like color etc.

With a bit of the camera frustum manipulation you only need 1x1 pixel texture, to render the pixel under the cursor.

Here is an example