47
1 Advanced Ray Advanced Ray Tracing Tracing Mani Thomas Mani Thomas CISC 440/640 CISC 440/640 Computer Graphics Computer Graphics

1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

  • View
    221

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

11

Advanced Ray TracingAdvanced Ray Tracing

Mani ThomasMani ThomasCISC 440/640CISC 440/640

Computer GraphicsComputer Graphics

Page 2: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

22

ReviewReview Ray tracing Ray tracing

Compute 3D ray into the scene for each 2D image Compute 3D ray into the scene for each 2D image pixelpixel

Compute 3D intersection point of ray with nearest Compute 3D intersection point of ray with nearest object in sceneobject in scene

Test each primitive in the scene for intersectionTest each primitive in the scene for intersection Find nearest intersectionFind nearest intersection

Recursively spawn rays from the point of intersectionRecursively spawn rays from the point of intersection Shadow RaysShadow Rays Reflected raysReflected rays Transmitted raysTransmitted rays

Accumulate the color from each of the spawned rays Accumulate the color from each of the spawned rays at the point of intersectionat the point of intersection

Page 3: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

33

ReviewReview

Ray object intersectionRay object intersection Intersection with a planeIntersection with a plane

Implicit formImplicit form

IntersectionIntersection

Intersection with a sphereIntersection with a sphere Implicit formImplicit form

IntersectionIntersection

),,(,,,22cbazyxr cc pppp

2222 rct ccc pSpScpSc

ddczbyaxzyxF xn,,

cn

SncnSn

d

tdt 0

Page 4: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

44

ReviewReview

““Shadow feelers”Shadow feelers”Spawn a ray from P to the light sourcesSpawn a ray from P to the light sources If there is an intersection of the shadow ray If there is an intersection of the shadow ray

with any object then P is in shadowwith any object then P is in shadowReflectionReflection

Angle of incidence = angle of ReflectionAngle of incidence = angle of Reflection

nnanna

nnna

nn

na

n

n

n

nam

ˆˆˆ180cosˆ

1ˆˆ

1

2

nnaa

mammamer

ˆˆ2

2

Page 5: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

55

ReviewReview

RefractionRefractionRay passing through media of different Ray passing through media of different

refractive indices bend towards/away from the refractive indices bend towards/away from the normalnormal

Snell’s LawSnell’s Lawnnii and n and nrr are the refractive indices of the two media are the refractive indices of the two media

Transmitted rayTransmitted ray

rrii nn sinsin

nuT

i

r

ir

r

i

n

n

n

n coscos

Page 6: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

66

Road mapRoad map

Super samplingSuper samplingAcceleration techniquesAcceleration techniquesMonte Carlo methodsMonte Carlo methods

Distributed ray tracingDistributed ray tracingBidirectional ray tracingBidirectional ray tracing

CausticsCausticsPOV-rayPOV-ray

Page 7: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

77

Anti aliasingAnti 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

Page 8: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

88

Super-samplingSuper-sampling

Ray tracing is a point-sampling processRay tracing is a point-sampling process Take discrete looks at the scene along individual rays Take discrete looks at the scene along individual rays

passing through each pixelpassing through each pixel Reduce aliasing due to this discrete signal Reduce aliasing due to this discrete signal

samplingsampling

Courtesy F.S. Hill, “Computer Graphics using OpenGL”

Page 9: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

99

Adaptive Super-samplingAdaptive Super-sampling Instead of shooting one ray per Instead of shooting one ray per

pixel, shoot four rays through pixel, shoot four rays through the corners of a pixelthe corners of a pixel Color at the pixel is the Color at the pixel is the

average of the colors at each average of the colors at each cornerscorners

Adaptive super-sampling Adaptive super-sampling (Whitted’s approach)(Whitted’s approach) Compute the intensity Compute the intensity

variation between the four variation between the four corners with the averagecorners with the average

Shoot more rays through Shoot more rays through corners with higher intensity corners with higher intensity variationvariation

Compute final color as a Compute final color as a weighted average rather than weighted average rather than the regular averagethe regular average

Courtesy of C. Rasmussen, CISC 640

Page 10: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1010

Stochastic Super samplingStochastic Super sampling Visible aliasing is Visible aliasing is

possible even with possible even with adaptive super-sampling adaptive super-sampling sampling grid interacts with sampling grid interacts with

regular structuresregular structures objects aligned with objects aligned with

sampling gridsampling grid Stochastic samplingStochastic sampling

instead of a regular grid, instead of a regular grid, subsample randomlysubsample randomly

keep taking samples until keep taking samples until the color estimates the color estimates convergeconverge

jittering: perturb a regular jittering: perturb a regular gridgrid

Courtesy of C. Rasmussen, CISC 640

Page 11: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1111

Using ExtentsUsing Extents

Ray tracing is slow, performing the same Ray tracing is slow, performing the same functions.functions.

Most of the time is spent in computing Most of the time is spent in computing intersectionsintersectionsEach ray should be intersected with every Each ray should be intersected with every

object in the sceneobject in the sceneEach ray, spawns out reflected/transmitted Each ray, spawns out reflected/transmitted

rays which have to be interested with the rays which have to be interested with the objects in the sceneobjects in the scene

Page 12: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1212

Using ExtentsUsing Extents Extent of an object is a shape that encloses the objectExtent of an object is a shape that encloses the object Compute complicated intersections if and only if the ray Compute complicated intersections if and only if the ray

hits the extenthits the extent Two shapes most commonly used as extentsTwo shapes most commonly used as extents

Sphere – specified by a center and radius (C , r)Sphere – specified by a center and radius (C , r) Box – specified by sides aligned to the coordinate axisBox – specified by sides aligned to the coordinate axis

Page 13: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1313

Distributed Ray TracingDistributed Ray Tracing

Distributed ray tracing is NOT ray tracing Distributed ray tracing is NOT ray tracing on a distributed system.on a distributed system.

Distributed ray tracing is a ray tracing Distributed ray tracing is a ray tracing method based on randomly distributed method based on randomly distributed oversampling to reduce aliasing artifacts in oversampling to reduce aliasing artifacts in rendered images (Allen Martin, rendered images (Allen Martin, http://www.cs.wpi.edu/~matt/courses/cs56http://www.cs.wpi.edu/~matt/courses/cs563/talks/dist_ray/dist.html3/talks/dist_ray/dist.html))

Page 14: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1414

Distributed Ray TracingDistributed Ray Tracing

Developed by Cook, et. al. (“Developed by Cook, et. al. (“Distributed Ray Distributed Ray TracingTracing”, ”, Computer GraphicsComputer Graphics, vol. 18, no. 3, pp , vol. 18, no. 3, pp 137-145, 1984)137-145, 1984)

Stochastic Oversampling (Stochastic Oversampling (http://www.cs.virginia.edu/~cs551dl/lecture11/sldhttp://www.cs.virginia.edu/~cs551dl/lecture11/sld016.htm016.htm)) Pixel for antialiasing Pixel for antialiasing Light source for soft shadows Light source for soft shadows Reflection function for soft (glossy) reflections Reflection function for soft (glossy) reflections Time for motion blur Time for motion blur Lens for depth of fieldLens for depth of field

Page 15: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1515

Distributed Ray tracingDistributed Ray tracing

Gloss (fuzzy reflections)Gloss (fuzzy reflections) Partially reflecting surfacesPartially reflecting surfaces Traditional ray tracing Traditional ray tracing

reflections look identical to the scene they are reflectingreflections look identical to the scene they are reflecting reflections are always sharpreflections are always sharp

Randomly distributing the rays reflected by the Randomly distributing the rays reflected by the surfacesurface

Send out a packet of rays around the reflecting Send out a packet of rays around the reflecting direction. direction.

The actual value of reflectance is the statistical mean The actual value of reflectance is the statistical mean of the values returned by each of these raysof the values returned by each of these rays

Page 16: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1616

Distributed Ray tracingDistributed Ray tracing

Distributing a set of Distributing a set of reflection rays by reflection rays by randomly perturbing the randomly perturbing the ideal specular reflection ideal specular reflection ray. ray.

The spread of the The spread of the distribution determines distribution determines the glossiness where a the glossiness where a wider distribution spread wider distribution spread models a rougher models a rougher surface.   surface.  

taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html

Page 17: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1717

Distributed Ray tracingDistributed Ray tracing

first image is from the traditional ray tracerfirst image is from the traditional ray tracer second one uses 16 rays in place of the single second one uses 16 rays in place of the single

reflected rayreflected ray third image uses 64 raysthird image uses 64 rays

taken from http://www.uwm.edu/People/dtstrock/graphics/mcrt.html

Page 18: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1818

Distributed Ray tracingDistributed Ray tracing

taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html

Page 19: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

1919

Distributed Ray tracingDistributed Ray tracing

Fuzzy translucencyFuzzy translucency Same as glossy reflections, but you jitter the refracted Same as glossy reflections, but you jitter the refracted

rayray Analytical function similar to the shadingAnalytical function similar to the shading

A transmission function is used instead of a reflectance A transmission function is used instead of a reflectance functionfunction

Light is gathered from the other side of the surface. Light is gathered from the other side of the surface.

Cast randomly distributed rays in the general direction Cast randomly distributed rays in the general direction of the transmitted ray from traditional ray tracing. of the transmitted ray from traditional ray tracing.

The average value computed from each of these rays The average value computed from each of these rays the true translucent component. the true translucent component.

Page 20: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2020

Distributed Ray tracingDistributed Ray tracing

first image is obtained from a traditional ray first image is obtained from a traditional ray tracertracer

Second image uses 10 rays for the transmitted Second image uses 10 rays for the transmitted rayray

third image uses 20 raysthird image uses 20 raystaken from http://www.cs.wpi.edu/~matt/courses/cs563/talks/dist_ray/dist_trans_fuzzy_20.html

Page 21: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2121

Distributed Ray tracingDistributed Ray tracing

first image is from the traditional ray tracerfirst image is from the traditional ray tracer second one uses 16 rays in place of the single second one uses 16 rays in place of the single

reflected rayreflected ray third images uses 64 raysthird images uses 64 rays

taken from http://www.uwm.edu/People/dtstrock/graphics/mcrt.html

Page 22: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2222

Distributed Ray tracingDistributed Ray tracing

Penumbras (soft shadows)Penumbras (soft shadows)Traditional ray tracing shadows are discreteTraditional ray tracing shadows are discrete

Shadow feelers used to check if a point is in Shadow feelers used to check if a point is in shadow with respect to a point light sourceshadow with respect to a point light source

Incorrect for large light sources and/or light Incorrect for large light sources and/or light sources that are close to the objectsources that are close to the object

The transition from fully shadowed to partially The transition from fully shadowed to partially shadowed is gradual. shadowed is gradual. Due to the finite area of real light sources, and Due to the finite area of real light sources, and

scattering of light of other surfacesscattering of light of other surfaces

Page 23: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2323

Distributed Ray tracingDistributed Ray tracing

Penumbras (soft shadows)Penumbras (soft shadows)A set of rays are cast about the projected A set of rays are cast about the projected

area of the light source. area of the light source. The projected area helps tackle the large area light The projected area helps tackle the large area light

sourcesource

The amount of light transmitted by the ratio of The amount of light transmitted by the ratio of the number of rays that hit the source to the the number of rays that hit the source to the number of rays castnumber of rays cast

Page 24: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2424

Distributed Ray tracingDistributed Ray tracing

In case of a point source, the occluder would create a sharp shadow In case of a point source, the occluder would create a sharp shadow boundaryboundary

In an area light source or if the light source is closer to the objectIn an area light source or if the light source is closer to the object Creation of a penumbra regionCreation of a penumbra region

Sending out shadow feelers to capture the penumbra regionSending out shadow feelers to capture the penumbra region

taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html

Page 25: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2525taken from http://www.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/realistic_raytracing.html

Page 26: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2626

Distributed Ray tracingDistributed Ray tracing

taken from http://www.cs.unc.edu/~andrewz/comp238/hw2/

Page 27: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2727

Distributed Ray tracingDistributed Ray tracing Depth of field - the Depth of field - the

distance that objects distance that objects appear in focusappear in focus Objects that are too far Objects that are too far

away or two close will away or two close will appear unfocused and appear unfocused and blurryblurry

pinhole camera model pinhole camera model does not truly mimic the does not truly mimic the real world situationreal world situation

Pinhole assumed to be Pinhole assumed to be infinitely smallinfinitely small

Changing focal length Changing focal length change field of view but change field of view but does not change focusdoes not change focus

Page 28: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2828

Distributed Ray tracingDistributed Ray tracing Distributed ray tracing creates depth of field by Distributed ray tracing creates depth of field by

placing an artificial lens in front of the view placing an artificial lens in front of the view plane. plane.

Randomly distributed rays are used once again Randomly distributed rays are used once again to simulate the blurring of depth of field. to simulate the blurring of depth of field. The first ray cast is not modified by the lens.The first ray cast is not modified by the lens.

focal point of the lens is at a fixed distance along this rayfocal point of the lens is at a fixed distance along this ray Rest of the rays sent out for the same pixel will be Rest of the rays sent out for the same pixel will be

scattered about the surface of the lensscattered about the surface of the lens Points in the scene that are close to the focal point of Points in the scene that are close to the focal point of

the lens will be in sharp focus. the lens will be in sharp focus. Points closer or further away will be blurred Points closer or further away will be blurred

Page 29: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

2929taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/gallery-sp04/

Page 30: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3030

Distributed Ray tracingDistributed Ray tracing

taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/

Page 31: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3131

Distributed Ray tracingDistributed Ray tracing

Motion blurMotion blur Temporal sampling rather than spatial samplingTemporal sampling rather than spatial sampling A Frame represents an average of the scene during A Frame represents an average of the scene during

the time that the camera shutter is openthe time that the camera shutter is open Before each ray is cast, objects are translated or Before each ray is cast, objects are translated or

rotated to their correct position for that frame. rotated to their correct position for that frame. The rays are averaged to give the actual value. The rays are averaged to give the actual value. Objects with the most motion will have the most Objects with the most motion will have the most

blurring in the rendered image. blurring in the rendered image.

Page 32: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3232

Distributed Ray tracingDistributed Ray tracing

taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/

Page 33: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3333

Distributed Ray tracingDistributed Ray tracing

taken from http://www-courses.cs.uiuc.edu/~cs419/mp2/mp2-gallery-sp05/

Page 34: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3434

Bidirectional Ray tracingBidirectional Ray tracing

Created by H. Wann Jensen

caustic

Page 35: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3535

Bidirectional Ray tracingBidirectional Ray tracing

Caustic - Caustic - (Concentrated) (Concentrated) specular specular reflection/refraction reflection/refraction onto a diffuse surfaceonto a diffuse surface

Standard ray tracing Standard ray tracing cannot handle cannot handle causticscaustics

caustic

Created by H. Wann Jensen

Page 36: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3636

Light PathsLight Paths

Interactions of the light Interactions of the light ray can be expressed ray can be expressed using regular using regular expressionsexpressions L is the light sourceL is the light source E is the eye/cameraE is the eye/camera D is a diffuse surfaceD is a diffuse surface S is a specular surfaceS is a specular surface

from Sillion & Puech

Page 37: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3737

Light PathsLight Paths

Direct visualization of Direct visualization of the light: LEthe light: LE

Local illumination: Local illumination: LDE, LSELDE, LSE

Ray tracing: LS*E, Ray tracing: LS*E, LDS*ELDS*E

Caustics: LSCaustics: LS++DEDE

Taken from cisc 440/640 – Fall 2005

from Sillion & Puech

Page 38: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3838

Diffuse SurfacesDiffuse Surfaces Uncertainty in the direction that Uncertainty in the direction that

a photon will take for diffuse a photon will take for diffuse surfacessurfaces

For specular surfaces, the For specular surfaces, the BRDF (probability that BRDF (probability that incoming photon will leave in a incoming photon will leave in a particular direction) has a thin particular direction) has a thin profileprofile We can predict the direction of We can predict the direction of

the outgoing photonthe outgoing photon For an ideal diffuse surfaces, For an ideal diffuse surfaces,

the BRDF would be sphericalthe BRDF would be spherical The photon can travel along The photon can travel along

any of the direction with equal any of the direction with equal probabilityprobability

from Sillion & Puech

Page 39: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

3939

Bidirectional Ray tracingBidirectional Ray tracing

Idea: Trace forward Idea: Trace forward light rayslight rays into scene as well as into scene as well as backward backward eye rayseye rays At diffuse surfaces, light rays additively “deposit” photons in At diffuse surfaces, light rays additively “deposit” photons in

radiosity texturesradiosity textures, or “rexes”, where they are picked up by eye , or “rexes”, where they are picked up by eye raysrays

The rays of the forward and backward pass "meet in the The rays of the forward and backward pass "meet in the middle" to exchange information.middle" to exchange information.

from P. Heckbert

Paul S. Heckbert, “Adaptive radiosity textures for bidirectional ray tracing “, SIGGRAPH 1990

Page 40: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4040

RadiosityRadiosity

Handling cases such Handling cases such as LD*Eas LD*E

““Color Bleeding”Color Bleeding”

courtesy of Cornell

Page 41: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4141

SoftwaresSoftwares

Two beautiful rendering/modeling softwaresTwo beautiful rendering/modeling softwares POV-ray (POV-ray (http://www.povray.org/http://www.povray.org/))

Persistence of Vision - ray tracerPersistence of Vision - ray tracer A free rendering tool (not a modeling tool)A free rendering tool (not a modeling tool)

Uses a text based scene description language (SDL)Uses a text based scene description language (SDL) Available on Windows/linux/MAC OSAvailable on Windows/linux/MAC OS

Blender (Blender (http://www.blender3d.orghttp://www.blender3d.org)) Modeling, Animation, rendering toolModeling, Animation, rendering tool

Especially useful in 3D game creationEspecially useful in 3D game creation Available for Windows, Linux, Irix, Sun Solaris, Available for Windows, Linux, Irix, Sun Solaris,

FreeBSD or Mac OS X under GPLFreeBSD or Mac OS X under GPL

Page 42: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4242

POV-rayPOV-ray

created using POV-ray, http://www.povray.org/

Page 43: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4343

POV-rayPOV-ray

created using POV-ray, http://www.povray.org/

Page 44: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4444

POV-rayPOV-ray

created using POV-ray, http://www.povray.org/

Page 45: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4545

POV-rayPOV-ray

created using POV-ray, http://www.povray.org/

Page 46: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4646

ConclusionConclusion

Traditional Ray tracingTraditional Ray tracingShadow feelersShadow feelersReflectionReflectionRefractionRefraction

Distributed Ray tracingDistributed Ray tracingJittered samplingJittered sampling

Bidirectional Ray tracingBidirectional Ray tracingCausticsCaustics

Page 47: 1 Advanced Ray Tracing Mani Thomas CISC 440/640 Computer Graphics

4747

Thank youThank you