Ray Intersect - Introduction to Computer Graphics - Lecture Slides, Slides of Computer Graphics

In Introduction to Computer Graphics course we study the basic concept of the principle of computer architecture. In these lecture slides the key points are:Ray Casting, Data Set Anticipates, Command Line Input, Polygon Creation, Line Clipping, Math for Ray Casting, Generating Rays, Coloring Pixels, Phong Shading, Software Architecture, Ray-Tracing Algorithm

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarasvan
sarasvan ๐Ÿ‡ฎ๐Ÿ‡ณ

4.4

(20)

118 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 17:
Ray Intersect
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Ray Intersect - Introduction to Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Lecture 17:

Ray Intersect

Review

โ€ข In ray casting, there are three steps:

โ€“ Step 1: Generating a Ray

  • A. Find the ray in world coordinate system
  • B. Find the ray in camera coordinate system and transform it

to world coordinate

โ€“ Step 2: Intersection

  • Intersects the ray with all objects in the world
  • Return the nearest point on the nearest object

โ€“ Step 3: Coloring the Pixel

  • Direct illumination (Assignment 5: intersect)
  • Indirect illumination (Assignment 6: recursive ray tracer)

Step 2: Ray-Object Intersection

(Implicit Objects)

  • At what points (if any) does the ray intersect an object?
  • Points on a ray have form P + t d
    • t is any nonnegative real
  • A surface point Q lying on an object has the property that f(Q) = 0
  • Combining, we want to know โ€œFor which values of t is f(P + t d ) = 0 ?โ€
  • We are solving a system of simultaneous equations in x , y (in 2D) or x , y , z (in 3D)

Step 2: Ray-Object Intersection

(Implicit Objects)

2D ray-circle intersection example

  • Consider eye-point P = (-3, 1), direction vector d = (.8, -.6) and the unit circle:

f(x,y) = x^2 + y^2 โ€“ R^2

  • A typical point of the ray is:

Q = P + t d = (-3,1) + t (.8,-.6) = (-3 + .8t,1 - .6 t )

  • Plugging this into the equation of the circle:

f (Q) = f (-3 + .8t,1 - .6 t ) = (-3+.8 t )^2 + (1-.6 t )^2 - 1

  • Expanding, we get:

9 โ€“ 4.8 t + .64 t^2 + 1 โ€“ 1.2 t + .36 t^2 - 1

  • Setting this to zero, we get:

t^2 โ€“ 6 t + 9 = 0

Step 2: Ray-Object Intersection

2D ray-circle intersection example (continued)^ (Implicit Objects)

  • Generalizing:
    • we can take an arbitrary implicit surface with equation f(Q) = 0 , a ray P + t d , and plug the latter into the former:

f ( P + t d ) = 0

  • The result, after some algebra, is an equation with t as unknown
  • We then solve for t , analytically or numerically

Step 2: Ray-Object Intersection

  • For cylindrical objects, the implicit equation^ (Implicit Objects)

๐‘“(๐‘ฅ, ๐‘ฆ, ๐‘ง) = ๐‘ฅ^2 + ๐‘ง^2 โ€“ 1 = 0

in 3-space defines an infinite cylinder of unit radius, running along the y-axis

  • Usually, itโ€™s more useful to work with finite objects
    • e.g. a unit cylinder truncated with the limits: Cylinder Body: ๐‘ฅ^2 + ๐‘ง^2 โ€“ 1 = 0, โˆ’1 โ‰ค ๐‘ฆ โ‰ค 1
  • But how do we implicitly define cylinder โ€œcaps?โ€
  • The cap is the inside of the cylinder at the y extrema of the cylinder (a.k.a. a circle)
    • cylinder caps top: ๐‘ฅ^2 + ๐‘ง^2 โ€“ 1 โ‰ค 0, ๐‘ฆ = 1

bottom: ๐‘ฅ^2 + ๐‘ง^2 โ€“ 1 โ‰ค 0, ๐‘ฆ = โˆ’

Cap

Step 2: Ray-Object Intersection

(Implicit Objects)

Implicit surface strategy summary

  • Substitute ray ( P + t d ) into implicit surface equations and solve for t
    • smallest non-negative t -value is the closest surface you see from eye point
  • For complicated objects (not defined by a single equation), write out a set of equalities and inequalities and then code individual surfaces as casesโ€ฆ
  • Latter approach can be generalized cleverly to handle all sorts of complex combinations of objects - constructive Solid Geometry (CSG), where objects are stored as a hierarchy of primitives and 3-D set operations (union, intersection, difference) - โ€œblobby objectsโ€, which are implicit surfaces defined by sums of implicit equations (F(x,y,z)= 0 )
CSG!

Cool Blob!

Step 2: Ray-Object Intersection

โ€ข So far, we have seen how intersection works if

the object is in the world coordinate, and its

parameters are simple

โ€“ That is, the object sits at (0, 0, 0), and has unit radius

โ€ข In real examples, the objects have often been

translated, rotated, and scaled.

โ€ข How would we apply the same solution to these

objects?

Step 2: Ray-Object Intersection (Object

Coord)

  • Let the world-space intersection point be defined as MQ , where Q is a point in object space: ๐‘ƒ + ๐‘ก๐’… = ๐‘€๐‘„ ๐‘€โˆ’1^ โ‹… ๐‘ƒ + ๐‘ก๐’… = ๐‘„ ๐‘€โˆ’1๐‘ƒ + ๐‘ก๐‘€โˆ’1๐’… = ๐‘„ Let ๐‘ƒ = ๐‘€โˆ’1๐‘ƒ, ๐’… = ๐‘€โˆ’1๐’…
  • If ๐‘“ ๐‘ฅ, ๐‘ฆ, ๐‘ง is the equation of the untransformed object, we just have to solve ๐‘“ ๐‘ƒ + ๐‘ก๐’… = 0
  • note: ๐’… is probably not a unit vector
  • the parameter t along this vector and its world space counterpart always have the same value.
  • normalizing ๐’… would alter this relationship. Do NOT normalize ๐’…. Why??

(0,0,0)

MQ

P ๏€ซ t d

f ( x , y , z )๏€ฝ 0

d^11 d

~ ~ ๏€ญ ๏€ญ P ๏€ซ t ๏€ฝ M P ๏€ซ tM

Q

f x y z ๏€ฝ

Step 2: Ray-Object Intersection (Object

Coord)

  • In the example, we already know the matrix M, which transforms the

object from object coordinate into world coordinate.

  • Recall, M is the matrix that translate/rotate/scales a unit object into the desired location/orientation/size
  • We are just finding the inverse of M, which will bring the ray from world

coordinate back to object coordinate.

  • The advantage is obvious, math is easier in the object coordinate space!
  • As mentioned before, you need to find the smallest t-value from the

intersection test, you can use t in two ways:

  • ๐‘ƒ + ๐‘ก๐’… gives the world coordinate location of the intersection point
  • ๐‘ƒ + ๐‘ก๐’… is the corresponding intersection point in object coordinate
  • Note that the t value doesnโ€™t change between the two coordinate spaces!