Docsity

Ray Tracing: Transformations, Shadows, Reflection, Refraction, and Recursive Ray Tracing, Slides of Computer Science

Partial preview of the text

Download Ray Tracing: Transformations, Shadows, Reflection, Refraction, and Recursive Ray Tracing and more Slides Computer Science in PDF only on Docsity!

MIT 6.837 - Ray Tracing

Ray Tracing

Review of last week?

Review of last week • Linear, affine and^ projective transforms • Homogeneous^ coordinates • Matrix notation • Transformation composition^ is not commutative • Orthonormal basis change

Fun with transformations: Relativity• Special relativity: Lorentz transformation– 4 vector (t, x, y, z)

th^ • 4 coordinate can be ct or t– Lorentz transformation depends on object speed v

t x y z

v

v

t x y z

http://casa.colorado.edu/~ajsh/sr/sr.shtml

Digression Docsity.com

Relativity• Transform ray by Lorentz transformation

0.65c^

0.70c

0.90c^

0.99c

See also http://www.cs.mu.oz.au/~andrbh/raytrace/raytrace.html

Digression Docsity.com

Overview of today •^ Shadows •^ Reflection •^ Refraction •^ Recursive Ray Tracing

11

Ray Casting (a.k.a. Ray Shooting) For^ every

pixel

(x,y) Construct

a^ ray

from^

the^ eye

color[x,y]=castRay(ray) • Complexity?^ – O(n * m)^ – n: number of objects, m: number of pixels

Docsity.com

Encapsulating shading Color castRay(ray)^ Hit hit();^ For every object ob

ob->intersect(ray, hit, tmin); Color col=ambient*hit->

getMaterial()

->getDiffuse();

For every light L^ col=col+hit->

getMaterial()->shade

(ray, hit, L->getDir(), L->getColor()); Return col;

How can we add shadows? Color castRay(ray)^ Hit hit();^ For every object ob

ob->intersect(ray, hit, tmin); Color col=ambient*hit->getMaterial()->getDiffuse(); For every light L col=col+hit->getMaterial()->shade^ (ray, hit, L->getDir(), L->getColor()); Return col;

Shadows – problem? Color castRay(ray)Hit hit();For every object ob

ob->intersect(ray, hit, tmin);Color col=ambient*hit->getMaterial()->getDiffuse();For every light L Ray^ ray2(hitPoint,

L->getDir());

Hit^ hit2(L->getDist(),,)

For^ every

object

ob ob->intersect(ray2,

hit2,^

If^ (hit->getT>

L->getDist()) col=col+hit->getMaterial()->shade(ray,

hit,^ L->getDir(),

L->getColor());

Return^

col;

Avoiding self shadowing Color castRay(ray)Hit hit();For every object ob

ob->intersect(ray, hit, tmin);Color col=ambient*hit->getMaterial()->getDiffuse();For every light LRay^ ray2(hitPoint,

L->getDir());

Hit^ hit2(L->getDist(),,)

For^ every

object

ob ob->intersect(ray2,

hit2,^

epsilon

If^ (hit->getT>

L->getDist()) col=col+hit->getMaterial()->shade(ray,

hit,^ L->getDir(),

L->getColor());

Return^

col;

Shadow optimization • We only want to know whether there is anintersection, not which one is closest• Special routine

Object3D::intersectShadowRay()

– Stops at first intersection

Shadow ray casting history • Due to Appel [1968] • First shadow method in graphics • Not really used until the 80s