Refactored nearest neighbor to use mesh to back buffers