Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ray Tracing Geometry CSE 681.

Similar presentations


Presentation on theme: "Ray Tracing Geometry CSE 681."— Presentation transcript:

1 Ray Tracing Geometry CSE 681

2 Camera Setup CSE 681

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

4 Camera Setup =? Tan(q/2) = yres*pixelHeight/2N
pixelHeight = 2*Tan(qy/2) *N/yres =N pixelWidth = 2*Tan(qx/2) *N/xres CSE 681

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

6 Pixel Calculation Tan(q/2) = yres*pixelHeight/2N
pixelHeight = 2*Tan(qy/2) *N/yres pixelWidth = 2*Tan(qx/2) *N/xres Pixel AspectRatio = pixelWidth/pixelHeight Coordinate (in u,v,n space) of upper left corner of screen = ? CSE 681

7 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)*PixelWidth*u + (yres/2)*PixelHeight *v CSE 681

8 Pixel Calculation Coordinate (in u,v,n space) of upper left pixel center = ? Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v + (pixelWidth/2)*u - (pixelHeight/2)*v CSE 681

9 Interate through pixel Centers
scanlineStart = Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v + (pixelWidth/2)*u - (pixelHeight/2)*v pixelCenter += pixelWidth * u scanlineStart -= pixelHeight * v CSE 681

10 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) { closestObject = object distancemin = distance } CSE 681

11 Organization of Ray Tracer
If (distancemin > infinityThreshold) pixelColor = background color else pixelColor = color of object at distancemin along ray d ray object eye CSE 681

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

13 Ray-Sphere Intersection - algebraic
x2 + y2 + z2 = r2 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 = r2 Expand squared terms and collect terms based on powers of d: A* t 2 + B* t + C = 0 CSE 681

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


Download ppt "Ray Tracing Geometry CSE 681."

Similar presentations


Ads by Google