Made sampleDepth() more flexible