Implementing texture sampling