I'm trying to implement picking routine using transform feedback. Currently it works ok, but the problem is very low speed (slower than GL_SELECT
).
How it works now:
- Bind TBO using
glBindBufferRange()
with offset (0 in the beginning). - Reset memory(size of TF varyings structure) using
glBufferSubData()
(to be sure picking will be correct). The main problem is here. - Draw objects with geometry shader that checks intersection with picking ray. If intersection has been found, shader writes this to TF varying (initially it has no intersection, see step 2).
- Increase offset and go to step 1 with the next object.
So, at the end I have an array of picking data for each object.
The question is how to avoid calling glBufferSubData()
on each iteration? Possible solutions (but I don't know how to implement them) are:
- Write only one TF varying. So it is not necessary to reset others
- Reset data with any other way
Any ideas?