Presentation is loading. Please wait.

Presentation is loading. Please wait.

GR2 Advanced Computer Graphics AGR

Similar presentations


Presentation on theme: "GR2 Advanced Computer Graphics AGR"— Presentation transcript:

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

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

3 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 Adaptive Tree Depth Control
Basic algorithm follows rays until they leave the scene (or hit diffuse surface) - in theory the tree depth can then be considerable In practice, it is not usually necessary to trace rays to any great depth 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 Bounding Volumes Enclose groups of objects in a simple bounding volume
sphere or box Test for intersection against bounding volume if none, then ray does not intersect objects within if intersection occurs, test against each object in turn Idea can be extended to hierarchies of bounding volumes (usually boxes)

6 Spatial Subdivision Idea: divide space into subregions, noting objects in each subregion termed ‘spatial subdivision’ or ‘spatial coherence’ 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 How do we Subdivide Space
One idea is octree partitioning 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 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 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 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 Binary Space Partitioning
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 Known as Binary Space Partitioning, or BSP, trees

12 Octrees versus BSP trees
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 BSP trees: depth of tree smaller because tree balanced memory costs lower void areas smaller

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

14 More Teapots! The POVRAY version

15 POVLAB modeller

16 Lecture 14 Part 2 Light Source Effects

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

18 Ambient Light Only

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

20 Distant Light Source Light rays parallel to each other Note shadows

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

22 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 Spotlight - Soft Shadows
Softer shadow obtained by having a gradual drop-off of intensity at edge of cone (here over last 5 deg)

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

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

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

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


Download ppt "GR2 Advanced Computer Graphics AGR"

Similar presentations


Ads by Google