Ray Casting: Generating Images by Shooting Rays into a Scene, Slides of Computer Graphics

Information on ray casting, a technique used to generate images by shooting rays into a 3d scene and determining the color of each pixel based on the intersection of the ray with the nearest object. Topics covered include generating rays, computing ray-object intersections, and determining color. The document also discusses camera intrinsics and extrinsics, and building a frustum to generate the camera matrix.

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarasvan
sarasvan 🇮🇳

4.4

(20)

118 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Ray Casting 2
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Ray Casting: Generating Images by Shooting Rays into a Scene and more Slides Computer Graphics in PDF only on Docsity!

  • Ray Casting

Programming 3 Info

  • Test data for part 1 (Lines) is available
    • As C/C++ array, or just as a text file
      • In both cases, each line has 7 parameters
        • (x 1 , y 1 , x 2 , y 2 , R, G, B)
      • This data set anticipates a 512x512 window
    • To read the array (line.data), use something like the following code:

Programming 3 Info

  • For part 3 (line clipping), should display

a window bigger than the clip window

  • i.e. Viewport (^) Clip against this

Last Time

  • Derived the math for ray casting
    • Intersecting rays and objects
    • Generating rays
      • aka generating a camera matrix
    • Coloring pixels
      • Phong shading for each ray

Ray-Tracing Algorithm

  • for each pixel / subpixel

shoot a ray into the scene

find nearest object the ray intersects

if surface is (nonreflecting OR light)

color the pixel

else

calculate new ray direction

recurse

Ray-Tracing Algorithm

  • for each pixel / subpixel

shoot a ray into the scene

find nearest object the ray intersects

if surface is (nonreflecting OR light)

color the pixel

else

calculate new ray direction

recurse

Ray Casting

Computing Ray-Object Intersections

  • If a ray intersects an object, want to

know the value of t where the

intersection occurs:

  • t < 0: Intersection is behing the ray, ignore it
  • t = 0: Undefined
  • t > 0: Good intersection
  • If there are multiple intersections, we

want the one with the smallest t

  • This will be the closest surface r (t) = p + t d

Generating Rays

  • Now, given a ray, we know how to test if it

intersects an object

  • But we don’t yet know how to generate the rays
  • We talked a bit about lenses last time, but

an ideal pinhole camera is still the simplest

model

  • So let’s assume that

Generating Rays in 2D

Eye Once we know this ray, the rest are easy This is referred to as a “Pencil of Rays”

Generating Rays in 3D

Eye +x +y +z

D v =

D u =

V 0 D v D u V 0 =

A Basic 3D Camera Matrix

  • Assumes:
    • Camera on the z-axis
    • Looking down - z
    • Ideal pinhole model
    • Fixed focal length (focal length = 1)

Determining Color

  • Since we’re not yet talking about tracing

rays

  • Really just talking about OpenGL-style lighting and shading - Since surfaces are implicitly defined, can solve Phong lighting equation at every intersection

Camera Intrinsics and Extrinsics

  • We normally divide camera properties

into two classes: intrinsic and

extrinsic

  • Intrinsic properties are those belonging to the camera itself - Intrinsic properties are inside the camera
  • Extrinsic properties define how the camera is situated in the world

Camera Intrinsics

  • These describe the behavior of the camera
    • Focal length
    • Aspect ratio
    • Resolution
    • Aperture
    • Shutter speed
    • etc.