Ray Tracing Outline - inst.eecs.berkeley.edu

Ray Tracing Outline - inst.eecs.berkeley.edu

Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest intersection, x. } If x exists { For each light source { For all other objects { Check for intersection of ray from light to x. } If no intersection { Calculate direct illumination with Phong model. } Accumulate calculated color. }

Calculate reflection ray r, and recurse calling trace( r ) Accumulate reflected colors, and return. } } Leverage C++ Using C++ will make complicated code very simple. Take advantage of it! Abstract base class Object. Subclasses for spheres, triangles, etc. Store objects as array of pointers, and iterate with virtual Intersect function. Common information (Kd, Ks, Ka) Each actual object type will have its own intersection function. Data Structures

Sphere: center, radius Ellipsoid: Just sphere with 4x4 tranformation applied to it. Triangle: vertices, normal Ray: start, direction Input files: Can use parser from As3 Need: camera information, object information Objects should at least have Ks, Kd, color, location, but the assignment is open-ended. E.g., can have Ka if you want, or not. Can have texture map information. Intersections Parametric ray equation: r(t)=p+td t>=0 Implicit sphere equation: f(p)=||p-c||-r=0

p is any point on spheres surface, c is the center, r is the radius. Intersection (with an implicit equation) is just root finding. Explicit triangle equation: t(u,v)=(1-u-v)v0+uv1+vv2 Barycentric Solve linear system of equations. Intersections (More) Ellipsoids (from www-courses.cs.uiuc.edu/~cs419/rayintersection.ppt) Ellipsoid Intersection d o Let T be a 4x4 transformation that

distorts a sphere into the ellipsoid Ellipsoid is implicit surface of f(T-1x) f(T-1r(t)) = f(T-1(o + t d)) = f(T-1o + t T-1d) Ellipsoid::Intersect(Ray Ellipsoid::Intersect(Rayr)r){{ Ray RayTir Tir==(Ti (Ti**r.o, r.o,Ti Ti**r.d); r.d); return returnSphere::Intersect(Tir); Sphere::Intersect(Tir); }}

Hit point needs to be in world coords t same in both coordinates x=o+td These eqns should be flipped f(T-1x)=0 x T T-1 T-1d T-1o f(x) = 0 T-1x

Local Illumination (a quick reminder) Phong illumination model (not to be confused with Phong shading) For each light: Speeding things up BSP trees with bounding boxes Intersections take up most of the time. If create BSP structure, then can check for intersection from front to back from a given starting ray location. Octrees Figure out which cells it intersects, and check for intersections only with objects inside those cells

More features Here are some suggestions: Transparency with refraction Anti-aliasing Lens effects / depth of field Super quadrics Programmable shading Texture, bump, and/or displacement mapping

Spot lights and/or area lights Other interesting features Tips Make sure you test your code early and often. Ray tracers are hard to debug. Dont try to implement everything at once. E.g., start with only spheres, 1 light source, and a constant local illumination value to test your intersection code. Take advantage of the newsgroup. This assignment is open-ended. However, we strongly suggest using C++. Very strongly. Start now! You dont know what silly problems youll encounter. Plus, youll get really into it and want to add lots of extra features.

Recently Viewed Presentations

  • Слайд 1 - unipi.it

    Слайд 1 - unipi.it

    PLC-ENGINEERING. INTRODUCTION TO CYBERSECURITY. ... use control terminology in English. Process Control Systems. The course is delivered through a combination of lectures and hands-on real life situations training with Emerson DeltaV distributed control system (DCS) currently used in industry. ...
  • www.dps61.org


    Mitosis. All daughter cells contain the same genetic information from the original parent cell from which it was copied. Every different type cell in your body contains the . same
  • Workplace Hazardous Materials Information System

    Workplace Hazardous Materials Information System

    Workplace Hazardous Materials Information System. The Three Components of WHMIS. Labels. Material Safety Data Sheets (MSDS) Education and Training. WHMIS does not apply to: Radioactive Materials. Pesticides. Explosives. Consumer Products. Materials covered by Food and Drug legislation.
  • Integrated Management & Proactive Care for the Vulnerable and ...

    Integrated Management & Proactive Care for the Vulnerable and ...

    What is the IMProVE Programme?. The number of people who are elderly, vulnerable and living with a long-term condition in South Tees is increasing. The CCG working closely with social care and other health partners, want to improve the quality...
  • Using MyMathLab - Purdue University

    Using MyMathLab - Purdue University

    Using MyMathLab. Features. ... Login with your login name and password. ... For math tutoring at the Tutor Center call . 1-800-435-4084 between 5 PM and midnight Sunday through Thursday. You must use your MyMathLab course ID or student access...


    Data for France exclude Martinique. Data for Guatemala exclude pediatric ESRD patients and patients receiving non-institutional RRT. Data for Indonesia represent the West Java region. Data for Italy representative of 35% (7 out of 19 regio ... PowerPoint Presentation Last...
  • Lecture 7b - UCLA

    Lecture 7b - UCLA

    Increasing strength of the p-back bond strengthens the M-N bond and weakens the N-O bond. In extreme cases, both bonds can be characterized as double bonds (II). In cases in which the M-N-O angle is close to 180o, the M-N...
  • Government Relations Update Council for Opportunity in Education

    Government Relations Update Council for Opportunity in Education

    COE Updates . First-Generation Celebration . November 8th. How are you celebrating on YOUR college campus? Puerto Rico Recovery Fund. The First-Generation Celebration commemorates the 52nd anniversary of the HEA by encouraging colleges and universities across the country to celebrate...