In Metal shading language, what is the exact difference between read and sample function to access texture pixels, and which one should be used when?
Asked
Active
Viewed 1,740 times
1 Answers
23
A few differences:
- You can sample outside the bounds of the texture. But you should not read outside the texture.
- Sampling can use normalized coordinates (between 0 and 1). Reading always uses pixel coordinates.
- Samplers can interpolate between pixel values (for example if you're sampling in between two pixels). Reading always gives you the exact pixel value.

Matthijs Hollemans
- 7,706
- 2
- 16
- 23