Visibility Problem Rendering converting a model to an image Visibility deciding which objects or parts will appear in the image Object order OpenGL later Imageorder Ray Tracing now ID: 1025204
Download Presentation The PPT/PDF document "Basic Ray Tracing CMSC 435/634" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
1. Basic Ray TracingCMSC 435/634
2. Visibility ProblemRendering: converting a model to an imageVisibility: deciding which objects (or parts) will appear in the imageObject-orderOpenGL (later)Image-order Ray Tracing (now)
3. RaytracingGivenSceneViewpointViewplaneCast ray from viewpoint through pixels into scene
4. View
5. Computing Viewing RaysParametric ray Camera frame : eye point : basis vectorsright, up, backwardRight hand rule!Screen position
6. Calculating IntersectionsDefine ray parametrically: If is center of projection andis center of pixel, then : points between those locations : points behind viewer : points beyond view window
7. Ray-Sphere IntersectionSphere in vector formRay Intersection when
8. Ray-Polygon IntersectionGiven ray and plane containing polygonWhat is ray/plane intersection?Is intersection point inside polygon?
9. Ray-Triangle IntersectionIntersection of ray with barycentric triangleIn triangle if α ≥ 0, ≥ 0, ≥ 0To avoid computing all three, can replace α ≥ 0 with + ≤ 1boolean raytri (ray r, vector p0, p1, p2, interval [t0,t1] ){ compute tif (( t < t0 ) or (t > t1)) return ( false )compute if (( < 0 ) or ( > 1)) return ( false )compute if (( < 0 ) or (+ > 1)) return ( false ) return true}
10. Point in Polygon?Is P in polygon?Cast ray from P to infinity1 crossing = inside0, 2 crossings = outside
11. Point in Polygon?Is P in concave polygon?Cast ray from P to infinityOdd crossings = insideEven crossings = outside
12. What Happens?
13. Raytracing CharacteristicsGoodSimple to implementMinimal memory requiredEasy to extendBadAliasingComputationally intensiveIntersections expensive (75-90% of rendering time)Lots of rays
14. Basic Illumination ConceptsTermsIllumination: calculating light intensity at a point (object space; equation) based loosely on physical lawsShading: algorithm for calculating intensities at pixels (image space; algorithm) ObjectsLight sources: light-emittingOther objects: light-reflectingLight sourcesPoint (special case: at infinity)Area
15. Lambert’s LawIntensity of reflected light related to orientation
16. Lambert’s LawSpecifically: the radiant energy from any small surface area dA in any direction relative to the surface normal is proportional to cos
17. Ambient LightAdditional light bounces we’re not countingApproximate them as a constant = Amount of extra light coming into this surface = Amount that bounces off of this surface Total extra light bouncing off this surface
18. Combined ModelAdding color:For any wavelength :
19. 19ShadowsWhat if there is an object between the surface and light?
20. Ray Traced ShadowsTrace a rayStart = point on surfaceEnd = light sourcet=0 at Suface, t=1 at Light“Bias” to avoid surface acneTestBias ≤ t ≤ 1 = shadowt < Bias or t > 1 = use this light
21. Mirror ReflectionThe Dark Side of the Trees - Gilles Tran, Spheres - Martin K. B.21
22. 22Ray Tracing ReflectionViewer looking in direction d sees whatever the viewer “below” the surface sees looking in direction rIn the real world Energy loss on the bounceLoss different for different colorsNew rayStart on surface, in reflection direction
23. Calculating Reflection VectorAngle of of incidence= angle of reflectionDecomposeRecompose
24. Ray Traced ReflectionAvoid looping foreverStop after n bouncesStop when contribution to pixel gets too small
25. Specular ReflectionShiny reflection from rough surfaceCentered around mirror reflection directionBut more spread more, depending on roughnessEasiest for individual light sources
26. Specular vs. Mirror Reflection
27. H vectorStrongest for normal that reflects to One at center of highlightZero at 90°Control highlight width
28. Combined Specular & MirrorMany surfaces have both
29. Refraction
30.
31. Top
32. Front
33. Calculating Refraction VectorSnell’s LawIn terms of term
34. Calculating Refraction VectorSnell’s LawIn terms of term
35. Calculating Refraction VectorSnell’s LawIn terms ofIn terms of and
36. Alpha BlendingHow much makes it througha = opacityHow much of foreground color 0-11-a = transparencyHow much of background colorForeground*a + Background*(1-a)
37. Refraction and AlphaRefraction = what directiona = how muchOften approximate as a constantBetter: Use FresnelSchlick approximation
38. Full Ray-TracingFor each pixelCompute ray directionFind closest surfaceFor each lightShoot shadow rayIf not shadowed, add direct illuminationShoot ray in reflection directionShoot ray in refraction direction
39. Motion BlurThings move while the shutter is open
40. Ray Traced Motion BlurInclude information on object motionSpread multiple rays per pixel across time
41. Depth of FieldSoler et al., Fourier Depth of Field, ACM TOG v28n2, April 2009
42. Pinhole Lens
43. Lens Model
44. Real LensFocal Plane
45. Lens ModelFocal Plane
46. Ray Traced DOFMove image plane out to focal planeJitter start position within lens apertureSmaller aperture = closer to pinholeLarger aperture = more DOF blur