You are viewing the course site for a past offering of this course. The current offering may be found here.
Lecture 5: Texture Mapping (29)
julialuo

How does this relate to barycentric coordinates? Do we map a texture onto each vertex of each triangle, and use barycentric interpolation to get the color for each sample within the triangle? How does that compare to just mapping a texture onto every sample within each triangle?

rahulmalayappan

@julialuo, I'm not exactly sure what you mean by mapping a texture onto each vertex. If you mean assigning a color to each vertex and then doing barycentric interpolation to smoothly vary the color across the triangle, then that is one way to color triangles, but it is limited in that we can't resolve detail that is finer than the size of the triangle.

Instead, we can use (u,v) coordinates to lookup textures. If we call texture.sample(u,v), then we will get a color corresponding to the pixel closest to (u * width, v * height). We can use this to color triangles with a different color for each sample:

We can assign the three vertices of the triangle their own (u,v) coordinates, and then when we sample within a triangle we can barycentrically interpolate the (u,v) coordinates of the triangle to get the (u,v) coordinates of the sample. Then we can color that sample using texture.sample(u,v). That is where barycentric coordinates come into play; not in interpolating the color, but rather in interpolating the texture coordinates.

killawhale2

@julialuo The difference is that instead of storing texture for all the points inside the triangle, we only need to store texture for the 3 vertices and calculate whatever texture of a point we need on the fly. Also, barycentric coordinates are USEFUL for interpolating things other than location, but they are not exact definition as the locations are. In other words, location of a point P within the triangle will be mathematically expressed in barycentric coordinates. However, for other properties like texture, barycentric coordinates give a reasonable coefficient for interpolating, but is NOT mathematically equal to the exact texture at a point P. We just assume that the triangle is small enough for the interpolation to have small error, and use the barycentric coordinates as a way of interpolating.

You must be enrolled in the course to comment