GAMES101 Lecture 09 - Shading 3 (Texture Mapping and Shadow Mapping)

GAMES101_Lecture_09.pdf

Shadow mapping is from Lecture 12. For convenience it is integrated into this lecture note.

I. Texture Mapping

 

II. Interpolation - Barycentric Coordinates

Why do we want to interpolate?

What do we want to interpolate?

 

Barycentric Coordinates

Assume the origin O. Inside the plane where a triangle ABC resides, for any point P we have OP=αOA+βOB+γOC, where α+β+γ=1.

Computing the Barycentric Coordinates

Barycentric coordinates are not invariant under projection!

 

III. Applying Textures

Simple Texture Mapping: Diffuse Color

For each rasterized screen sample, determine its (u,v) coordinate by (possibly) interpolating.

 

Texture Magnification

img-5

Insufficient texture resolution

Texture Too Large

 

Applications of Textures

In modern GPUS, textures = memory + range query (filtering)

Applications:

 

IV. Shadow Mapping

From Lecture 12.md.

Procedure

 

Problems

 

Appendix A: Famous Models

 

Appendix B: Normal Mapping and TBN Matrix

Reference: Normal-Mapping

Tangent Space

Normal vectors in a normal map are expressed in tangent space where normals always point roughly in the positive z direction. Tangent space is a space that's local to the surface of a triangle: the normals are relative to the local reference frame of the individual triangles. Think of it as the local space of the normal map's vectors; they're all defined pointing in the positive z direction regardless of the final transformed direction. Using a specific matrix we can then transform normal vectors from this local tangent space to world or view coordinates, orienting them along the final mapped surface's direction.

The TBN Matrix is computed to transform normals from the tangent space to a different space such that they're aligned with the surface's normal direction.