Quiz
- The reading says texture coordinates are used to compute a pixel, what does that mean?
Good question. The shader needs to compute the color of each pixel. When we did material and lighting, that computation was based on normal vectors, light vectors, material and so forth.
With texture mapping, we have another source of information: the texels. The shader determines which texel maps onto this pixel, based on the texture coordinates that it is interpolating across the surface.
That texel is then combined with the material (and, possibly, lighting) to determine the final pixel.
For example, a tan pixel from Buffy's face combined with a light gray from the material and lighting.
- So for the use of coordinates, there was this sentence "One important use of texture coordinates is to figure out what texel to use when computing a pixel. " What exactly does that mean? What does computing a pixel involve?
A good followup question. If the upper left of the image is texture coordinates (0,0) and we are computing some pixel in the upper left of the quadrant, it might have texture coordinates of, say, (0.3, 0.4). We then compute the texel that is at those coordinates, indexing into the 2D array that is the texture, and find, say, a tan pixel from Buffy's face.
- I was a little confused by how .repeateWrapping and .mirroredReatedWrapping worked, specifically number wise for the texel. Could you explain this more?
Sure. Instead of the texture coordinates going from 0 to 1, maybe they go from 0 to 4, because we specified 4 repetitions. Now the interpolation goes a little differently. That same pixel might now have texture coordinates of (1.3, 1.4).
With
repeatWrapping
, we'd treat that the same as 0.3 and use the same texel.With
mirroredRepeatWrapping
, we'd treat that the same as 0.7 and use a texel from the other side of the image. - None today, thank you for the reading! / Thank you for the reading!
You're welcome!