Presentation is loading. Please wait.

Presentation is loading. Please wait.

Global Illumination (3) Cone Tracing / Distributed Ray Tracing.

Similar presentations


Presentation on theme: "Global Illumination (3) Cone Tracing / Distributed Ray Tracing."— Presentation transcript:

1 Global Illumination (3) Cone Tracing / Distributed Ray Tracing

2 Conventional Ray Tracing Light Image Plane Object Infinitesimally thin rays Perfect sharp multiple reflections and shadows Not in reality! Surfaces are not perfectly smooth!

3

4

5 On the same object: blurred reflection of the direct light sources with perfect reflection of nearby objects Hybrid Model

6

7

8 Cone Tracing Amantides (1984) idea: rather than send a single thin ray, we send out a cone and determine intersections with that cone cone –circular –represented with apex, center line, spread angle –spread angle of primary ray determined by eyepoint –spread angle of secondary rays determined by material of the object Intersect the cone base with the second object, then merge those intersection intensities to determine the intensity at the original intersection point

9

10

11 Diffuse reflection Perturb directions reflection/transmission, with distribution based on angle from ideal ray Depth of field Perturb eye position on lens Soft shadows shadow Perturb illumination rays across area light Motion blur Perturb eye ray samples in time Distributed Ray Tracing Cook-Porter-Carpenter (1984) Apply distribution-based sampling to many parts of the ray-tracing algorithm Rays can also be stochastically distributed in object space to simulate

12 Diffuse reflection rays are distributed reflections around reflection direction to simulate non- smooth surfaces Depth of field origin of rays is distributed with respect to lens to get out-of-focus effect Soft shadows shadow rays are distributed around light direction to simulate area light sources Motion blur rays are distributed in time to simulate object movement Distributed Ray Tracing Apply distribution-based sampling to many parts of the ray-tracing algorithm Rays can also be stochastically distributed in object space to simulate

13 Distributed Ray Tracing

14 Diffuse reflection rays are distributed reflections around reflection direction to simulate non- smooth surfaces Depth of field origin of rays is distributed with respect to lens to get out-of-focus effect Soft shadows shadow rays are distributed around light direction to simulate area light sources Motion blur rays are distributed in time to simulate object movement Distributed Ray Tracing Rays can also be stochastically distributed in object space to simulate

15 DRT: Diffuse reflection Blurry reflections and refractions are produced by randomly perturbing the reflection and refraction rays from their "true" directions.

16 void RenderStandrad (Color *fb) { int i, j; Ray r; Color color; fb = new Color[resY*resX]; for (i = 0; I < resY; i++) { for (j = 0; j < resX; j++) { color.Set(0,0,0); calcRay (&r, j, i); color += traceRay (r); fb[i*resX + j] = color; }

17 void calcRay (Ray *r, int x, int y) { double a = ((double)resX) / resY; double d = 1.0 / tan((camera.FOV()/2)*(PI/180)); Vec3d L = camera.LookAt() - camera.Eye(); L.Normalize(); Vec3d v = L.crossProd(camera.Up()); v.Normalize(); Vec3d u = v.crossProd(L); Vec3d LL = camera.Eye() + d*L - a*v - u; Vec3d p = LL + 2*a*v*(((double)x)/resX) + 2*u*(((double)y)/resY); Vec3d dir = p - camera.Eye(); dir.Normalize(); r->setPos(camera.Eye()); r->setDir(dir); }

18 void calcRay (Ray *r, int x, int y) { double a = ((double)resX) / resY; double d = 1.0 / tan((camera.FOV()/2)*(PI/180)); Vec3d L = camera.LookAt() - camera.Eye(); L.Normalize(); Vec3d v = L.crossProd(camera.Up()); v.Normalize(); Vec3d u = v.crossProd(L); Vec3d LL = camera.Eye() + d*L - a*v - u; Vec3d p = LL + 2*a*v*(((double)x)/resX) + 2*u*(((double)y)/resY); Vec3d dir = p - camera.Eye(); dir.Normalize(); r->setPos(camera.Eye()); r->setDir(dir); } p

19 void RenderDistributed_v1 (Color *fb, int numSamples) { int i, j, k; Ray r; Color color; fb = new Color[resY*resX]; for (i = 0; I < resY; i++) { for (j = 0; j < resX; j++) { color.Set(0,0,0); for (k = 0; k < numSamples; k++) { calcRandomRay (&r, j, i); color += traceRay (r); } color /= (double) numSamples; fb[i*resX + j] = color; } } } (…) RenderDistributed_v1 (fb, 12); (…)

20 void calcRandomRay(Ray *r, int x, int y) { double a = ((double)resX) / resY; double d = 1.0 / tan((camera.FOV()/2)*(PI/180)); Vec3d L = camera.LookAt() - camera.Eye(); L.Normalize(); Vec3d v = L.crossProd(camera.Up()); v.Normalize(); Vec3d u = v.crossProd(L); Vec3d LL = camera.Eye() + d*L - a*v - u; Vec3d p = LL + 2*a*v*((((double)x)+RAND3())/resX) + 2*u*((((double)y)+RAND3())/resY); Vec3d dir = p - camera.Eye(); dir.Normalize(); r->setPos(camera.Eye()); r->setDir(dir); } #define RAND3() (float)((rand()/(float)RAND_MAX)-0.5) // NORMALIZED RAND FUNCTION [-0.5,0.5]

21 void RenderDistributed_v2 (Color *fb, int numSamples) { int i, j, k; Ray r; Color color; fb = new Color[resY*resX]; for (i = 0; I < resY; i++) { for (j = 0; j < resX; j++) { color.Set(0,0,0); for (k = 0; k < numSamples; k++) { calcJitteredRay (&r, j, i, (k% numSamples)); color += traceRay (r); } color /= (double) numSamples; fb[i*resX + j] = color; } 0 1 2 3 (…) RenderDistributed_v2 (fb, 4); (…)

22 #define RAND3() (float)((rand()/(float)RAND_MAX)-0.5) // NORMALIZED RAND FUNCTION [-0.5,0.5] void calcRandomRay (Ray *r, int x, int y, int quadrant) { double a = ((double)resX) / resY; double d = 1.0 / tan((camera.FOV()/2)*(PI/180)); Vec3d L = camera.LookAt() - camera.Eye(); L.Normalize(); Vec3d v = L.crossProd(camera.Up()); v.Normalize(); Vec3d u = v.crossProd(L); double xOffset = (quadrant == 0 || quadrant == 3) ? 0.5 : 0; double yOffset = (quadrant == 0 || quadrant == 2) ? 0.5 : 0; Vec3d LL = camera.Eye() + d*L - a*v - u; Vec3d p = LL + 2*a*v*((((double)x)+xOffset-RAND1())/resX) + 2*u*((((double)y)+yOffset-RAND1())/resY); Vec3d dir = p - camera.Eye(); dir.Normalize(); r->setPos(camera.Eye()); r->setDir(dir); }

23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Jitter magnitude Range of reflection angles 16 ray samples Look Up Table

24 Importance Sampling Divide sample space into blocks of equal area under weighting function Assign each pixel sample a different (random) block Perturb randomly within block (ideally, points in block have nearly equal weight…) Possible block arrangement for reflection ray direction

25 Importance Sampling cos(x)]^n for n = 2.cos(x)]^n for n = 4.cos(x)]^n for n = 8. phong-style cos(x)]^n

26

27

28 4 rays64 rays Reflection

29 4 rays16 rays Transparency

30 Diffuse reflection rays are distributed reflections around reflection direction to simulate non- smooth surfaces Depth of field origin of rays is distributed with respect to lens to get out-of-focus effect Soft shadows shadow rays are distributed around light direction to simulate area light sources Motion blur rays are distributed in time to simulate object movement Distributed Ray Tracing Rays can also be stochastically distributed in object space to simulate

31 Depth of Field The area in front of your camera where everything looks sharp and in focus. For example, if you're focused on somebody standing 10 feet in front of the camera, your depth of field might be from 8 feet to 14 feet. That means: –objects falling within that area will be acceptably-sharp and in focus; –objects falling outside the area will be soft and out of focus.

32 CG Camera Models Pinhole – ideal camera All rays go through single point Everything in focus -- unrealistic

33 More Realistic Model Lenses with spherical surfaces Depth of field control

34

35 DRT: Depth of Field

36 Depth of Field

37

38

39 Cook (1986) The first fully CG character, a medieval knight, springs to life from a stained glass window in "Young Sherlock Holmes." The 30-second sequence takes six months to accomplish.

40 Diffuse reflection rays are distributed reflections around reflection direction to simulate non- smooth surfaces Depth-of-view origin of rays is distributed with respect to lens to get out-of-focus effect Soft shadows shadow rays are distributed around light direction to simulate area light sources Motion blur rays are distributed in time to simulate object movement Distributed Ray Tracing Rays can also be stochastically distributed in object space to simulate

41 Soft Shadows Consider the light source to be an area, not a point Trace rays to random areas on the surface of the light source distribute rays according to areas of varying intensity of light source (if any) Use the fraction of the light intensity equal to the fraction of rays which indicate an unobscured light source

42

43

44

45 Cook (1986)

46 Diffuse reflection rays are distributed reflections around reflection direction to simulate non- smooth surfaces Depth-of-view origin of rays is distributed with respect to lens to get out-of-focus effect Soft shadows shadow rays are distributed around light direction to simulate area light sources Motion blur rays are distributed in time to simulate object movement Distributed Ray Tracing Rays can also be stochastically distributed in object space to simulate

47 Motion Blur Two objects moving so that one always obscures the other –Can’t render and blur objects separately A spinning top with texture blurred but highlights sharp –Can’t post-process blur a rendered object The blades of a fan creating a blurred shadow –Must consider the movement of other objects time Post-process blurring can get some effects, but consider:

48 Temporal Jittering Sampling

49 Motion Blur

50

51 Cook (1986)

52

53 Distributed Ray Tracing (Summary)


Download ppt "Global Illumination (3) Cone Tracing / Distributed Ray Tracing."

Similar presentations


Ads by Google