DOC PREVIEW
UCSD CSE 167 - Ray Tracing

This preview shows page 1-2-3-4-25-26-27-52-53-54-55 out of 55 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 55 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Ray TracingCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2006Ray Tracing Ray tracing is a powerful rendering technique that is the foundation of many modern photoreal rendering algorithms The original ray tracing technique was proposed in 1980 by Turner Whitted, although there were suggestions about the possibility in scientific papers dating back to 1968 Classic ray tracing shoots virtual view rays into the scene from the camera and traces their paths as they bounce around With ray tracing, one can achieve a wide variety of complex lighting effects, such as accurate shadows and reflections/refractions from curved surfaces Achieving these effects with the same precision is difficult if not impossible with a more traditional rendering pipeline Ray tracing offers a big advance in visual quality, but comes with an expensive price of notoriously slow rendering timesRay Intersections Tracing a single ray requires determining if that ray intersects any one of potentially millions of primitives This is the basic problem of ray intersection Many algorithms exist to make this not only feasible, but remarkably efficient Tracing one ray is a complex problem and requires serious work to make it run at an acceptable speed Of course, the big problem is the fact that one needs to trace lots of rays to generate a high quality imageRays Recall that a ray is a geometric entity with an origin and a direction A ray in a 3D scene would probably use a 3D vector for the origin and a normalized 3D vector for the directionclass Ray {Vector3 Origin;Vector3 Direction;};Camera Rays We start by ‘shooting’ rays from the camera out into the scene We can render the pixels in any order we choose (even in random order!), but we will keep it simple and go from top to bottom, and left to right We loop over all of the pixels and generate an initial primary ray (also called a camera ray or eye ray) The ray origin is simply the camera’s position in world space The direction is computed by first finding the 4 corners of a virtual image in world space, then interpolating to the correct spot, and finally computing a normalized direction from the camera position to the virtual pixelCamera positionVirtual imagePrimary rayRay Intersection The initial camera ray is then tested for intersection with the 3D scene, which contains a bunch of triangles and/or other primitives If the ray doesn’t hit anything, then we can color the pixel to some specified ‘background’ color Otherwise, we want to know the first thing that the ray hits (it is possible that the ray will hit several surfaces, but we only care about the closest one to the camera) For the intersection, we need to know the position, normal, color, texture coordinate, material, and any other relevant information we can get about that exact location If we hit somewhere in the center of a triangle, for example, then this information would get computed by interpolating the vertex dataRay Intersection We will assume that the results of a ray intersection test are put into some data structure which conveniently packages it togetherclass Intersection {Vector3 Position;Vector3 Normal;Vector2 TexCoord;Material *Mtl;float Distance; // Distance from ray origin to intersection};Lighting Once we have the key intersection information (position, normal, color, texture coords, etc.) we can apply any lighting model we want This can include procedural shaders, lighting computations, texture lookups, texture combining, bump mapping, and more Many of the most interesting forms of lighting involve spawning off additional rays and tracing them recursively The result of the lighting equation is a color, which is used to color the pixelShadow Rays Shadows are an important lighting effect that can easily be computed with ray tracing If we wish to compute the illumination with shadows for a point, we shoot an additional ray from the point to every light source A light is only allowed to contribute to the final color if the ray doesn’t hit anything in between the point and the light source The lighting equation we looked at earlier in the quarter can easily be adapted to handle this, as clgtiwill be 0 if the light is blocked Obviously, we don’t need to shoot a shadow ray to a light source if the dot product of the normal with the light direction is negative Also, we can put a limit of the range of a point light, so they don’t have an infinite influence (bending the laws of physics)()()()∑⋅+⋅+=sispecidifilgtambambhnmlnmccmc **Shadow RaysShadow Rays Shadow rays behave slightly differently from primary (and secondary) rays Normal rays (primary & secondary) need to know the first surface hit and then compute the color reflected off of the surface Shadow rays, however, simply need to know if something is hit or not In other words, we don’t need to compute any additional shading for the ray and we don’t need to find the closest surface hit This makes them a little faster than normal raysOffsetting Spawned Rays We say that the shadow rays are spawned off of the surface, or we might say that the primary ray spawned off additional shadow rays When we spawn new rays from a surface, it is usually a good idea to apply a slight adjustment to the origin of the ray to push it out slightly (0.00001) along the normal of the surface This fixes problems due to mathematical roundoff that might cause the ray to spawn from a point slightly below the surface, thus causing the spawned ray to appear to hit the same surfaceReflection Rays Another powerful feature often associated with ray tracing is accurate reflections off of complex surfaces If we wanted to render a surface as a perfect mirror, instead of computing the lighting through the normal equation, we just create a new reflection ray and trace it into the scene Remember that primary rays are the initial rays shot from the camera. Any reflected rays (and others, like refracted rays, etc.), are called secondary rays Reflected rays, like shadow rays should be moved slightly along the surface normal to prevent the ray from re-intersecting the same surfaceComputing Reflection Directiondnr()nnddr⋅−=2Reflections If the reflection ray hits a normal material, we just compute the illumination and use that for the final color If the reflection ray hits another mirror, we just


View Full Document

UCSD CSE 167 - Ray Tracing

Documents in this Course
Lighting

Lighting

38 pages

Review

Review

59 pages

Surfaces

Surfaces

22 pages

Review

Review

110 pages

Midterm

Midterm

4 pages

Lighting

Lighting

38 pages

Lighting

Lighting

71 pages

Review

Review

110 pages

Lighting

Lighting

71 pages

Load more
Download Ray Tracing
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Ray Tracing and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Ray Tracing 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?