# optimized sub-sampling by precomputed surface flags