What's a technique for snapping the mouse pointer to vertices in WebGL or OpenGL? All I need is the vertex position, no other info.
Ideally, I'd like to do this without needing to keep positions and indices arrays in memory outside of the GPU. BTW, I have already a surface picking technique that uses GPU-resident geometry, which works by sampling the depth buffer at the mouse coordinates and combining that with the unprojected mouse coordinates.
One vague idea: use a vertex colors buffer, that fills triangles with fragments that somehow each encode the position of their nearest vertex position. The fragments could have the absolute position of their nearest vertex, or a vector with length, pointing towards their vertex position. Picking a color on the triangles would provide the nearast vertex position. Though I can't imagine a way to set up that interpolation on WebGL or OpenGL ES.
Any tips appreciated!