New version page

UVA CS 445 - Ray Casting

Documents in this Course
Lighting

Lighting

49 pages

Color

Color

20 pages

Clipping

Clipping

10 pages

Shadows

Shadows

95 pages

Color

Color

37 pages

Radiosity

Radiosity

49 pages

Clipping

Clipping

59 pages

Assign 3

Assign 3

28 pages

Splines

Splines

17 pages

Color

Color

17 pages

Load more

This preview shows page 1-2-3-24-25-26-27-49-50-51 out of 51 pages.

View Full Document
View Full Document

End of preview. Want to read all 51 pages?

Upload your study docs or become a GradeBuddy member to access this document.

View Full Document
Unformatted text preview:

Ray Casting3D RenderingSlide 3Slide 4Ray casting != Ray tracingCompare to “real-time” graphicsRendered without raytracingRendered with raytracingSlide 9Slide 10Slide 11Slide 12Slide 13Constructing Ray Through a PixelSlide 15Slide 16Ray-Scene IntersectionRay-Sphere IntersectionSlide 19Slide 20Slide 21Ray-Triangle IntersectionRay-Plane IntersectionRay-Triangle Intersection IRay-Triangle Intersection IIRay-Triangle Intersection IIIOther Ray-Primitive IntersectionsSlide 28Slide 29Bounding VolumesBounding Volume Hierarchies IBounding Volume HierarchiesBounding Volume Hierarchies IIISlide 34Uniform GridSlide 36Slide 37Slide 38OctreeSlide 40Slide 41Binary Space Partition (BSP) TreeSlide 43Slide 44BSP DemoFirst game-based use of BSP treesOther AccelerationsAccelerationSummaryHeckbert’s business card ray tracerNext Time is Illumination!Ray CastingAaron BloomfieldCS 445: Introduction to GraphicsFall 200623D RenderingThe color of each pixel on the view planedepends on the radiance emanating from visible surfacesView planeEye positionSimplest methodis ray castingSimplest methodis ray castingRays throughview plane3Ray CastingFor each sample …Construct ray from eye position through view planeFind first surface intersected by ray through pixelCompute color sample based on surface radiance4Ray CastingFor each sample …Construct ray from eye position through view planeFind first surface intersected by ray through pixelCompute color sample based on surface radianceSamples on view planeEye positionRays throughview planeWHY?5Ray casting != Ray tracingRay casting does not handle reflectionsThese can be “faked” by environment mapsThis speeds up the algorithmRay tracing doesAnd is thus much slowerWe will generally be vague about the difference6Compare to “real-time” graphicsThe 3-D scene is “flattened” into a 2-D view planeRay tracing is MUCH slowerBut can handle reflections much betterSome examples on the next few slidesView planeEye position(focal point)7Rendered without raytracing8Rendered with raytracing9101112Ray CastingSimple implementation:Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(hit);}}return image;}13Ray CastingSimple implementation:Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = Co nstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = Co nstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(hit);}}return image;}14Constructing Ray Through a PixelrightbackUp directionP0towardsViewPlanePVRay: P = P0 + tVRay: P = P0 + tV15Constructing Ray Through a Pixel2D ExampledtowardsP0rightright = towards x up = frustum half-angled = distance to view planeP1 = P0 + d*towards – d*tan()*rightP2 = P0 + d*towards + d*tan()*rightP1P22*d*tan(PP = P1 + (i+ 0.5) /width * (P2 - P1) = P1 + (i+ 0.5) /width * 2*d*tan ()*rightV = (P - P0) / | P - P0 |VRay: P = P0 + tVRay: P = P0 + tV16Ray CastingSimple implementation:Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection (ray, scene);image[i][j] = GetColor(hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection (ray, scene);image[i][j] = GetColor(hit);}}return image;}17Ray-Scene IntersectionIntersections with geometric primitivesSphereTriangleGroups of primitives (scene)Acceleration techniquesBounding volume hierarchiesSpatial partitionsUniform gridsOctreesBSP trees18Ray-Sphere IntersectionRay: P = P0 + tVSphere: |P - C|2 - r 2 = 0 P0VCPrP’19Ray-Sphere IntersectionRay: P = P0 + tVSphere: (x - cx)2 + (y - cy)2 + (z - cz)2 = r 2 |P - C|2 - r 2 = 0 Substituting for P, we get:|P0 + tV - C|2 - r 2 = 0 Solve quadratic equation: at2 + bt + c = 0where:a = |V|2 = 1b = 2 V • (P0 - C) c = |P0 - C|2 - r 2P = P0 + tVP0VCPrP’If ray direction is normalized!20Ray-Sphere IntersectionP0VCPrN = (P - C) / |P - C|NNeed normal vector at intersection for lighting calculations21Ray-Scene IntersectionIntersections with geometric primitivesSphere»TriangleGroups of primitives (scene)Acceleration techniquesBounding volume hierarchiesSpatial partitionsUniform gridsOctreesBSP trees22Ray-Triangle IntersectionFirst, intersect ray with planeThen, check if point is inside trianglePP0V23Ray-Plane IntersectionRay: P = P0 + tVPlane: ax + by + cz + d = 0 P • N + d = 0Substituting for P, we get:(P0 + tV) • N + d = 0Solution: t = -(P0 • N + d) / (V • N)P = P0 + tVNPP0V24Ray-Triangle Intersection ICheck if point is inside triangle geometricallyFirst, find ray intersection point on plane defined by triangleAxB will point in the opposite direction from CxBPT1T2T3P’ABCSameSide(p1,p2, a,b): cp1 = Cross (b-a, p1-a) cp2 = Cross (b-a, p2-a) return Dot (cp1, cp2) >= 0 PointInTriangle(p, t1, t2, t3): return SameSide(p, t1, t2, t3) and SameSide(p, t2, t1, t3) and SameSide(p, t3, t1, t2)25SameSide(p1,p2, a,b): cp1 = Cross (b-a, p1-a) cp2 = Cross (b-a, p2-a) return Dot (cp1, cp2) >= 0 PointInTriangle(p, t1, t2, t3): return SameSide(p,


View Full Document
Loading Unlocking...
Login

Join to view Ray Casting 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 Casting 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?