lecture 8c

Upload: sparaiso

Post on 02-Jun-2018

255 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Lecture 8c

    1/29

    Ray Tracing and other

    Surface Rendering Methods

    CMSC 161: Interactive Computer

    Graphics

  • 8/11/2019 Lecture 8c

    2/29

    Global Illumination Algorithms

    Global illuminationindirectly reflected andtransmitted light

    In contrast, local illuminationis light that comes directly from

    light sources to the point being shaded

    Much of the light in real-world environments does not comefrom direct light sources

    So far we have modeled global illumination by an ambient

    illumination term (constant)

    Two different classes of algorithms have been used togenerate pictures that emphasize its contribution:

    Recursive ray tracing

    Radiosity methods

  • 8/11/2019 Lecture 8c

    3/29

    Light Transport in Brief

    Light comes fromsources, reflects off

    surfaces, and gets to

    the eye

    We are interested inlight that gets to a

    particular pixel

    What parts of the

    scene couldcontribute?

  • 8/11/2019 Lecture 8c

    4/29

    Light Transport and Ray Tracing

    Ray tracing idea: answer the question What light arriveshere? by analyzing where it might have come from and

    looking there

    First level: look along ray to camera

    Second level: think of how light could get to the surface Directly from sources

    Indirectly via reflection

    Indirectly via transmission

    Higher level: recursive

  • 8/11/2019 Lecture 8c

    5/29

    Ray Tracing

    Determines the visibility of surfaces by tracing imaginaryrays of light from the viewers eye to the objects in the

    scene

    Think of it as a variation of the depth-buffer algorithm

  • 8/11/2019 Lecture 8c

    6/29

    Ray Tracing

    Ray Tracing vs.Ray Casting Is based on geometric optics methods, which trace the

    paths of light rays

    In ray tracing, a ray of light is traced in a backwards direction

    (i.e. from the eye or camera through a pixel in the image plane)

    Ray tracing handles shadows, multiple specular

    reflections and texture mapping in a straightforward

    manner

  • 8/11/2019 Lecture 8c

    7/29

    Ray Tracing

    Center of projection and a window onan arbitrary view plane are selected

    For each pixel in the window, an eye

    rayis fired from the center of projection

    through the pixels center into thescreen

    The pixels color is set to that of the

    object at the closest intersection

    If the ray misses all objects, then thatpixel is shaded the background color

    http://en.wikipedia.org/wiki/File:Ray_trace_diagram.svghttp://en.wikipedia.org/wiki/File:Ray_trace_diagram.svg
  • 8/11/2019 Lecture 8c

    8/29

    Ray Tracing

    We then reflect the ray off the visible surface along aspecular path

    If the surface is transparent, we also send a ray through

    the surface in the refraction direction

    Reflection and refraction rays (in addition to shadow rays) arereferred to as secondary rays

    This procedure is repeated for each secondary ray

  • 8/11/2019 Lecture 8c

    9/29

    Ray-Tracing Tree

    As the rays from a pixel ricochet through space, eachsuccessively intersected surface is added to a binary

    ray-tracing tree

    Left branches represent reflection paths while right branches

    represent transmission paths

  • 8/11/2019 Lecture 8c

    10/29

    Ray-Tracing Tree

    Maximum depth of ray-tracing trees can be set as a useroption, or by availability of storage

    A path is terminated if it reaches the preset maximum or if the

    ray strikes a light source

    The intensity assigned to a pixel is then determined byaccumulating the intensity contributions, starting at the

    bottom of its ray-tracing tree

    Involves attenuation before adding intensities

  • 8/11/2019 Lecture 8c

    11/29

    Brief History

    Was first developed by Appel (used a sparse grid of raysto determine shading) and by Goldstein and Nagel (to

    simulate trajectories of ballistic projectiles and nuclear

    particles)

    Appel was the first to ray trace shadows Goldstein and Nagel pioneered the use of ray tracing to

    evaluate Boolean set operations

    Whitted and Kay extended ray tracing to handle specular

    reflection and refraction

  • 8/11/2019 Lecture 8c

    12/29

    Ray Tracing Pseudocode

  • 8/11/2019 Lecture 8c

    13/29

    Ray Tracing Effects

    Basic ray tracer: mirror reflections, sharp shadows

  • 8/11/2019 Lecture 8c

    14/29

    Ray Tracing Procedure

    If a ray hits an object, we want to know if that point onthe object is in a shadow. So, when the ray hits an

    object, a secondary ray (called a shadow ray) is shot

    towards the light sources

  • 8/11/2019 Lecture 8c

    15/29

    Ray Tracing Procedure

    How much light do I see if I look along this ray?

  • 8/11/2019 Lecture 8c

    16/29

    Distributed Ray Tracing

    Randomly distribute rays according to variousparameters in the illumination model:

    Pixel area

    Reflection and refraction directions

    Camera lens area Time

    The idea is based in the theory of oversampling:

    Instead of approximating an integral by a single scalar value,

    the function is point sampled and these samples are used todefine a more accurate scalar value

  • 8/11/2019 Lecture 8c

    17/29

    Soft and Hard Shadows

    Distribute a number of shadow rays over the area of thelight source

  • 8/11/2019 Lecture 8c

    18/29

    Glossy Reflections and Translucency

    Refraction Reflection

    Caustics

  • 8/11/2019 Lecture 8c

    19/29

    Motion Blur

    Is the streaked or blurred appearance that movingobjects have because a cameras shutter is open for a

    finite amount of time

    Achieved by distributing rays over time

  • 8/11/2019 Lecture 8c

    20/29

    Camera Lens Depth of Field

    Objects appear to be more or less in focus depending ontheir distance from the lens, an effect known as depth of

    field

    Objects near the focal plane are projected as sharp images

    Objects in front or in back of the focal plane are blurred

    Images (slides 14 to 17) from www-csl.csres.utexas.edu

    Efficiency Considerations for Visible-

  • 8/11/2019 Lecture 8c

    21/29

    Efficiency Considerations for Visible

    Surface Ray Tracing

    Ray tracing is so time-consuming because of theintersection calculations

    Since each ray must be checked against all objects, for a

    naive ray tracer (with no speedup techniques) the time is

    proportional to the product of the number of rays and thenumber of objects in the scene

    Some techniques:

    Optimizing intersection calculations

    Hierarchies Spatial partitioning

    O ti i i I t ti C l l ti

  • 8/11/2019 Lecture 8c

    22/29

    Optimizing Intersection Calculations

    Bounding volumes provide a particularly attractive way todecrease the amount of time spent on intersection

    calculations

    The object does not need to be tested if the ray fails to

    intersect with its bounding volume

    Hi hi

  • 8/11/2019 Lecture 8c

    23/29

    Hierarchies

    Although bounding volumes do not by themselvesdetermine the order of frequency of intersection tests,

    bounding volumes may be organized in nested

    hierarchieswith objects at the leaves and internal nodes

    that bound their children Child volume is guaranteed not to intersect with a ray if

    its parent does not

    Thus, if intersection tests begin at the root, many branches of

    the hierarchy (and hence many objects) may be triviallyrejected

    S ti l P titi i

  • 8/11/2019 Lecture 8c

    24/29

    Spatial Partitioning

    Subdivides space top-down Bounding box of the scene is calculated first, then

    divided into a regular grid of equal-sized extents

    Partitions can be examined in the order in which the ray

    passes through them; thus as soon as a partition isfound in which there is an intersection, no more partitions

    need to be inspected

    R di it Li hti M d l

  • 8/11/2019 Lecture 8c

    25/29

    Radiosity Lighting Model

    Acurrate model of diffuse reflections from a surface byconsidering energy transfers between surfaces, subject

    to conservation of energy laws

    Unlike conventional rendering algorithms, radiosity

    methods first determine all the light interactions in anenvironment in a view-independent way

    Based on thermal-engineering models

    Adding S rface Detail

  • 8/11/2019 Lecture 8c

    26/29

    Adding Surface Detail

    Modeling Surface Detail with Polygons Model structure and patterns with polygons facets

    For example, squares on a checkerboard, tile patterns in a

    linoleum floor, panels in a door

    Texture Mapping Map texture patterns onto the surfaces of objects

    The texture pattern may either be defined

    In a rectangular array

    Or as a procedure that modifies surface intensity values

    Compute texture coordinates at the intersection point

    Texture Mapping

  • 8/11/2019 Lecture 8c

    27/29

    Texture Mapping

    This process is akin to applying patterned paper on aplain white box

    Mip Mapping

  • 8/11/2019 Lecture 8c

    28/29

    Mip Mapping

    MIP mapsare precalculated, optimized collections ofimages that accompany a main texture

    To increase rendering speed

    Reduce aliasing artifacts and achieve illusion of depth

    Need more space in memory Switch to a suitable mipmap image when the texture is viewed

    from a distance or at a small size

    MIP means multum in parvo, meaning much in a small

    space

    Bump Mapping

  • 8/11/2019 Lecture 8c

    29/29

    Bump Mapping

    Although texture mapping can be used to add finesurface detail, it is not a good method for modeling the

    surface roughness that appears on some objects

    The illumination detail in a texture pattern usually does not

    correspond to the illumination direction in the scene

    Bump mapping applies a perturbation function to the

    surface to the surface normal and then uses the

    perturbed normal in the illumination-model calculations

    Silhouettes and shadows remain unaffected