Ray Tracing Geometry CSE 681 Camera Setup CSE

  • Slides: 14
Download presentation
Ray Tracing Geometry CSE 681

Ray Tracing Geometry CSE 681

Camera Setup CSE 681

Camera Setup CSE 681

Camera Setup “up” vector n v w View direction u Can be formed as

Camera Setup “up” vector n v w View direction u Can be formed as cross product of view vector and up vector CSE 681

Camera Setup =? Tan(q/2) = yres*pixel. Height/2 N =N pixel. Height = 2*Tan(qy/2) *N/yres

Camera Setup =? Tan(q/2) = yres*pixel. Height/2 N =N pixel. Height = 2*Tan(qy/2) *N/yres pixel. Width = 2*Tan(qx/2) *N/xres CSE 681

Screen Placement How do images differ if the resolution doesn’t change? CSE 681

Screen Placement How do images differ if the resolution doesn’t change? CSE 681

Pixel Calculation Tan(q/2) = yres*pixel. Height/2 N pixel. Height = 2*Tan(qy/2) *N/yres pixel. Width

Pixel Calculation Tan(q/2) = yres*pixel. Height/2 N pixel. Height = 2*Tan(qy/2) *N/yres pixel. Width = 2*Tan(qx/2) *N/xres Pixel Aspect. Ratio = pixel. Width/pixel. Height Coordinate (in u, v, n space) of upper left corner of screen = ? CSE 681

Pixel Calculation Coordinate (in u, v, n space) of upper left corner of screen

Pixel Calculation Coordinate (in u, v, n space) of upper left corner of screen = ? Assume virtual screen is one unit away (N=1) in w direction Eye + w - (xres/2)*Pixel. Width*u + (yres/2)*Pixel. Height *v CSE 681

Pixel Calculation Coordinate (in u, v, n space) of upper left pixel center =

Pixel Calculation Coordinate (in u, v, n space) of upper left pixel center = ? Eye + w - (xres/2)*Pixel. Width*u + (yres/2)*Pixel. Height *v + (pixel. Width/2)*u - (pixel. Height/2)*v CSE 681

Interate through pixel Centers pixel. Center = scanline. Start = Eye + w(xres/2)*Pixel. Width*u

Interate through pixel Centers pixel. Center = scanline. Start = Eye + w(xres/2)*Pixel. Width*u + (yres/2)*Pixel. Height *v + (pixel. Width/2)*u (pixel. Height/2)*v pixel. Center += pixel. Width * u scanline. Start -= pixel. Height * v CSE 681

Organization of Ray Tracer For each pixel { Form ray from eye through pixel

Organization of Ray Tracer For each pixel { Form ray from eye through pixel distancemin = infinity For each object { If (distance=intersect(ray, object)) { If (distance< distancemin) { closest. Object = object distancemin = distance } } CSE 681

Organization of Ray Tracer If (distancemin > infinity. Threshold) pixel. Color = background color

Organization of Ray Tracer If (distancemin > infinity. Threshold) pixel. Color = background color else pixel. Color = color of object at distancemin along ray d eye ray object CSE 681

Ray-Sphere Intersection - geometric Knowns C, r Eye Ray t = |C-eye| d eye

Ray-Sphere Intersection - geometric Knowns C, r Eye Ray t = |C-eye| d eye d+k = (C-eye) · Ray k r s t 2= (d+k) 2 + s 2 C t CSE 681 r 2 = k 2+ s 2

Ray-Sphere Intersection - algebraic x 2 + y 2 + z 2 = r

Ray-Sphere Intersection - algebraic x 2 + y 2 + z 2 = r 2 p = eye + t*Ray Substitute definition of p into first equation: (eye. x+ t *ray. x) 2 + (eye. y+ t *ray. y)2 + (eye. z+ t *ray. z) 2 = r 2 Expand squared terms and collect terms based on powers of d: A* t 2 + B* t + C = 0 CSE 681

Determine Color Use z-component of normalized normal vector FOR LAB #1 Clamp to [0.

Determine Color Use z-component of normalized normal vector FOR LAB #1 Clamp to [0. 3. . 1. 0] N object. Color*Nz What’s the normal at a point on the sphere? ray eye CSE 681