How to Highlight a Mesh Instance?

Given:

  • List of three Mesh instances in the scene: Instance 1 and 2 from Mesh A, Instance 3 from Mesh B.

When:

  • User selects mesh instances 1 and 3, they are added to a temporary Gizmo Mesh as parent
  • GizmoManager attaches to the Gizmo Mesh

Expected:

  • Mesh Instances 1 and 3 to have outline glow effect, similar to Blender selected object with orange outline.
  • Unselected Mesh Instances 2 does not have outline glow.

PG - I tried HighlightLayer and Mesh.renderOutline, but they do not work for Mesh Instances.

You can’t highlight just one instance, but you can highlight the source mesh and all of its instances or you can also clone the source mesh and highlight just the clone.

For example to select instance 1 you can do something like: clone Mesh A, disable instance 1 of Mesh A, copy transform from instance 1 to clone, and add clone to highlight layer. Then when it’s deselected: copy transform from clone of Mesh A back to instance 1 of Mesh A, enable instance 1, then disable the clone and save it for next time one of mesh A’s instances is selected.

I only have single select in my little editor so far, so that’s as far as I’ve gone with it, but theoretically you can create an instance of that clone for each instance of A that’s selected, that way there’s only 2 draw calls total for all of the instances of A…

It’s the same for outline rendering too, instances are great for reducing draw calls but not as flexible as clones and sometimes the workarounds get a little tricky… :slight_smile:

3 Likes

yes, I thought of that too, but just wondered if someone here knew a better and more clean approach

1 Like

Mesh.enableEdgesRendering() works with instances, but not the same desired effect. Why is this not the case with HighlightLayer?

You might want to use the Solid Particle System.

1 Like

I am not sure exactly how you are planning to highlight. But if there is a glow layer involved, that requires multi materials in all cases, because the effect is layered. It boosts your draw calls by 3 (I think). But since you can change the emissiveColor per particle, that’s why I thought it might work for you. I have not done exactly what you are trying to do, but that is my understanding of how it works.

Hello @ecoin just checking in, was your question answered? :smiley:

I closed the topic because it’s not currently possible to highlight a mesh instance, only render edges.

2 Likes