470 likes | 605 Views
Advanced Ray Tracing. Mani Thomas CISC 440/640 Computer Graphics. Review. Ray tracing Compute 3D ray into the scene for each 2D image pixel Compute 3D intersection point of ray with nearest object in scene Test each primitive in the scene for intersection Find nearest intersection
E N D
Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics
Review • Ray tracing • Compute 3D ray into the scene for each 2D image pixel • Compute 3D intersection point of ray with nearest object in scene • Test each primitive in the scene for intersection • Find nearest intersection • Recursively spawn rays from the point of intersection • Shadow Rays • Reflected rays • Transmitted rays • Accumulate the color from each of the spawned rays at the point of intersection
Review • Ray object intersection • Intersection with a plane • Implicit form • Intersection • Intersection with a sphere • Implicit form • Intersection
Review • “Shadow feelers” • Spawn a ray from P to the light sources • If there is an intersection of the shadow ray with any object then P is in shadow • Reflection • Angle of incidence = angle of Reflection
Review • Refraction • Ray passing through media of different refractive indices bend towards/away from the normal • Snell’s Law • ni and nr are the refractive indices of the two media • Transmitted ray
Road map • Super sampling • Acceleration techniques • Monte Carlo methods • Distributed ray tracing • Bidirectional ray tracing • Caustics • POV-ray
Anti aliasing • Ray tracing gives a color for every possible point in the image • But a square pixel contains an infinite number of points • These points may not all have the same color • Sampling: choose the color of one point (center of pixel) • This leads to aliasing • jaggies • moire patterns • Aliasing means one frequency (high) masquerading as another (low) • e.g. wagon wheel effect
Super-sampling • Ray tracing is a point-sampling process • Take discrete looks at the scene along individual rays passing through each pixel • Reduce aliasing due to this discrete signal sampling Courtesy F.S. Hill, “Computer Graphics using OpenGL”
Adaptive Super-sampling • Instead of shooting one ray per pixel, shoot four rays through the corners of a pixel • Color at the pixel is the average of the colors at each corners • Adaptive super-sampling (Whitted’s approach) • Compute the intensity variation between the four corners with the average • Shoot more rays through corners with higher intensity variation • Compute final color as a weighted average rather than the regular average Courtesy of C. Rasmussen, CISC 640
Stochastic Super sampling • Visible aliasing is possible even with adaptive super-sampling • sampling grid interacts with regular structures • objects aligned with sampling grid • Stochastic sampling • instead of a regular grid, subsample randomly • keep taking samples until the color estimates converge • jittering: perturb a regular grid Courtesy of C. Rasmussen, CISC 640
Using Extents • Ray tracing is slow, performing the same functions. • Most of the time is spent in computing intersections • Each ray should be intersected with every object in the scene • Each ray, spawns out reflected/transmitted rays which have to be interested with the objects in the scene
Using Extents • Extent of an object is a shape that encloses the object • Compute complicated intersections if and only if the ray hits the extent • Two shapes most commonly used as extents • Sphere – specified by a center and radius (C , r) • Box – specified by sides aligned to the coordinate axis
Distributed Ray Tracing • Distributed ray tracing is NOT ray tracing on a distributed system. • Distributed ray tracing is a ray tracing method based on randomly distributed oversampling to reduce aliasing artifacts in rendered images (Allen Martin, http://www.cs.wpi.edu/~matt/courses/cs563/talks/dist_ray/dist.html)
Distributed Ray Tracing • Developed by Cook, et. al. (“Distributed Ray Tracing”, Computer Graphics, vol. 18, no. 3, pp 137-145, 1984) • Stochastic Oversampling (http://www.cs.virginia.edu/~cs551dl/lecture11/sld016.htm) • Pixel for antialiasing • Light source for soft shadows • Reflection function for soft (glossy) reflections • Time for motion blur • Lens for depth of field
Distributed Ray tracing • Gloss (fuzzy reflections) • Partially reflecting surfaces • Traditional ray tracing • reflections look identical to the scene they are reflecting • reflections are always sharp • Randomly distributing the rays reflected by the surface • Send out a packet of rays around the reflecting direction. • The actual value of reflectance is the statistical mean of the values returned by each of these rays
Distributed Ray tracing • Distributing a set of reflection rays by randomly perturbing the ideal specular reflection ray. • The spread of the distribution determines the glossiness where a wider distribution spread models a rougher surface. taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html
Distributed Ray tracing • first image is from the traditional ray tracer • second one uses 16 rays in place of the single reflected ray • third image uses 64 rays taken from http://www.uwm.edu/People/dtstrock/graphics/mcrt.html
Distributed Ray tracing taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html
Distributed Ray tracing • Fuzzy translucency • Same as glossy reflections, but you jitter the refracted ray • Analytical function similar to the shading • A transmission function is used instead of a reflectance function • Light is gathered from the other side of the surface. • Cast randomly distributed rays in the general direction of the transmitted ray from traditional ray tracing. • The average value computed from each of these rays the true translucent component.
Distributed Ray tracing • first image is obtained from a traditional ray tracer • Second image uses 10 rays for the transmitted ray • third image uses 20 rays taken from http://www.cs.wpi.edu/~matt/courses/cs563/talks/dist_ray/dist_trans_fuzzy_20.html
Distributed Ray tracing • first image is from the traditional ray tracer • second one uses 16 rays in place of the single reflected ray • third images uses 64 rays taken from http://www.uwm.edu/People/dtstrock/graphics/mcrt.html
Distributed Ray tracing • Penumbras (soft shadows) • Traditional ray tracing shadows are discrete • Shadow feelers used to check if a point is in shadow with respect to a point light source • Incorrect for large light sources and/or light sources that are close to the object • The transition from fully shadowed to partially shadowed is gradual. • Due to the finite area of real light sources, and scattering of light of other surfaces
Distributed Ray tracing • Penumbras (soft shadows) • A set of rays are cast about the projected area of the light source. • The projected area helps tackle the large area light source • The amount of light transmitted by the ratio of the number of rays that hit the source to the number of rays cast
Distributed Ray tracing • In case of a point source, the occluder would create a sharp shadow boundary • In an area light source or if the light source is closer to the object • Creation of a penumbra region • Sending out shadow feelers to capture the penumbra region taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html
taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html
Distributed Ray tracing taken from http://www.cs.unc.edu/~andrewz/comp238/hw2/
Distributed Ray tracing • Depth of field - the distance that objects appear in focus • Objects that are too far away or two close will appear unfocused and blurry • pinhole camera model does not truly mimic the real world situation • Pinhole assumed to be infinitely small • Changing focal length change field of view but does not change focus
Distributed Ray tracing • Distributed ray tracing creates depth of field by placing an artificial lens in front of the view plane. • Randomly distributed rays are used once again to simulate the blurring of depth of field. • The first ray cast is not modified by the lens. • focal point of the lens is at a fixed distance along this ray • Rest of the rays sent out for the same pixel will be scattered about the surface of the lens • Points in the scene that are close to the focal point of the lens will be in sharp focus. • Points closer or further away will be blurred
taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/gallery-sp04/
Distributed Ray tracing taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/
Distributed Ray tracing • Motion blur • Temporal sampling rather than spatial sampling • A Frame represents an average of the scene during the time that the camera shutter is open • Before each ray is cast, objects are translated or rotated to their correct position for that frame. • The rays are averaged to give the actual value. • Objects with the most motion will have the most blurring in the rendered image.
Distributed Ray tracing taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/
Distributed Ray tracing taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/
Bidirectional Ray tracing caustic Created by H. Wann Jensen
Bidirectional Ray tracing • Caustic - (Concentrated) specular reflection/refraction onto a diffuse surface • Standard ray tracing cannot handle caustics caustic Created by H. Wann Jensen
Light Paths • Interactions of the light ray can be expressed using regular expressions • L is the light source • E is the eye/camera • D is a diffuse surface • S is a specular surface from Sillion & Puech
Light Paths • Direct visualization of the light: LE • Local illumination: LDE, LSE • Ray tracing: LS*E, LDS*E • Caustics: LS+DE from Sillion & Puech Taken from cisc 440/640 – Fall 2005
Diffuse Surfaces • Uncertainty in the direction that a photon will take for diffuse surfaces • For specular surfaces, the BRDF (probability that incoming photon will leave in a particular direction) has a thin profile • We can predict the direction of the outgoing photon • For an ideal diffuse surfaces, the BRDF would be spherical • The photon can travel along any of the direction with equal probability from Sillion & Puech
Bidirectional Ray tracing from P. Heckbert • Idea: Trace forward light rays into scene as well as backward eye rays • At diffuse surfaces, light rays additively “deposit” photons in radiosity textures, or “rexes”, where they are picked up by eye rays • The rays of the forward and backward pass "meet in the middle" to exchange information. Paul S. Heckbert, “Adaptive radiosity textures for bidirectional ray tracing “, SIGGRAPH 1990
Radiosity • Handling cases such as LD*E • “Color Bleeding” courtesy of Cornell
Softwares • Two beautiful rendering/modeling softwares • POV-ray (http://www.povray.org/) • Persistence of Vision - ray tracer • A free rendering tool (not a modeling tool) • Uses a text based scene description language (SDL) • Available on Windows/linux/MAC OS • Blender (http://www.blender3d.org) • Modeling, Animation, rendering tool • Especially useful in 3D game creation • Available for Windows, Linux, Irix, Sun Solaris, FreeBSD or Mac OS X under GPL
POV-ray created using POV-ray, http://www.povray.org/
POV-ray created using POV-ray, http://www.povray.org/
POV-ray created using POV-ray, http://www.povray.org/
POV-ray created using POV-ray, http://www.povray.org/
Conclusion • Traditional Ray tracing • Shadow feelers • Reflection • Refraction • Distributed Ray tracing • Jittered sampling • Bidirectional Ray tracing • Caustics