Raytracing-20 09 2017
Raytracing-20 09 2017
Introduction
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
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
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
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
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
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
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?
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)
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