More general way to use stencil test