Here is scene with my problem:
Regular objects are highlighted properly, but if I use InstancedMesh and change positions for instances using BufferAttribute, the effect doesn’t apply to them.
Note the strange artefact when the middle triangle is near to zero position. Like during one of the rendering passes, the shader positions setting is not applied.
Cool, both your solutions works as I expect. But why doesn’t it work in my case? My example is a part of a more complex code with a non-trivial vertex shader, which is used to draw a huge number of objects, and their position (and size) depends on other attributes. That’s why I chose the solution to compute the position in the shader.