0% found this document useful (0 votes)
59 views

Raytracing-20 09 2017

1. Ray tracing is a technique for generating realistic images by tracing the path of light through pixels in an image. 2. The basic components of a ray tracer are ray generation to determine the path of each pixel's viewing ray, ray intersection to find the closest object each ray hits, and shading to determine each pixel's color based on the intersection. 3. Ray tracing follows the physical behavior of light, including reflection, refraction, and shadows, to produce realistic images for applications like movies, architectural design, automotive design, and computer games.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Raytracing-20 09 2017

1. Ray tracing is a technique for generating realistic images by tracing the path of light through pixels in an image. 2. The basic components of a ray tracer are ray generation to determine the path of each pixel's viewing ray, ray intersection to find the closest object each ray hits, and shading to determine each pixel's color based on the intersection. 3. Ray tracing follows the physical behavior of light, including reflection, refraction, and shadows, to produce realistic images for applications like movies, architectural design, automotive design, and computer games.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

1

Introduction

Rendering is a process that takes as its input a set of objects and


produces as its output an array of pixels.

One way or another, rendering involves considering how each object


contributes to each pixel; it can be organized in two general ways.
1. Object-order rendering, each object is
considered in turn, and for each
object all the pixels that it inuences are found and updated.

2. Image order rendering, each pixel is considered in turn, and for each
pixel all the objects that inuence it are found and the pixel value is
computed.
Introduction

The idea behind ray tracing is that physically


correct images are composed by light and that
light will usually come from a light source and
bounce around as light rays (following a broken
line path) in a scene before hitting our eyes or a
camera.

Ray tracing is a method to produce realistic


images; it determines visible surfaces in an
image at the pixel level
Ray Tracing - Applications

oVisual effects in movies and commercials


Major software packages have built-in ray tracers:
e. g. Maya, 3ds Max (Autodesk), Houdini (Side Effects
Software)

oVisualization of architectural design


Consideration of realistic indoor and outdoor
illumination

oAutomotive design
oFlight and car simulators
oComputer games
Ray Tracer
A ray tracer works by computing one pixel at a time, and for each pixel
the basic task is to find the object that is seen at that pixels position in
the image. Each pixel looks in a different direction, and any object that
is seen by a pixel must intersect the viewing ray, a line that emanates
from the viewpoint in the direction that pixel is looking.
A basic ray tracer therefore has three parts:
1.ray generation, which computes the origin and direction of each pixels
viewing ray based on the camera geometry;
2. ray intersection, which finds the closest object intersecting the viewing
ray;
3.shading, which computes the pixel color based on the results
of ray intersection.
Ray Tracer

The structure of the basic ray tracing program


is:
for each pixel do
compute viewing ray
find first object hit by ray and its surface
normal n
set pixel color to value computed from hit
point, light, and n
Ray tracing Algorithm

Basic algorithm traces the mirror reection and refraction


of light rays..
The light sources issue lights. The lights hit the surfaces
and are reected or refracted. The propagation
directions of lights are changed. Lights continue the
propagation along the new directions, until they hit new
objects.
A small portion of the lights issued by the light sources
will enter the eyes.
In reality, the propagation direction of lights are opposite
to the direction of ray tracing.
Image Formation
Image Formation
Ray Tracing
Ray Tracing
Ray Tracing
Ray Tracing
Ray Tracing - Motivation

light is modeled as geometric rays


travels in straight lines (e. g., diffraction / bending is not
considered)
travels at infinite speed (ray tracing computes steady state of
light)
is emitted by light sources
is absorbed or scattered / reflected at surfaces

radiance
characterizes strength and direction of radiation / light
is measured by sensors
is computed in computer-generated images
is preserved along lines in space
does not change with distance
Ray Tracing vs. Rasterization

rasterization
given a set of viewing rays and a primitive, efficiently compute the
subset of rays hitting the primitive
loop over all primitives
no explicit representation of rays

ray tracing
given a viewing ray and a set of primitives, efficiently compute the
subset of primitives hit by the ray
loop over all viewing rays
explicit representation of rays
Ray Tracer
A ray is issued from the view point V through a pixel (x, y).
The ray hits the rst object along its propagation.
The reection and refraction take place at the intersection
point.
Continue to trace the reected ray and refracted ray.
Forward Ray Tracing

Rays are the paths of these photons


This method of rendering by following photon paths is called ray tracing
Forward ray tracing follows the photon in direction that light travels (from the
source).

BIG problem with this approach:


Only a tiny fraction of rays reach the image.
Many, rays are required to get a value for
each pixel.

Ideal Scenario:
We'd like to magically know which rays
will eventually contribute to the image,
and trace only those.
Forward Ray Tracing
Forward Ray Tracing
Forward Ray Tracing
Backward Ray Tracing
The solution is to start from the image and trace backwardsbackward
ray tracing

Start from the image and follow the ray until the ray finds (or fails to find) a
light source
Backward Ray Tracing
Backward Ray Tracing

Basic idea:
Each pixel gets light from just one directionthe line through
the image point and focal point
Any photon contributing to that pixels color has to come
from this direction. So head in that direction and see
what is sending light
If we hit a light
sourcedone
If we find nothing
done
If we hit a surfacesee where that surface is lit from
At the end weve done forward ray tracing, but ONLY for the
rays that contribute to the image
Recursive Ray Tracing

Four ray types:


Eye rays: originate at the eye
Shadow rays: from surface point toward light source
Reflection rays: from surface point in mirror direction
Transmission rays: from surface point in refracted direction
Ray tracing proceeds as follows:

1- Fire a single ray from each pixel position into the scene along the
projection path.
Determine which surfaces the ray intersects and order these by
distance from
the pixel.
3The nearest surface to the pixel is the visible surface for that pixel.
4For transparent surfaces send a ray through the surface in the
refraction direction.
5 Repeat the process for these secondary rays.
We terminate a ray-tracing path when any one of the following
conditions is satisfied:
The ray intersects no surfaces.
The ray intersects a light source that is not a reflecting surface.
A maximum allowable number of reflections have taken place.
The initial camera ray is then tested for intersection with the
3D scene, which contains a bunch of triangles and/or other
primitives, If the ray doesnt hit anything, then we can color
the pixel to some specified background color,
Otherwise, we want to know the first thing that the ray
hits (it is possible that the ray will hit several surfaces, but
we only care about the closest one to the camera)
For the intersection, we need to know the position,
normal, color, texture coordinate, material, and any
other relevant information we can get about that exact
location
If we hit somewhere in the center of a triangle, for example,
then this information would get computed by interpolating
the vertex data
Ray tracing: Primary rays

For each ray we need to test which objects are


intersecting the ray:
If the object has an intersection with the ray we
calculate the distance between viewpoint and
intersection
If the ray has more than one intersection, the
smallest distance identifies
the visible surface.
Primary rays are rays from the view point to the
nearest intersection point
27
Ray tracing: Secondary rays

Secondary rays are rays originating at the intersection points


Secondary rays are caused by
rays reflected off the intersection point in the direction of reflection
rays transmitted through transparent materials in the direction of
refraction
shadow rays
The primary rays are the initial rays shot from the camera. Any
reflected rays (and others, like refracted rays, etc.), are called
secondary rays.
Types of secondary rays

A- Lighting
Once we have the key intersection information
(position, normal, color, texture coordinates,
etc.) we can apply any lighting model we want,
This can include procedural shades, lighting
computations, texture lookups, texture
combining, bump mapping, The result of the
lighting equation is a color, which is used to
color the pixel

February 5, 2015 [email protected] 29


Types of secondary rays

B- Shadow Rays
Shadows are an important lighting effect that can easily be computed
with ray tracing, If we wish to compute the illumination with shadows
for a point, we shoot an additional ray from the point to every
light source
A light is only allowed to contribute to the final color if the ray doesnt hit
anything in between the point and the light source, Shadow rays
behave slightly differently from primary (and secondary) rays
Normal rays (primary & secondary) need to know the first surface hit
and then compute the color reflected off of the surface, Shadow rays,
however, simply need to know if something is hit or not
How do we add shadows?

L = ka + s(kd (n l) + ks(v r)q )Is + kreflectedLreflected + krefractedLrefracted


Shadows

One shadow ray per intersection


per point light source
Soft shadows

Multiple shadow rays to sample


area light source
Types of secondary rays
C- Reflection Rays

Another powerful feature often associated with ray tracing is accurate


reflections, If we wanted to render a surface as a perfect mirror, instead
of computing the lighting through the normal equation, we just create a
new reflection ray and trace it into the scene.

February 5, 2015 [email protected] 34


Reflection
If the reflection ray hits a normal material, we just compute the illumination and
use that for the final color.
If the reflection ray hits another mirror, we just recursively generate a new
reflection ray and trace that.
In this way, we can render complex mirrored surfaces that include reflections,
reflections of reflections, reflections of reflections of reflections,To prevent the
system from getting caught in an infinite loop, it is common to put an upper limit
on the depth of the recursion. 10 or lower works for most scenes, except
possibly for ones with lots of mirrored surfaces

February 5, 2015 [email protected] 35


Reflection

Surfaces in the real world dont act as perfect mirrors, Real mirrors will absorb a
small amount of light and only reflect maybe 95%-98% of the light
Some reflecting surfaces are tinted and will reflect different wavelengths with
different strengths, This can be handled by multiplying the reflected color by the
mirror color at each bounce, We can also simulate partially reflective materials
like polished plastic, which have a diffuse component as well as a shiny specular
component
For a material like this, we would apply the normal lighting equation, including
shooting shadow rays, to compute the diffuse component, then add a
contribution from a reflection ray to get the final color (the diffuse and specular
components should be weighted so as not to violate conservation of energy)

February 5, 2015 [email protected] 60


Types of secondary rays
D-Transmission Rays

Ray tracing can also be used to accurately render


the light bending in transparent surfaces due to
refraction, this is called transmission instead of
refraction.
Transmission Rays
When a ray hits a transparent surface (like glass, or water), we generate a new
refracted ray and trace that, in a similar way as we did for reflection
We will assume that the transmitted ray will obey Snells law
(n1 sin1 = n2 sin2), where n1 and n2 are the index of refraction for the two
materials, Computing Transmission (Refraction) Direction
Total Internal Reflection
When light traveling in a material with a high index of
refraction hits a material with a low index of refraction at a
steep angle, we get a total internal reflection, When this
happens, no refraction ray is generated, This effect can be
visible when one is scuba diving and looks up at the water
surface. One can only see rays refracting to the outside world
in a circular area on the water surface above.

A consequence of Snells law is a phenomenon known as


total internal reflection. If the ratio of refractive indices n2/n1
is less than unity, there will be some critical angle of
incidence above which the angle of refraction is always
greater than 90 degrees.
Mathematically, we can find the critical angle c by setting 2 equal to 90
degrees in Snells law and rearranging. When 2=90, sin2 = 1, and we
have
c = sin-1(n2/n1)

Note that there is no critical angle when n2 > n1 since sin cannot be greater
than 1. This means, for example, that total internal reflection can occur
when light travelling through water or glass strikes air, but not the other way
around.
Recursive Ray Tracing

The classic ray tracing algorithm includes features like


shadows, reflection, refraction, and custom
materials,
A single primary ray may end up spawning many
secondary and shadow rays, depending on the number
of lights and the arrangement and type of materials
,These rays can be thought of as forming a tree like
structure
Recursive Ray Tracing: Ray Tree
Distribution Ray Tracing

In 1984, an important modification to the basic ray tracing algorithm was


proposed, known as distributed ray tracing, The concept basically involved
shooting several distributed rays to achieve what had previously been
done with a single ray.
The goal is not to simply make the rendering slower, but to achieve a
variety of soft lighting effects such as antialiasing, camera focus, soft-
edge shadows, blurry reflections, color separation, motion blur, and more.
As the term distributed tends to refer to parallel processing in modern
days, the distributed ray tracing technique is now called distribution ray
tracing, and the term distributed is reserved for parallel ray tracing, which
is also an important subject

February 5, 2015 [email protected] 43


Ray casting
Ray casting

Ray casting finds the visible surfaces of objects


Ray tracing determines what each visible surface
looks like
This extra curiosity is quite heavy on your
processor
But it allows you to create effects that are very
difficult or even impossible to do using other
methods.
Reflection
Transparency
Shadows

February 5, 2015 [email protected] 90


Ray Tracer
Color intensity. A ray R intersects a surface at
point p, there are 3 parts of lights at p
contributing to R
1. The local light intensity caused by the light
sources at p directly.
2. The intensity of the reection ray Is Ks, Is is
obtained by recursively
tracing the reection ray.
3. The intensity of the refraction ray It Kt, It is
obtained by recursively tracing the
refraction ray.
February 5, 2015 [email protected] 46
Path Tracing -Illustration

February 5, 2015 [email protected] 47

You might also like