Last Time - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Last Time

Description:

Construct using the eye location and the pixel's location on the image plane. x0=eye ... Construct using laws of reflection. x0=surface point ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 32
Provided by: Stephen787
Category:
Tags: construct | last | time

less

Transcript and Presenter's Notes

Title: Last Time


1
Last Time
  • An introduction to global illumination
  • We cant solve the general case, so we look to
    special cases
  • Light paths as a way of classifying rendering
    algorithms L(SD)E
  • Raytracing
  • Captures LDSE paths Start at the eye, any
    number of specular bounces before ending at a
    diffuse surface and going to the light
  • Can also do LSE and LE if light source is not a
    point

2
Today
  • Issues in implementing a ray-tracing algorithm
  • How to intersect rays with various objects
  • Texture mapping and other enhancements
  • Area light sources and soft shadows

3
Raytracing Implementation
  • Raytracing breaks down into two tasks
  • Constructing the rays to cast
  • Intersecting rays with geometry
  • The former problem is simple vector arithmetic
  • The intersection problem arises in many areas of
    computer graphics
  • Collision detection
  • Other rendering algorithms
  • Intersection is essentially root finding (as we
    will see)
  • Any root finding technique can be applied

4
Constructing Rays
  • Define rays by an initial point and a direction
    x(t)x0td
  • Eye rays Rays from the eye through a pixel
  • Construct using the eye location and the pixels
    location on the image plane. x0eye
  • Shadow rays Rays from a point on a surface to
    the light.
  • x0point on surface
  • Reflection rays Rays from a point on a surface
    in the reflection direction
  • Construct using laws of reflection. x0surface
    point
  • Transmitted rays Rays from a point on a
    transparent surface through the surface
  • Construct using laws of refraction. x0surface
    point

5
Ray-Object Intersections
  • Aim Find the parameter value, ti, at which the
    ray first meets object i
  • Transform the ray into the objects local
    coordinate system
  • Makes ray-object intersections generic
    ray-sphere, ray-plane,
  • Write the surface of the object implicitly
    f(x)0
  • Unit sphere at the origin is xx-10
  • Plane with normal n passing through origin is
    nx0
  • Put the ray equation in for x
  • Result is an equation of the form f(t)0 where we
    want t
  • Now its just root finding

6
Ray-Sphere Intersection
  • Quadratic in t
  • 2 solutions Ray passes through sphere - take
    minimum value that is gt 0
  • 1 solution Ray is tangent - use it if gt0
  • 0 solutions Ray does not hit sphere

7
Ray-Plane Intersections
  • To do polygons, intersect with plane then do
    point-in-polygon test

8
Point-in-Polygon Testing
  • Project point and polygon onto a 2D plane
  • Find biggest component of normal vector, and just
    use other two coordinates
  • For example, if n(0.2, 0.4, 0.9), just use x,y
    coordinates, which is like projecting down onto
    the x-y plane
  • Cast a ray from the point to infinity and count
    the number of edges it crosses
  • Odd number means point is inside
  • Edge crossing tests are very fast - think clipping

9
More complex tests
  • Ray-Polygon test reveals a common strategy
  • Intersect with something easy - a superset of the
    actual shape
  • Do a bounds check to make sure you have actually
    hit the shape
  • Also works for cylinders, disks, cones
  • CSG is well suited to raytracing
  • Find intersection along ray of all the CSG
    primitives
  • Break the ray into intervals according to which
    primitives it is in
  • Do set operations to find the first interval that
    is actually inside the CSG object

10
CSG Intersection Testing
Subtract
Subtract intervals
Intersection intervals
11
Ray-Patch Intersection
  • Equation in 3 parameters, two for surface and two
    for ray
  • Solve using Newtons method for root finding
  • Have derivatives from basis functions
  • Starting point from control polygon, or random
    guess, or try a whole set of different starting
    values

12
Details
  • Must find first intersection of ray from the eye
  • Find all candidate intersections, sort them and
    take soonest
  • Techniques for avoiding testing all objects
  • Bounding boxes that are cheap to test
  • Octrees for organizing objects in space
  • Take care to eliminate intersections behind the
    eye
  • Same rules apply for reflection and transmission
    rays
  • Shadow ray just has to find any intersection
    shadowing the light source
  • Speedup Keep a cache of shadowing objects - test
    those first

13
Transforming Normal Vectors
  • Normal vectors are not transformed the same way
    points are
  • Ray directions behave like normal vectors
  • Plane equation should still be true with
    transformed points!
  • Transform normal vectors with the inverse
    transpose of the transformation matrix
  • For rotations, matrix is its own inverse transpose

14
Numerical Issues
  • Shadow, reflection and transmission rays have to
    be sure they dont intersect the surface they are
    leaving
  • Cant just ignore the object the ray is leaving -
    some objects self-shadow
  • Solution Use a tolerance - offset the starting
    point off the surface a little in the normal
    direction
  • Finding all the intersections with a spline
    surface patch is difficult
  • CSG can have problems when doing set operations
  • Make sure pieces being subtracted protrude above
    surfaces

Bad
Good
15
Mapping Techniques
  • Raytracing provides a wealth of information about
    the visible surface point
  • Position, normal, texture coordinates,
    illuminants, color
  • Raytracing also has great flexibility
  • Every point is computed independently, so effects
    can easily be applied on a per-pixel basis
  • Reflection and transmission and shadow rays can
    be manipulated for various effects
  • Even the intersection point can be modified

16
Texture Mapping
  • Define texture parameters over the surface
  • Determine texture parameters at each hit point
  • Use them to look up a texture map, just as with
    OpenGL
  • But
  • Can also use them to look up other things

17
Bump Mapping
  • Vary the surface normal vector according to some
    map
  • Influences shading and reflection and refraction
  • Variation may be random - for effects like stucco
    - or structured - for effects like tiles

18
Bump Mapping Examples
19
Displacement Mapping
  • Bump mapping changes only the normal, not the
    intersection point
  • Silhouettes will not show bumps, even though
    shading does
  • Displacement mapping actually shifts the
    intersection point according to a map
  • Gives bump map effects and also correct
    silhouettes and self shadowing, if implemented
    fully

20
From RmanNotes http//www.cgrg.ohio-state.edu/sma
y/RManNotes/index.html
21
Procedural Texturing
  • Define a shading language that can be used to
    compute the color of the intersection point
  • A shading language program can be defined for
    each surface
  • Every time the surface is hit, the program is run
    to compute the color
  • Program has access to the incoming ray, the
    normal, the texture coordinates, the texture
    image, plus lots of other stuff
  • Implemented in, for example, RenderMan from Pixar
  • Available in a limited form in hardware

22
Soft Shadows
  • Light sources that extend over an area (area
    light sources) should cast soft-edged shadows
  • Some points see all the light - fully illuminated
  • Some points see none of the light source - the
    umbra
  • Some points see part of the light source - the
    penumbra
  • To ray-trace area light sources, cast multiple
    shadow rays
  • Each one to a different point on the light source
  • Weigh illumination by the number that get through

23
Soft Shadows
Umbra
Penumbra
Penumbra
24
Soft Shadows
All shadow rays go through
No shadow rays go through
Some shadow rays go through
25
Anti-Aliasing
  • Raytracing can alias badly
  • Each ray is a single point sample
  • Problem is made worse by recursive rays the
    point sample depends on other point samples
  • Common solutions
  • Super-sampling Cast multiple rays per pixel and
    average their contribution in some way
  • Jittered sampling Frequently used with
    super-sampling, randomly jitters each ray within
    the pixel
  • Adaptive sampling Cast extra rays through the
    pixel if some initial sample rays indicate that
    they are needed

26
Anti-Aliasing
Uniform
Jittered
Adaptive
27
Distribution Raytracing
  • Distribution raytracing casts more than one ray
    for each sample
  • Originally called distributed raytracing, but the
    names confusing
  • Multiple rays for each pixel, distributed in time
  • Gives you motion blur, a strong visual clue for
    motion
  • Cast multiple reflection rays at a reflective
    surface
  • Gives you rough, blurry reflections
  • Simulate multiple paths through the camera lens
    system
  • Gives you depth of field, an important visual
    clue for depth

28
Distribution Raytracing
Depth of Field
29
Raytracing Cant Do
  • Recall light paths
  • Which does a raytracer capture?
  • Which can it not capture?

30
Ray-traced Cornell box, due to Henrik
Jensen, http//www.gk.dtu.dk/hwj
31
Missing Paths
  • Raytracing cannot do
  • LSDE Light bouncing off a shiny surface like a
    mirror and illuminating a diffuse surface
  • LDE Light bouncing off one diffuse surface to
    illuminate others
  • Basic problem The raytracer doesnt know where
    to send rays out of the diffuse surface to
    capture the incoming light
  • Also a problem for rough specular reflection
  • Fuzzy reflections in rough shiny objects
  • Next lecture Rendering algorithms that get more
    paths
Write a Comment
User Comments (0)
About PowerShow.com