Adding a highlight to the selected instance
At first sight, adding some sort of highlight seems to be easy by adding some more fields to the vertices and the vertex buffer. Sadly, we are using instanced rendering for performance reasons. This means that all instances share the same vertex data. So, this approach does not work.
The next idea may be the instance placement and animations data. These matrices are calculated entirely by our compute shaders from Chapter 2, fed by the node transform data of the nodes. Adding model related data to every node seems to be a bit overkill, since the highlighted data is needed only once per instance, not once per node.
A better idea would be another SSBO, filled with the correct data in the draw()
call of the renderer, right after the node transform data has been retrieved from the instance. In the instance loop, we have direct access to all instances of a model and can simply push a value to a std::vector
, stating if this is the selected...