Download presentation

Presentation is loading. Please wait.

Published byEvelyn Preston Modified over 2 years ago

1
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 14 Improving the Efficiency of Ray Tracing Light Source Effects

2
2GR2-00 Advantages and Disadvantages of Ray Tracing n Ray tracing is attractive because – shadows, reflections, refractions are easily incorporated n Ray tracing is expensive because – the cost of computing ray-object intersections is very high n This part of the lecture looks at efficiency issues in ray tracing

3
3GR2-00 Ray Tracing - A Reminder pixel positions on view plane camera The intensity calculation is now: I = I local + k r * I reflected + k t * I transmitted I reflected and I transmitted are calculated recursively

4
4GR2-00 Adaptive Tree Depth Control n Basic algorithm follows rays until they leave the scene (or hit diffuse surface) - in theory the tree depth can then be considerable n In practice, it is not usually necessary to trace rays to any great depth n As tree formed, a running product is kept of transmission and reflection coefficients – this product attenuates all intensities lower in tree – once product less than threshold, branch is stopped

5
5GR2-00 Bounding Volumes n Enclose groups of objects in a simple bounding volume – sphere or box n Test for intersection against bounding volume – if none, then ray does not intersect objects within – if intersection occurs, test against each object in turn n Idea can be extended to hierarchies of bounding volumes (usually boxes)

6
6GR2-00 Spatial Subdivision n Idea: divide space into subregions, noting objects in each subregion – termed spatial subdivision or spatial coherence n Calculation changes from: – for each object or bounding box, find ray intersection to – as ray proceeds through space, are there any objects in the current subregion? – if yes, calculate intersections; if not, move on – find next subregion entered by the ray

7
7GR2-00 How do we Subdivide Space n One idea is octree partitioning n We illustrate in 2D - known as quadtree First divide space into four regions Count number of objects in each region If a region contains an object, subdivide again Continue to a specified level of subdivision

8
8GR2-00 Octree A tree structure emerges, with the nodes at the leaves of the tree containing (hopefully) a small number of objects, or empty. This is quadtree - in 3D we subdivide cube into 8 each time, getting an octree

9
9GR2-00 Ray Tracing through Octree We trace ray from subregion to subregion, only doing intersection tests for the small number of objects in the subregion. Find region corresponding to start point. Test ray for intersections with any objects. If none, find next region - by calculating intersection with region boundaries. Advance a short way into next region - say to (x,y,z) Find region which includes (x,y,z) and continue.

10
10GR2-00 Finding Region Containing (x,y,z) We use octree itself to locate region. Starting at top, a simple test determines in which of eight (4 for quadtree) regions the point (x,y,z) lies. Proceed down tree until leaf node reached.

11
11GR2-00 Binary Space Partitioning n An alternative to octrees is just to split into two at each step – separating plane typically chosen to divide space into regions of equal complexity n Known as Binary Space Partitioning, or BSP, trees

12
12GR2-00 Octrees versus BSP trees n Octrees: – good for scenes where density of objects varies widely – possible to have small objects in large regions – stepping from region to region slow because trees tend to be unbalanced n BSP trees: – depth of tree smaller because tree balanced – memory costs lower – void areas smaller

13
13GR2-00 Ray Tracing Software n Persistence Of Vision Ray Tracer (POV- RAY) is public domain ray tracing software n Download from: –

14
14GR2-00 More Teapots! The POVRAY version

15
15GR2-00 POVLAB modeller

16
16GR2-00 Lecture 14 Part 2 Light Source Effects

17
17GR2-00 Light Source Sequence of Images n The following sequence of images were created by Alan Watt of University of Sheffield n They illustrate effects of different light sources in a scene

18
18GR2-00 Ambient Light Only

19
19GR2-00 Camera Light Source Light source at camera only. Note no shadows.

20
20GR2-00 Distant Light Source Light rays parallel to each other Note shadows

21
21GR2-00 Point Light Source Point light source close to object, in same direction as distant source in previous picture. Note shadows are different.

22
22GR2-00 Spotlight Spotlight in same position as previous point light. Cone angle is 30 deg. Note cone of influence of the light, and the hard shadow.

23
23GR2-00 Spotlight - Soft Shadows Softer shadow obtained by having a gradual drop-off of intensity at edge of cone (here over last 5 deg)

24
24GR2-00 Effect of Distance - No Attenuation Here there is no attenuation of light over distance

25
25GR2-00 Effect of Distance - Attenuation Intensity is attenuated by 1/distance

26
26GR2-00 Effect of Distance - Attenuation Here the attenuation factor is 1/(distance) 2

27
27GR2-00 Fog Intensity of fog increases linearly with depth. How is this achieved?

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google