Docsity

Transforming Normal Vectors from Object to World Coordinate Space, Slides of Computer Graphics

Partial preview of the text

Download Transforming Normal Vectors from Object to World Coordinate Space and more Slides Computer Graphics in PDF only on Docsity!

Lecture 18:

Intersection Normal

Normal Vectors at the Intersection Points

  • We discussed all three steps of Ray Casting
  • The key to Ray Casting is to do geometric computation in object coordinate space, but covert the results to world coordinate space.
  • One mathematical issue involves transforming the normal of a surface point from object coordinate space to world coordinate spaceโ€ฆ

Normal Vector Transformed

โ€ข We have a normal vector in object coordinate

โ€ข We need a world-coordinate normal vector to

compute the illumination model

โ€ข How do we transform a point or a vector from

the object coordinate to the world coordinate?

โ€“ We apply the objectโ€™s transformation matrix M

โ€ข Can we treat the normal the same way?

โ€“ Answer: noโ€ฆ

Normal Vector Transformed

โ€ข Can we treat the normal the same way?

โ€“ Answer: noโ€ฆ

๐’˜๐’๐’“๐’๐’…

๐’•

๐’๐’ƒ๐’‹๐’†๐’„๐’•

โ€ข Hereโ€™s an example of why that is:

โ€“ Say that M scales in x by ยฝ, and y by 2

n object M n object Wrong! Normal must be perpendicular

So How Do I Do This?

  • If we canโ€™t use ๐‘€, but some kind of inverse of it, then what does it look like, ๐‘€

?

  • Nope, the answer is ๐‘€

, because:

  1. we need to invert the non-uniform scale,
  2. but not disturb the rotation component (same as in as M)
  3. we donโ€™t care about translation because vectors canโ€™t be translated
  • Recall that ๐‘…

= ๐‘…

, so we can invert the matrix ๐‘€ to ๐‘€

, but then โ€œun-applyโ€ the rotation component by adding in the transpose.

  • The addition of the transpose does not affect the scale matrix because the scale matrix is a diagonal matrix whose transpose remains the same as the original - ๐‘† ๐‘ฅ, ๐‘ฆ, ๐‘ง ๐‘‡ = ๐‘†(๐‘ฅ, ๐‘ฆ, ๐‘ง) - ๐‘† ๐‘ฅ, ๐‘ฆ, ๐‘ง โˆ’1 ๐‘‡ = ๐‘† ๐‘ฅ, ๐‘ฆ, ๐‘ง โˆ’ = ๐‘†(1/๐‘ฅ, 1/๐‘ฆ, 1/๐‘ง)

A More Rigorous Proof

  • Letโ€™s compute the relationship between object-space normal ๐’๐‘œ๐‘๐‘— to polygon H and world-space normal ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ to transformed version of H, called MH
  • For a vector ๐’— in the world space that lies in the polygon (e.g., one of its edge vectors), the normal is perpendicular to ๐’—: ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ โˆ™ ๐’—๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ = 0
  • But ๐’—๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ is just a transformed version of some vector in object space, ๐’—๐‘œ๐‘๐‘—, so we could write: ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ โˆ™ ๐‘€๐’—๐‘œ๐‘๐‘— = 0
  • Recall that since vectors have no position, they are unaffected by translations (w = 0) - So we need to only consider: - ๐‘€ 3 =upper left 3x3 of ๐‘€ (the rotation / scaling components) ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ โˆ™ ๐‘€ 3 ๐’—๐‘œ๐‘๐‘— = 0

A More Rigorous Proof

  • So, we have: ๐‘€ 3

๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ โˆ™ ๐’—๐‘œ๐‘๐‘— = 0

  • We also already have: ๐’๐‘œ๐‘๐‘— โˆ™ ๐’—๐‘œ๐‘๐‘— = 0
  • Therefore: ๐‘€ 3

๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ = ๐’๐‘œ๐‘๐‘—

  • Left-multiplying by ๐‘€ 3

: ๐‘€ 3

๐‘€ 3

๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ = ๐‘€ 3

๐’๐‘œ๐‘๐‘— ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ = ๐‘€ 3

๐’๐‘œ๐‘๐‘— ๐’๐‘ค๐‘œ๐‘Ÿ๐‘™๐‘‘ = ๐‘€ 3 โˆ’1 (^) t ๐’๐‘œ๐‘๐‘—

Summary:

  • Pseudocode for a non-recursive ray tracer: P = eyePoint for each pixel d = Compute Ray in World Coordinate for each object intersect P+td with object, record t and object Select object with smallest non-negative t value Find intersection point in Object Coordinate Compute normal of the point in Object Coordinate Transform normal to World Coordinate Solve lighting equation in World Coordinate Set Pixel Color