Date post: | 28-Mar-2015 |
Category: |
Documents |
Upload: | evelyn-preston |
View: | 214 times |
Download: | 0 times |
1GR2-00
GR2Advanced Computer
GraphicsAGR
GR2Advanced Computer
GraphicsAGR
Lecture 14Improving the Efficiency of
Ray TracingLight Source Effects
2GR2-00
Advantages and Disadvantages of Ray
Tracing
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
3GR2-00
Ray Tracing - A ReminderRay Tracing - A Reminder
pixel positionson view plane
camera
The intensity calculationis now:I = I local + k r * I reflected
+ k t * I transmitted
I reflected and I transmitted
are calculated recursively
4GR2-00
Adaptive Tree Depth Control
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
5GR2-00
Bounding VolumesBounding 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)
6GR2-00
Spatial SubdivisionSpatial 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
7GR2-00
How do we Subdivide Space
How do we Subdivide Space
One idea is octree partitioning We illustrate in 2D - known as
quadtreeFirst divide space intofour regions
Count number of objectsin each region
If a region contains an object, subdivide again
Continue to a specified levelof subdivision
8GR2-00
OctreeOctree
A tree structure emerges, with the nodes at the leaves ofthe tree containing (hopefully) a small number of objects,or empty.
This is quadtree - in 3Dwe subdivide cube into8 each time, getting anoctree
9GR2-00
Ray Tracing through Octree
Ray Tracing through Octree
We trace ray from subregion to subregion, only doingintersection tests for the small number of objects in thesubregion.
Find region correspondingto start point. Test ray forintersections with any objects.
If none, find next region - bycalculating intersection withregion boundaries. Advancea short way into next region -say to (x,y,z)
Find region which includes(x,y,z) and continue.
10GR2-00
Finding Region Containing (x,y,z)
Finding Region Containing (x,y,z)
We use octree itself to locate region. Starting at top, asimple test determines in which of eight (4 for quadtree) regions the point (x,y,z) lies. Proceed down tree untilleaf node reached.
11GR2-00
Binary Space PartitioningBinary 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
12GR2-00
Octrees versus BSP treesOctrees versus BSP trees
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 BSP trees:
– depth of tree smaller because tree balanced– memory costs lower– void areas smaller
13GR2-00
Ray Tracing SoftwareRay Tracing Software
Persistence Of Vision Ray Tracer (POV-RAY) is public domain ray tracing software
Download from:– http://www.povray.org
14GR2-00
More Teapots! The POVRAY version
More Teapots! The POVRAY version
15GR2-00
POVLAB modellerPOVLAB modeller
16GR2-00
Lecture 14Part 2
Light Source Effects
17GR2-00
Light Source Sequence of Images
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
18GR2-00
Ambient Light OnlyAmbient Light Only
19GR2-00
Camera Light SourceCamera Light Source
Light source atcamera only.
Note no shadows.
20GR2-00
Distant Light SourceDistant Light Source
Light rays parallelto each other
Note shadows
21GR2-00
Point Light SourcePoint Light Source
Point light sourceclose to object,in same directionas distant sourcein previous picture.
Note shadows aredifferent.
22GR2-00
SpotlightSpotlight
Spotlight in sameposition as previouspoint light.
Cone angle is 30 deg.
Note cone ofinfluence of thelight, and thehard shadow.
23GR2-00
Spotlight - Soft ShadowsSpotlight - Soft Shadows
Softer shadowobtained by havinga gradual drop-offof intensity at edge ofcone (here over last5 deg)
24GR2-00
Effect of Distance - No Attenuation
Effect of Distance - No Attenuation
Here there is noattenuation of lightover distance
25GR2-00
Effect of Distance - Attenuation
Effect of Distance - Attenuation
Intensity is attenuatedby 1/distance
26GR2-00
Effect of Distance - Attenuation
Effect of Distance - Attenuation
Here the attenuation factoris 1/(distance)2
27GR2-00
FogFog
Intensity of fogincreases linearlywith depth.
How is thisachieved?