English subtitles

← Scale Matrix and Normal - Interactive 3D Graphics

Get Embed Code
2 Languages

Showing Revision 2 created 05/25/2016 by Udacity Robot.

  1. Here's what a scaling matrix looks like. Set all three values here to one and
  2. you get the identity matrix. If you want to uniformly scale something to be
  3. three times as large as before, set SX, SY, and SZ to all be three. If you want
  4. to instead just stretch something up along the Y axis so that it's five times as
  5. tall, set SX and SZ to be one, and SY to be five. There's just one funny thing
  6. that happens with scaling in particular. It can mess up normals. Remember we're
  7. not just transforming points with matrices, we're also transforming shading
  8. normals. If you run normals through a translation matrix, nothing happens to
  9. them. They're vectors so they don't get touched. If you run normals though a
  10. rotation matrix, things are fine. Here's a triangle from a side view, looking
  11. along it's plane, along with it's normal. If you uniformally scale this object
  12. to be larger, look what happens. The object grows larger, as does the normal.
  13. The good news is that the normal doesn't change direction, so all we have to do
  14. is re-normalize it before using it in any lighting equations. If you
  15. non-uniformally scale an object, In other words, stretch or squish it. Things
  16. get weird. Here I stretch the triangle in one direction. The normal vector has
  17. also stretched upwards and is clearly no longer pointing in the right direction.
  18. To solve this problem, we need to inverse and transpose a matrix.