SlideShare a Scribd company logo
1 of 70
Download to read offline
RAY TRACING
•The basic Ray Tracing Algorithm
•Computing Viewing Rays
•Ray-Object Intersection
•A Ray Tracing Program
•Shadows
•Specular Reflection
•Refraction
•Instancing
•Constructive Solid Geometry
•Distribution Ray Tracing
RAY TRACING- INTRODUCTION
• RAY TRACING is a rendering technique for generating an image by tracing the
path of light as pixels in an image plane and simulating the effects of its
encounters with virtual objects.
• The technique is capable of producing a very high degree of visual realism, but at
a greater computational cost.
• Ray tracing is best suited
for applications where
taking a relatively long time
to render a frame can be
tolerated, such as in still
images and film
• Poorly suited for real-
time applications such
as video games where
speed is critical.
FORWARD RAY TRACING
Forward ray tracing follows the light particles
(photons) from the light source to the object. Although
forward ray tracing can most accurately determine the
coloring of each object, it is highly inefficient. This is
because many rays from the light source never come
through the viewplane and into the eye. Tracking every
light ray from the light source down means that many
rays will go to waste because they never contribute to
the final image as seen from the eye. Forward ray
tracing is also known as light ray tracing and photon
tracing.
• Rays as paths of photons in world space
• Forward ray tracing: follow photon from light
sources to viewer
RAY TRACING- INTRODUCTION
BACKWARD RAY TRACING
To make ray tracing more efficient, the method of backward ray tracing is introduced. In
backward ray tracing, an eye ray is created at the eye; it passes through the viewplane and
on into the world. The first object the eye ray hits is the object that will be visible from
that point of the viewplane. After the ray tracer allows that light ray to bounce around, it
figures out the exact coloring and shading of that point in the viewplane and displays it
on the corresponding pixel on the computer monitor screen. Backward ray tracing is also
known as eye ray tracing.
The downfall of backward ray tracing is that it assumes only the light rays that come through
the viewplane and on into the eye contribute to the final image of the scene. In certain
cases, this assumption is flawed. For example, if a lens is held at a distance on top of a
table, and is illuminated by a light source directly above, there will exist a focal point
beneath the lens with a large concentration of light. If backward ray tracing tries to re-
create this image, it will miscalculate because shooting light rays backward only confirms
that rays traveled through the lens; backward rays have no way of recognizing that
forward rays are bent when they go through the lens. Therefore, if only backward ray
tracing is performed, there will only be an even patch of light beneath the lens, just as if
the lens were a normal piece of glass and light is transmitted straight through it.
RAY TRACING- INTRODUCTION
BACKWARD RAY TRACING
Ray-casting: one ray from center of projection through each pixel in image plane
Illumination:
• Phong (Phong shading is an interpolation technique for surface shading in 3D
computer graphics)
• Shadow rays
• Specular reflection
• Specular transmission
RAY TRACING- INTRODUCTION
SHADOW RAYS
• Determine if light “really” hits surface point
• Cast shadow ray from surface point to light
• If shadow ray hits opaque object. No contribution
• Improved diffuse reflection
RAY TRACING- INTRODUCTION
REFLECTION RAYS
• Calculate specular component of illumination
• Compute reflection ray (recall: backward!)
• Call ray tracer recursively to determine color
• Add contributions
RAY TRACING- INTRODUCTION
BASIC RAY TRACING ALGORITHM
For( every pixel in the view port)
{
for(every object in the model world)
{
if(ray-object intersection)
{
select the front most intersection;
recursively trace the reflection and refraction rays;
calculate color;
}
}
}
RAY TRACING- INTRODUCTION
camera position: let’s call it O=(Ox,Oy,Oz)
Viewport: (Vx,Vy,Vz)
So what color is the light reaching (Ox,Oy,Oz) after passing
through (Vx,Vy,Vz)?
EXAMPLE: RENDERING A SPHERE
we’ll trace the rays “in reverse”; we’ll start
with a ray originating from the camera,
going through a point in the viewport, and
following it until it hits some object in the
scene. This object is what is “seen” from
the camera through that point of the
viewport.
• We need a “frame” through which the scene was viewed. We’ll assume this
frame has dimensions Vw and Vh, it’s frontal to the camera orientation (that is,
it’s perpendicular to Z+→) at a distance d,
EXAMPLE: RENDERING A SPHERE
THE RAY EQUATION
we can express any point P in the ray as
P=O+t(V−O)
the ray passes through O, and we know its direction (from O to V). where t
is an arbitrary real number.
Let’s call (V−O), the direction of the ray, D D→; then the equation
becomes simply
P=O+tD
EXAMPLE: RENDERING A SPHERE
THE SPHERE EQUATION
If C is the center and r is the radius of the sphere, the points P on the
surface of the sphere satisfy the following equation:
P−C,P−C =r2
EXAMPLE: RENDERING A SPHERE
RAY MEETS SPHERE
• We now have two equations, one describing the points
on the sphere, and one describing the points on the ray:
P−C,P−C =r2
P=O+tD
• The point P where the ray hits the sphere is both a point
in the ray and a point in the surface of the sphere, so it
must satisfy both equations at the same time
• substituting P in the first with the expression for P in the
second one. This gives us
O+tD −C, O+tD −C =r2
further solving for values of t satisfy this equation
gives:
EXAMPLE: RENDERING A SPHERE
varying t across all the real numbers will yield every point P in this ray.
• Now we need to do is to compute the
intersections of the ray and each sphere,
keep the closest one to the camera, and
paint the pixel in the canvas with the
appropriate color.
EXAMPLE: RENDERING A SPHERE
ray equation:
P=O+t(V−O)
we can divide the parameter space in three parts:
t<0 Behind the camera
0≤t≤1 Between the camera and the projection plane
t>1 The scene
Fig. The parameter space
EXAMPLE: RENDERING A SPHERE
O = <0, 0, 0>
for x in [-Cw/2, Cw/2] {
for y in [-Ch/2, Ch/2] {
D = CanvasToViewport(x, y)
color = TraceRay(O, D, 1, inf)
canvas.PutPixel(x, y, color) } }
CanvasToViewport(x, y) {
return (x*Vw/Cw, y*Vh/Ch, d) }
PSEUDOCODE:
The main method now looks like this:
The CanvasToViewport function is :
EXAMPLE: RENDERING A SPHERE
The TraceRay method computes the intersection of the ray with every
sphere, and returns the color of the sphere at the nearest intersection
which is inside the requested range of t:
TraceRay(O, D, t_min, t_max) {
closest_t = inf
closest_sphere = NULL
for sphere in scene.Spheres {
t1, t2 = IntersectRaySphere(O, D, sphere)
if t1 in [t_min, t_max] and t1 < closest_t
closest_t = t1
closest_sphere = sphere
if t2 in [t_min, t_max] and t2 < closest_t
closest_t = t2 closest_sphere = sphere }
if closest_sphere == NULL
return BACKGROUND_COLOR
return closest_sphere.color }
finally, IntersectRaySphere just solves the quadratic equation:
EXAMPLE: RENDERING A SPHERE
Result of the above algorithm:
The reason they don’t quite look like spheres is that we’re missing a key
component of how human beings determine the shape of an object - the way it
interacts with light.
EXAMPLE: RENDERING A SPHERE
LIGHT- adding “realism” to our rendering
We’ll consider a simple model with
assumptions:
1. All light is white. This lets us
characterize any light using a
single real number, i, called
the intensity of the light. Colored
light contains three intensity
values, one per color channel.
2. we’ll ignore the atmosphere. This
means lights don’t become any
less bright no matter how far away
they are.
LIGHT SOURCES:
1. Point lights: A point light emits light from a fixed point in space, called
its position. Light is emitted equally in every direction.
2. Directional lights: a directional light has an intensity, but unlike them, it
doesn’t have a position; instead, it has a direction.
3. Ambient light: ambient light is characterized only by its intensity. It’s assumed
it unconditionally contributes some light to every point in the scene
EXAMPLE: RENDERING A SPHERE
Point light Directional light
ILLUMINATION OF A SINGLE POINT
To compute the illumination of a point:
• compute the amount of light contributed by each light source and add them
together to get a single number representing the total amount of light it receives.
• We can then multiply the color of the surface at that point by this number, to get
the appropriately lit color.
EXAMPLE: RENDERING A SPHERE
When a ray of light hits a matte object, because its surface is quite irregular at the
microscopic level, it’s reflected back into the scene equally in every direction; hence
“diffuse” reflection.
DIFFUSE REFLECTION
When a ray of light hits a matte object, because its surface is quite irregular at
the microscopic level, it’s reflected back into the scene equally in every
direction; hence “diffuse” reflection.
The amount of light reflected depends on the angle between the ray of light and
the surface.
EXAMPLE: RENDERING A SPHERE
MODELING DIFFUSE REFLECTION
EXAMPLE: RENDERING A SPHERE
The ray of light, with a width of I, hits the surface at P, at an angle β. The
normal at P is N , and the energy carried by the ray spreads over A. We
need to compute I/A.
From the figure,
cos(α)=QR/PR
substituting QR with I/2 and PR with A/2 we get
cos(α)=I/A
finally
I/A= N ,L / |N ||L |
EXAMPLE: RENDERING A SPHERE
For a sphere N is given by:
N =(P−C) / (|P−C|)
RENDERING WITH DIFFUSE REFLECTION
In first pseudocode add a couple of lights to the scene:
EXAMPLE: RENDERING A SPHERE
light {
type = ambient
intensity = 0.2 }
light {
type = point
intensity = 0.6
position = (2, 1, 0) }
light {
type = directional
intensity = 0.2
direction = (1, 4, 4) }
Note : that the intensities conveniently add up to 1.0; no point can have a greater
light intensity than this.
PSEUDOCODE FOR LIGHTING EQUATION :
EXAMPLE: RENDERING A SPHERE
ComputeLighting(P, N) {
i = 0.0
for light in scene.Lights {
if light.type == ambient {
i += light.intensity }
else {
if light.type == point
L = light.position – P
else L = light.direction
n_dot_l = dot(N, L)
if n_dot_l > 0
i += light.intensity*n_dot_l/(length(N)*length(L))
} }
return i }
We can use ComputeLighting in TraceRay by replacing the line that returns the color of the
sphere by
return closest_sphere.color
EXAMPLE: RENDERING A SPHERE
Output of rendering with diffuse reflection:
EXAMPLE: RENDERING A SPHERE
SPECULAR REFLECTION
When a ray of light hits a perfectly regular surface, it’s reflected in a single
direction, which is the symmetric of the incident angle respect to the mirror
normal. If we call the direction of the reflected light R , and we keep the
convention that L points to the light source, this is the situation:
For α=0 , all of the light is reflected. For α=90 , no light is reflected. Thus we take
cos(α) .
EXAMPLE: RENDERING A SPHERE
MODELING SPECULAR REFLECTION
Shininess is a measure of how quickly the reflection function decreases
as α increases. Thus we take cos(α)s
Thus The bigger the value of s, the “narrower” the function becomes around 0,
and the shinier the object looks.
EXAMPLE: RENDERING A SPHERE
A ray L hits a surface at a point P, where the normal is N , and the specular
exponent is s. light reflected to the viewing direction V is cos(α)s
R =LN→ − LP→
Equation for the specular reflection:
R =2N N ,L −L
EXAMPLE: RENDERING A SPHERE
RENDERING WITH SPECULAR REFLECTIONS
Let’s add specular reflections to the scene we’ve been working with so far. First, some
changes to the scene itself: sphere {
center = (0, -1, 3)
radius = 1
color = (255, 0, 0) # Red
specular = 500 # Shiny }
sphere {
center = (2, 0, 4)
radius = 1
color = (0, 0, 255) # Blue
specular = 500 # Shiny }
sphere {
center = (-2, 0, 4)
radius = 1
color = (0, 255, 0) # Green
specular = 10 # Somewhat shiny }
sphere {
color = (255, 255, 0) # Yellow
center = (0, -5001, 0)
radius = 5000
specular = 1000 # Very shiny }
EXAMPLE: RENDERING A SPHERE
We need to change ComputeLighting to compute the specular term when necessary and add
it to the overall light. Note that it now needs V and s:
ComputeLighting(P, N, V, s) {
i = 0.0
for light in scene.Lights
{ if light.type == ambient {
i += light.intensity }
else {
if light.type == point
L = light.position – P
else L = light.direction # Diffuse
n_dot_l = dot(N, L)
if n_dot_l > 0
i += light.intensity*n_dot_l/(length(N)*length(L)) # Specular
if s != -1 {
R = 2*N*dot(N, L) - L
r_dot_v = dot(R, V)
if r_dot_v > 0
i += light.intensity*pow(r_dot_v/(length(R)*length(V)), s)
}
}
} return i }
TRACERAY WITH SPECULAR REFLECTION:
TraceRay(O, D, t_min, t_max) {
closest_t = inf
closest_sphere = NULL
for sphere in scene.Spheres {
t1, t2 = IntersectRaySphere(O, D, sphere)
if t1 in [t_min, t_max] and t1 < closest_t
closest_t = t1
closest_sphere = sphere
if t2 in [t_min, t_max] and t2 < closest_t
closest_t = t2
closest_sphere = sphere }
if closest_sphere == NULL
return BACKGROUND_COLOR
P = O + closest_t*D # Compute intersection
N = P - closest_sphere.center # Compute sphere normal at intersection
N = N / length(N)
return closest_sphere.color*ComputeLighting(P, N, -D, sphere.specular)
}
EXAMPLE: RENDERING A SPHERE
EXAMPLE: RENDERING A SPHERE
Output of rendering with specular reflection:
REFRACTION
The angle of the refracted ray can be determined by Snell’s law:
η1sin(φ1) = η2sin(φ 2)
•η1 is a constant for medium 1
• η2 is a constant for medium 2
• φ1 is the angle between the incident ray and the
surface normal
• φ2 is the angle between the refracted ray and
the surface normal
• In vector notation Snell’s law can be
written:
k1(v×n) = k2(v'×n)
• The direction of the refracted ray is
This equation only has a solution if
REFRACTION
This illustrates the physical phenomenon of the limiting
angle:
– if light passes from one medium to another medium
whose index of refraction
is low, the angle of the refracted ray is greater than the
angle of the incident
ray
– if the angle of the incident ray is large, the angle of the
refracted ray is larger
than 90o
➨ the ray is reflected rather than refracted
REFRACTION
Mix reflected and refracted light according to the Fresnel factor
L = kfresnelLreflected + (1- k fresnel)Lrefracted
FR =((η2cosθ1−η1cosθ2) / (η2cosθ1+η1cosθ2))2
FR =((η1cosθ2−η2cosθ1) / (η1cosθ2+η2cosθ1))2
FR=1/2(FR +FR ).
void fresnel(const Vec3f &I, const Vec3f &N, const float &ior, float &kr)
{
float cosi = clamp(-1, 1, dotProduct(I, N));
float etai = 1, etat = ior;
if (cosi > 0) { std::swap(etai, etat); }
// Compute sini using Snell's law
float sint = etai / etat * sqrtf(std::max(0.f, 1 - cosi * cosi));
// Total internal reflection
if (sint >= 1) {
kr = 1;
}
else {
float cost = sqrtf(std::max(0.f, 1 - sint * sint));
cosi = fabsf(cosi);
float Rs = ((etat * cosi) - (etai * cost)) / ((etat * cosi) + (etai * cost));
float Rp = ((etai * cosi) - (etat * cost)) / ((etai * cosi) + (etat * cost));
kr = (Rs * Rs + Rp * Rp) / 2;
}
// As a consequence of the conservation of energy, transmittance is given by:
// kt = 1 - kr;
}
REFRACTION
REFRACTION
EXAMPLE
REFRACTION
EXAMPLE
• One shadow ray per intersection per point light source
SHADOWS
Soft shadows :Multiple shadow rays to sample area light source
SHADOWS
SHADOWS
Following steps are taken to trace the shadows:
•For each pixel hit on the screen (2D), we cast a ray from it’s actual 3D position in
world space towards the light source
•If the pixel is occluded, we store our occlusion value
SHADOWS
•If the pixel is not occluded, we store a value of
1.0 in the buffer
SHADING
The actual shading step of each pixel that we have traced will be done post ray tracing:
•Determine if pixel is occluded (ray traced shadow buffer entry smaller than 1.0). If it is
occluded, continue with 2.
•Determine the sampling size (for our ray traced shadow buffer)
SHADOWS
SHADOWS
SHADOWS
INSTANCING
The basic idea of instancing is to distort all points on an object by a transformation matrix
before the object is displayed.
For example, if we transform the unit circle (in 2D)
by a scale factor (2, 1) in x and y, respectively, then
rotate it by 45◦, and move one unit in the x-
direction, the result is an ellipse with an eccentricity
of 2 and a long axis along the x = −y-direction
centered at (0, 1)
An instance of a circle with a series of
three transforms is an ellipse.
The ray intersection problem in the two spaces are just simple transforms
of each other. The object is specified as a sphere plus matrix M. The ray is specified in the
transformed (world) space by location a and direction b.
If the base object is composed of a set of points, one of which is p, then the transformed
object is composed of that set of points transformed by matrix M
INSTANCING
we can determine the intersection of a ray and an object transformed by matrix M. Let this
function be hit. If we create an instance class of type surface, we need to create a hit
function:
instance::hit(ray a + tb, real t0, real t1, hit-record rec)
ray r = M-1a + tM-1b
if (base-object→hit(r, t0, t1, rec)) then
rec.n = (M-1)T rec.n
return true
else
return false
INSTANCING
CONSTRUCTIVE SOLID GEOMETRY
•Real and virtual objects can be represented by – solid models such as spheres,
cylinders and cones – surface models such as triangles, quads and polygons
• Surface models can be rendered either by – object-order rendering (polygon
rendering) – image-order rendering (ray tracing)
• Solid models can only be rendered by ray tracing
• Solid models are commonly used to describe manmade shapes – computer aided
design – computer assisted manufacturing
CSG combines solid objects by using three (four)
different boolean operations
– intersection (∩)
– union (+)
– minus (–)
– (complement)
• In theory the minus operation can be replaced by a
complement and intersection operation
• In practice the minus operation is often more intuitive
as it corresponds to removing a solid volume
CONSTRUCTIVE SOLID GEOMETRY
UNION
CONSTRUCTIVE SOLID GEOMETRY
INTERSECTION
CONSTRUCTIVE SOLID GEOMETRY
MINUS OPERATION
CONSTRUCTIVE SOLID GEOMETRY
PRIMATIVE OBJECTS
CONSTRUCTIVE SOLID GEOMETRY
CSG TREE OF OPERATIONS
CONSTRUCTIVE SOLID GEOMETRY
FINAL COMPLEX OBJECT
CONSTRUCTIVE SOLID GEOMETRY
CONSTRUCTIVE SOLID GEOMETRY
DISTRIBUTION RAY TRACING
Distributed ray tracing is a ray tracing method based on randomly distributed
oversampling to reduce aliasing artifacts in rendered images.
•Distributed ray tracing uses oversampling to reduce aliasing artifacts. Oversampling is a
process where instead of sampling a single value, multiple samples are taken and averaged
together
•The intensity of a point in a scene can be represented analytically by an integral over the
illumination function and the reflectance function. The evaluation of this integral, while
extremely accurate, is too expensive for most graphics applications.
•Instead of approximating an integral by a single scalar value, the function is point
sampled and these samples are used to define a more accurate scalar value. The practical
benefits of this are:
•Gloss (fuzzy reflections)
•Fuzzy translucency
•Penumbras (soft shadows)
•Depth of field
•Motion blur
• Cast multiple rays from eye through different
parts of same pixel
• Image function f(x,y) – Color that ray through
(x.y) returns
• Sampling function s(x,y) – Controls where the
samples occur within the pixel – One if sample
at (x,y), else zero
• Reconstruction filter r(x,y) – Computes the
weighted average of resulting colors into a
single color – Also weights according to area
DISTRIBUTION RAY TRACING
OVERSAMPLING
SOFT SHADOWS
DISTRIBUTION RAY TRACING
• Point light sources unrealistic
• Use area light source
• Cast shadow rays from surface to different
locations on light
• Hits/rays = % illuminated
• Integral is spatial average, Aliasing can occur and
be very nasty, particularly with uniform grid
GLOSSY SURFACES
DISTRIBUTION RAY TRACING
Surface microfacets perturb reflection
ray directions
• Nearby objects reflect more clearly
because distribution still narrow
• Farther objects reflect more blurry
because distribution has spread
• Helmholtz reciprocity allows us to
sample lobe of BRDF
MOTION BLUR
• Cast multiple rays from eye
through same point in each
pixel
• Each of these rays intersects the
scene at a different time
• Reconstruction filter controls
shutter speed, length
– Box filter – fast shutter
– Triangle filter – slow shutter
DISTRIBUTION RAY TRACING
DISTRIBUTION RAY TRACING
EXAMPLE:
This example shows a technique for generating soft shadows that is not based on
distributed ray tracing. This technique is based on uniformly sampling an area light
source. Although the penumbra and umbra of the shadow are clearly visible, the variation
between them is rigid.
DISTRIBUTION RAY TRACING
This example shows a soft shadow generated by distributed ray tracing. The light source was
sampled using 10 rays
DISTRIBUTION RAY TRACING
This example shows a soft shadow generated by distributed ray tracing. The light
source was sampled using 50 rays.
DISTRIBUTION RAY TRACING
This example shows a perfect reflection produced by a traditional (non-distributed) ray
tracer. Notice that the edges of the reflection are very sharp.
DISTRIBUTION RAY TRACING
Glossy Reflection Example - 50 Distributed Rays
DISTRIBUTION RAY TRACING
Standard Traslucency Example
DISTRIBUTION RAY TRACING
Fuzzy Translucency Example - 20 Distributed Rays

More Related Content

What's hot

Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...rohitjasudkar
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface DetectionAmitBiswas99
 
Spatial filtering using image processing
Spatial filtering using image processingSpatial filtering using image processing
Spatial filtering using image processingAnuj Arora
 
Basic Steps of Video Processing - unit 4 (2).pdf
Basic Steps of Video Processing - unit 4 (2).pdfBasic Steps of Video Processing - unit 4 (2).pdf
Basic Steps of Video Processing - unit 4 (2).pdfHeenaSyed6
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarsyedArr
 
Lossless predictive coding in Digital Image Processing
Lossless predictive coding in Digital Image ProcessingLossless predictive coding in Digital Image Processing
Lossless predictive coding in Digital Image Processingpriyadharshini murugan
 
Transform coding
Transform codingTransform coding
Transform codingNancy K
 
fundamentals of optical fiber
fundamentals of optical fiberfundamentals of optical fiber
fundamentals of optical fiberPraveen Vaidya
 
Graphics Lecture 7
Graphics Lecture 7Graphics Lecture 7
Graphics Lecture 7Saiful Islam
 
Measurements of Rediation Resistance in Antenna
Measurements of Rediation Resistance in AntennaMeasurements of Rediation Resistance in Antenna
Measurements of Rediation Resistance in Antennaparmar sidhdharth
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
COM2304: Morphological Image Processing
COM2304: Morphological Image ProcessingCOM2304: Morphological Image Processing
COM2304: Morphological Image ProcessingHemantha Kulathilake
 
Texture,pattern and pattern classes
Texture,pattern and pattern classesTexture,pattern and pattern classes
Texture,pattern and pattern classesrajisri2
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalAnkit Garg
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalPunyajoy Saha
 

What's hot (20)

Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
 
Hit and-miss transform
Hit and-miss transformHit and-miss transform
Hit and-miss transform
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface Detection
 
Spatial filtering using image processing
Spatial filtering using image processingSpatial filtering using image processing
Spatial filtering using image processing
 
Basic Steps of Video Processing - unit 4 (2).pdf
Basic Steps of Video Processing - unit 4 (2).pdfBasic Steps of Video Processing - unit 4 (2).pdf
Basic Steps of Video Processing - unit 4 (2).pdf
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukar
 
3 D texturing
 3 D texturing 3 D texturing
3 D texturing
 
Lossless predictive coding in Digital Image Processing
Lossless predictive coding in Digital Image ProcessingLossless predictive coding in Digital Image Processing
Lossless predictive coding in Digital Image Processing
 
Transform coding
Transform codingTransform coding
Transform coding
 
fundamentals of optical fiber
fundamentals of optical fiberfundamentals of optical fiber
fundamentals of optical fiber
 
Boundary fill algm
Boundary fill algmBoundary fill algm
Boundary fill algm
 
Ray tracing
Ray tracingRay tracing
Ray tracing
 
Graphics Lecture 7
Graphics Lecture 7Graphics Lecture 7
Graphics Lecture 7
 
Measurements of Rediation Resistance in Antenna
Measurements of Rediation Resistance in AntennaMeasurements of Rediation Resistance in Antenna
Measurements of Rediation Resistance in Antenna
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
COM2304: Morphological Image Processing
COM2304: Morphological Image ProcessingCOM2304: Morphological Image Processing
COM2304: Morphological Image Processing
 
Texture,pattern and pattern classes
Texture,pattern and pattern classesTexture,pattern and pattern classes
Texture,pattern and pattern classes
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 

Similar to Ray Tracing Rendering Technique Explained

Direct Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-castingDirect Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-castingCaferYaarKarabulut
 
Interactive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space TechniquesInteractive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space Techniquescodevania
 
LIGHT , REFACTION AND REFRACTION CLASS 10TH
LIGHT , REFACTION AND REFRACTION CLASS 10TH LIGHT , REFACTION AND REFRACTION CLASS 10TH
LIGHT , REFACTION AND REFRACTION CLASS 10TH Ajay Chikte
 
Computer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionComputer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionDamian T. Gordon
 
Illumination model
Illumination modelIllumination model
Illumination modelAnkur Kumar
 
Chapter 2 geometrical_optics_b
Chapter 2 geometrical_optics_bChapter 2 geometrical_optics_b
Chapter 2 geometrical_optics_bGabriel O'Brien
 
Chapter 2 geometrical_optics_a
Chapter 2 geometrical_optics_aChapter 2 geometrical_optics_a
Chapter 2 geometrical_optics_aGabriel O'Brien
 
GRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and RadiosityGRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and RadiosityMichael Heron
 
Interactive Volumetric Lighting Simulating Scattering and Shadowing
Interactive Volumetric Lighting Simulating Scattering and ShadowingInteractive Volumetric Lighting Simulating Scattering and Shadowing
Interactive Volumetric Lighting Simulating Scattering and ShadowingMarc Sunet
 
reflectionoflight-100829070425-phpapp02.pptx
reflectionoflight-100829070425-phpapp02.pptxreflectionoflight-100829070425-phpapp02.pptx
reflectionoflight-100829070425-phpapp02.pptxSapnaPatiye
 

Similar to Ray Tracing Rendering Technique Explained (20)

Direct Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-castingDirect Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-casting
 
Interactive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space TechniquesInteractive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space Techniques
 
LIGHT , REFACTION AND REFRACTION CLASS 10TH
LIGHT , REFACTION AND REFRACTION CLASS 10TH LIGHT , REFACTION AND REFRACTION CLASS 10TH
LIGHT , REFACTION AND REFRACTION CLASS 10TH
 
RAY OPTICS.pdf
RAY OPTICS.pdfRAY OPTICS.pdf
RAY OPTICS.pdf
 
Light (1)
Light (1)Light (1)
Light (1)
 
graphics notes
graphics notesgraphics notes
graphics notes
 
Atomic Spectra
Atomic SpectraAtomic Spectra
Atomic Spectra
 
Lec03 light
Lec03 lightLec03 light
Lec03 light
 
Computer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionComputer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and Motion
 
Illumination model
Illumination modelIllumination model
Illumination model
 
Shading methods
Shading methodsShading methods
Shading methods
 
november6.ppt
november6.pptnovember6.ppt
november6.ppt
 
Chapter 2 geometrical_optics_b
Chapter 2 geometrical_optics_bChapter 2 geometrical_optics_b
Chapter 2 geometrical_optics_b
 
Chapter 2 geometrical_optics_a
Chapter 2 geometrical_optics_aChapter 2 geometrical_optics_a
Chapter 2 geometrical_optics_a
 
GRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and RadiosityGRPHICS08 - Raytracing and Radiosity
GRPHICS08 - Raytracing and Radiosity
 
Interactive Volumetric Lighting Simulating Scattering and Shadowing
Interactive Volumetric Lighting Simulating Scattering and ShadowingInteractive Volumetric Lighting Simulating Scattering and Shadowing
Interactive Volumetric Lighting Simulating Scattering and Shadowing
 
reflectionoflight-100829070425-phpapp02.pptx
reflectionoflight-100829070425-phpapp02.pptxreflectionoflight-100829070425-phpapp02.pptx
reflectionoflight-100829070425-phpapp02.pptx
 
Ray tracing
Ray tracingRay tracing
Ray tracing
 
3.2 form 4 light
3.2 form 4 light3.2 form 4 light
3.2 form 4 light
 
Ray tracing
Ray tracingRay tracing
Ray tracing
 

More from Mattupallipardhu (13)

Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
Image processing.pptx
Image processing.pptxImage processing.pptx
Image processing.pptx
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
Lec_2.pdf
Lec_2.pdfLec_2.pdf
Lec_2.pdf
 
Lec_10.pdf
Lec_10.pdfLec_10.pdf
Lec_10.pdf
 
Lec_4.pdf
Lec_4.pdfLec_4.pdf
Lec_4.pdf
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
 
Fundamentals of Computer Graphics.pdf
Fundamentals of Computer Graphics.pdfFundamentals of Computer Graphics.pdf
Fundamentals of Computer Graphics.pdf
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Hidden_surfaces.pdf
Hidden_surfaces.pdfHidden_surfaces.pdf
Hidden_surfaces.pdf
 
cathoderaytube.pdf
cathoderaytube.pdfcathoderaytube.pdf
cathoderaytube.pdf
 
2d Transformation.pdf
2d Transformation.pdf2d Transformation.pdf
2d Transformation.pdf
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 

Ray Tracing Rendering Technique Explained

  • 1. RAY TRACING •The basic Ray Tracing Algorithm •Computing Viewing Rays •Ray-Object Intersection •A Ray Tracing Program •Shadows •Specular Reflection •Refraction •Instancing •Constructive Solid Geometry •Distribution Ray Tracing
  • 2. RAY TRACING- INTRODUCTION • RAY TRACING is a rendering technique for generating an image by tracing the path of light as pixels in an image plane and simulating the effects of its encounters with virtual objects. • The technique is capable of producing a very high degree of visual realism, but at a greater computational cost. • Ray tracing is best suited for applications where taking a relatively long time to render a frame can be tolerated, such as in still images and film • Poorly suited for real- time applications such as video games where speed is critical.
  • 3. FORWARD RAY TRACING Forward ray tracing follows the light particles (photons) from the light source to the object. Although forward ray tracing can most accurately determine the coloring of each object, it is highly inefficient. This is because many rays from the light source never come through the viewplane and into the eye. Tracking every light ray from the light source down means that many rays will go to waste because they never contribute to the final image as seen from the eye. Forward ray tracing is also known as light ray tracing and photon tracing. • Rays as paths of photons in world space • Forward ray tracing: follow photon from light sources to viewer RAY TRACING- INTRODUCTION
  • 4. BACKWARD RAY TRACING To make ray tracing more efficient, the method of backward ray tracing is introduced. In backward ray tracing, an eye ray is created at the eye; it passes through the viewplane and on into the world. The first object the eye ray hits is the object that will be visible from that point of the viewplane. After the ray tracer allows that light ray to bounce around, it figures out the exact coloring and shading of that point in the viewplane and displays it on the corresponding pixel on the computer monitor screen. Backward ray tracing is also known as eye ray tracing. The downfall of backward ray tracing is that it assumes only the light rays that come through the viewplane and on into the eye contribute to the final image of the scene. In certain cases, this assumption is flawed. For example, if a lens is held at a distance on top of a table, and is illuminated by a light source directly above, there will exist a focal point beneath the lens with a large concentration of light. If backward ray tracing tries to re- create this image, it will miscalculate because shooting light rays backward only confirms that rays traveled through the lens; backward rays have no way of recognizing that forward rays are bent when they go through the lens. Therefore, if only backward ray tracing is performed, there will only be an even patch of light beneath the lens, just as if the lens were a normal piece of glass and light is transmitted straight through it. RAY TRACING- INTRODUCTION
  • 5. BACKWARD RAY TRACING Ray-casting: one ray from center of projection through each pixel in image plane Illumination: • Phong (Phong shading is an interpolation technique for surface shading in 3D computer graphics) • Shadow rays • Specular reflection • Specular transmission RAY TRACING- INTRODUCTION
  • 6. SHADOW RAYS • Determine if light “really” hits surface point • Cast shadow ray from surface point to light • If shadow ray hits opaque object. No contribution • Improved diffuse reflection RAY TRACING- INTRODUCTION
  • 7. REFLECTION RAYS • Calculate specular component of illumination • Compute reflection ray (recall: backward!) • Call ray tracer recursively to determine color • Add contributions RAY TRACING- INTRODUCTION
  • 8. BASIC RAY TRACING ALGORITHM For( every pixel in the view port) { for(every object in the model world) { if(ray-object intersection) { select the front most intersection; recursively trace the reflection and refraction rays; calculate color; } } } RAY TRACING- INTRODUCTION
  • 9. camera position: let’s call it O=(Ox,Oy,Oz) Viewport: (Vx,Vy,Vz) So what color is the light reaching (Ox,Oy,Oz) after passing through (Vx,Vy,Vz)? EXAMPLE: RENDERING A SPHERE we’ll trace the rays “in reverse”; we’ll start with a ray originating from the camera, going through a point in the viewport, and following it until it hits some object in the scene. This object is what is “seen” from the camera through that point of the viewport.
  • 10. • We need a “frame” through which the scene was viewed. We’ll assume this frame has dimensions Vw and Vh, it’s frontal to the camera orientation (that is, it’s perpendicular to Z+→) at a distance d, EXAMPLE: RENDERING A SPHERE
  • 11. THE RAY EQUATION we can express any point P in the ray as P=O+t(V−O) the ray passes through O, and we know its direction (from O to V). where t is an arbitrary real number. Let’s call (V−O), the direction of the ray, D D→; then the equation becomes simply P=O+tD EXAMPLE: RENDERING A SPHERE
  • 12. THE SPHERE EQUATION If C is the center and r is the radius of the sphere, the points P on the surface of the sphere satisfy the following equation: P−C,P−C =r2 EXAMPLE: RENDERING A SPHERE
  • 13. RAY MEETS SPHERE • We now have two equations, one describing the points on the sphere, and one describing the points on the ray: P−C,P−C =r2 P=O+tD • The point P where the ray hits the sphere is both a point in the ray and a point in the surface of the sphere, so it must satisfy both equations at the same time • substituting P in the first with the expression for P in the second one. This gives us O+tD −C, O+tD −C =r2 further solving for values of t satisfy this equation gives: EXAMPLE: RENDERING A SPHERE varying t across all the real numbers will yield every point P in this ray.
  • 14. • Now we need to do is to compute the intersections of the ray and each sphere, keep the closest one to the camera, and paint the pixel in the canvas with the appropriate color. EXAMPLE: RENDERING A SPHERE ray equation: P=O+t(V−O) we can divide the parameter space in three parts: t<0 Behind the camera 0≤t≤1 Between the camera and the projection plane t>1 The scene Fig. The parameter space
  • 15. EXAMPLE: RENDERING A SPHERE O = <0, 0, 0> for x in [-Cw/2, Cw/2] { for y in [-Ch/2, Ch/2] { D = CanvasToViewport(x, y) color = TraceRay(O, D, 1, inf) canvas.PutPixel(x, y, color) } } CanvasToViewport(x, y) { return (x*Vw/Cw, y*Vh/Ch, d) } PSEUDOCODE: The main method now looks like this: The CanvasToViewport function is :
  • 16. EXAMPLE: RENDERING A SPHERE The TraceRay method computes the intersection of the ray with every sphere, and returns the color of the sphere at the nearest intersection which is inside the requested range of t: TraceRay(O, D, t_min, t_max) { closest_t = inf closest_sphere = NULL for sphere in scene.Spheres { t1, t2 = IntersectRaySphere(O, D, sphere) if t1 in [t_min, t_max] and t1 < closest_t closest_t = t1 closest_sphere = sphere if t2 in [t_min, t_max] and t2 < closest_t closest_t = t2 closest_sphere = sphere } if closest_sphere == NULL return BACKGROUND_COLOR return closest_sphere.color } finally, IntersectRaySphere just solves the quadratic equation:
  • 17. EXAMPLE: RENDERING A SPHERE Result of the above algorithm: The reason they don’t quite look like spheres is that we’re missing a key component of how human beings determine the shape of an object - the way it interacts with light.
  • 18. EXAMPLE: RENDERING A SPHERE LIGHT- adding “realism” to our rendering We’ll consider a simple model with assumptions: 1. All light is white. This lets us characterize any light using a single real number, i, called the intensity of the light. Colored light contains three intensity values, one per color channel. 2. we’ll ignore the atmosphere. This means lights don’t become any less bright no matter how far away they are.
  • 19. LIGHT SOURCES: 1. Point lights: A point light emits light from a fixed point in space, called its position. Light is emitted equally in every direction. 2. Directional lights: a directional light has an intensity, but unlike them, it doesn’t have a position; instead, it has a direction. 3. Ambient light: ambient light is characterized only by its intensity. It’s assumed it unconditionally contributes some light to every point in the scene EXAMPLE: RENDERING A SPHERE Point light Directional light
  • 20. ILLUMINATION OF A SINGLE POINT To compute the illumination of a point: • compute the amount of light contributed by each light source and add them together to get a single number representing the total amount of light it receives. • We can then multiply the color of the surface at that point by this number, to get the appropriately lit color. EXAMPLE: RENDERING A SPHERE When a ray of light hits a matte object, because its surface is quite irregular at the microscopic level, it’s reflected back into the scene equally in every direction; hence “diffuse” reflection.
  • 21. DIFFUSE REFLECTION When a ray of light hits a matte object, because its surface is quite irregular at the microscopic level, it’s reflected back into the scene equally in every direction; hence “diffuse” reflection. The amount of light reflected depends on the angle between the ray of light and the surface. EXAMPLE: RENDERING A SPHERE
  • 22. MODELING DIFFUSE REFLECTION EXAMPLE: RENDERING A SPHERE The ray of light, with a width of I, hits the surface at P, at an angle β. The normal at P is N , and the energy carried by the ray spreads over A. We need to compute I/A.
  • 23. From the figure, cos(α)=QR/PR substituting QR with I/2 and PR with A/2 we get cos(α)=I/A finally I/A= N ,L / |N ||L | EXAMPLE: RENDERING A SPHERE For a sphere N is given by: N =(P−C) / (|P−C|)
  • 24. RENDERING WITH DIFFUSE REFLECTION In first pseudocode add a couple of lights to the scene: EXAMPLE: RENDERING A SPHERE light { type = ambient intensity = 0.2 } light { type = point intensity = 0.6 position = (2, 1, 0) } light { type = directional intensity = 0.2 direction = (1, 4, 4) } Note : that the intensities conveniently add up to 1.0; no point can have a greater light intensity than this.
  • 25. PSEUDOCODE FOR LIGHTING EQUATION : EXAMPLE: RENDERING A SPHERE ComputeLighting(P, N) { i = 0.0 for light in scene.Lights { if light.type == ambient { i += light.intensity } else { if light.type == point L = light.position – P else L = light.direction n_dot_l = dot(N, L) if n_dot_l > 0 i += light.intensity*n_dot_l/(length(N)*length(L)) } } return i } We can use ComputeLighting in TraceRay by replacing the line that returns the color of the sphere by return closest_sphere.color
  • 26. EXAMPLE: RENDERING A SPHERE Output of rendering with diffuse reflection:
  • 27. EXAMPLE: RENDERING A SPHERE SPECULAR REFLECTION When a ray of light hits a perfectly regular surface, it’s reflected in a single direction, which is the symmetric of the incident angle respect to the mirror normal. If we call the direction of the reflected light R , and we keep the convention that L points to the light source, this is the situation: For α=0 , all of the light is reflected. For α=90 , no light is reflected. Thus we take cos(α) .
  • 28. EXAMPLE: RENDERING A SPHERE MODELING SPECULAR REFLECTION Shininess is a measure of how quickly the reflection function decreases as α increases. Thus we take cos(α)s Thus The bigger the value of s, the “narrower” the function becomes around 0, and the shinier the object looks.
  • 29. EXAMPLE: RENDERING A SPHERE A ray L hits a surface at a point P, where the normal is N , and the specular exponent is s. light reflected to the viewing direction V is cos(α)s R =LN→ − LP→ Equation for the specular reflection: R =2N N ,L −L
  • 30. EXAMPLE: RENDERING A SPHERE RENDERING WITH SPECULAR REFLECTIONS Let’s add specular reflections to the scene we’ve been working with so far. First, some changes to the scene itself: sphere { center = (0, -1, 3) radius = 1 color = (255, 0, 0) # Red specular = 500 # Shiny } sphere { center = (2, 0, 4) radius = 1 color = (0, 0, 255) # Blue specular = 500 # Shiny } sphere { center = (-2, 0, 4) radius = 1 color = (0, 255, 0) # Green specular = 10 # Somewhat shiny } sphere { color = (255, 255, 0) # Yellow center = (0, -5001, 0) radius = 5000 specular = 1000 # Very shiny }
  • 31. EXAMPLE: RENDERING A SPHERE We need to change ComputeLighting to compute the specular term when necessary and add it to the overall light. Note that it now needs V and s: ComputeLighting(P, N, V, s) { i = 0.0 for light in scene.Lights { if light.type == ambient { i += light.intensity } else { if light.type == point L = light.position – P else L = light.direction # Diffuse n_dot_l = dot(N, L) if n_dot_l > 0 i += light.intensity*n_dot_l/(length(N)*length(L)) # Specular if s != -1 { R = 2*N*dot(N, L) - L r_dot_v = dot(R, V) if r_dot_v > 0 i += light.intensity*pow(r_dot_v/(length(R)*length(V)), s) } } } return i }
  • 32. TRACERAY WITH SPECULAR REFLECTION: TraceRay(O, D, t_min, t_max) { closest_t = inf closest_sphere = NULL for sphere in scene.Spheres { t1, t2 = IntersectRaySphere(O, D, sphere) if t1 in [t_min, t_max] and t1 < closest_t closest_t = t1 closest_sphere = sphere if t2 in [t_min, t_max] and t2 < closest_t closest_t = t2 closest_sphere = sphere } if closest_sphere == NULL return BACKGROUND_COLOR P = O + closest_t*D # Compute intersection N = P - closest_sphere.center # Compute sphere normal at intersection N = N / length(N) return closest_sphere.color*ComputeLighting(P, N, -D, sphere.specular) } EXAMPLE: RENDERING A SPHERE
  • 33. EXAMPLE: RENDERING A SPHERE Output of rendering with specular reflection:
  • 34. REFRACTION The angle of the refracted ray can be determined by Snell’s law: η1sin(φ1) = η2sin(φ 2) •η1 is a constant for medium 1 • η2 is a constant for medium 2 • φ1 is the angle between the incident ray and the surface normal • φ2 is the angle between the refracted ray and the surface normal • In vector notation Snell’s law can be written: k1(v×n) = k2(v'×n) • The direction of the refracted ray is
  • 35. This equation only has a solution if REFRACTION This illustrates the physical phenomenon of the limiting angle: – if light passes from one medium to another medium whose index of refraction is low, the angle of the refracted ray is greater than the angle of the incident ray – if the angle of the incident ray is large, the angle of the refracted ray is larger than 90o ➨ the ray is reflected rather than refracted
  • 36. REFRACTION Mix reflected and refracted light according to the Fresnel factor L = kfresnelLreflected + (1- k fresnel)Lrefracted FR =((η2cosθ1−η1cosθ2) / (η2cosθ1+η1cosθ2))2 FR =((η1cosθ2−η2cosθ1) / (η1cosθ2+η2cosθ1))2 FR=1/2(FR +FR ).
  • 37. void fresnel(const Vec3f &I, const Vec3f &N, const float &ior, float &kr) { float cosi = clamp(-1, 1, dotProduct(I, N)); float etai = 1, etat = ior; if (cosi > 0) { std::swap(etai, etat); } // Compute sini using Snell's law float sint = etai / etat * sqrtf(std::max(0.f, 1 - cosi * cosi)); // Total internal reflection if (sint >= 1) { kr = 1; } else { float cost = sqrtf(std::max(0.f, 1 - sint * sint)); cosi = fabsf(cosi); float Rs = ((etat * cosi) - (etai * cost)) / ((etat * cosi) + (etai * cost)); float Rp = ((etai * cosi) - (etat * cost)) / ((etai * cosi) + (etat * cost)); kr = (Rs * Rs + Rp * Rp) / 2; } // As a consequence of the conservation of energy, transmittance is given by: // kt = 1 - kr; } REFRACTION
  • 40. • One shadow ray per intersection per point light source SHADOWS
  • 41. Soft shadows :Multiple shadow rays to sample area light source SHADOWS
  • 43. Following steps are taken to trace the shadows: •For each pixel hit on the screen (2D), we cast a ray from it’s actual 3D position in world space towards the light source •If the pixel is occluded, we store our occlusion value SHADOWS •If the pixel is not occluded, we store a value of 1.0 in the buffer
  • 44. SHADING The actual shading step of each pixel that we have traced will be done post ray tracing: •Determine if pixel is occluded (ray traced shadow buffer entry smaller than 1.0). If it is occluded, continue with 2. •Determine the sampling size (for our ray traced shadow buffer) SHADOWS
  • 47. INSTANCING The basic idea of instancing is to distort all points on an object by a transformation matrix before the object is displayed. For example, if we transform the unit circle (in 2D) by a scale factor (2, 1) in x and y, respectively, then rotate it by 45◦, and move one unit in the x- direction, the result is an ellipse with an eccentricity of 2 and a long axis along the x = −y-direction centered at (0, 1) An instance of a circle with a series of three transforms is an ellipse.
  • 48. The ray intersection problem in the two spaces are just simple transforms of each other. The object is specified as a sphere plus matrix M. The ray is specified in the transformed (world) space by location a and direction b. If the base object is composed of a set of points, one of which is p, then the transformed object is composed of that set of points transformed by matrix M INSTANCING
  • 49. we can determine the intersection of a ray and an object transformed by matrix M. Let this function be hit. If we create an instance class of type surface, we need to create a hit function: instance::hit(ray a + tb, real t0, real t1, hit-record rec) ray r = M-1a + tM-1b if (base-object→hit(r, t0, t1, rec)) then rec.n = (M-1)T rec.n return true else return false INSTANCING
  • 50. CONSTRUCTIVE SOLID GEOMETRY •Real and virtual objects can be represented by – solid models such as spheres, cylinders and cones – surface models such as triangles, quads and polygons • Surface models can be rendered either by – object-order rendering (polygon rendering) – image-order rendering (ray tracing) • Solid models can only be rendered by ray tracing • Solid models are commonly used to describe manmade shapes – computer aided design – computer assisted manufacturing CSG combines solid objects by using three (four) different boolean operations – intersection (∩) – union (+) – minus (–) – (complement) • In theory the minus operation can be replaced by a complement and intersection operation • In practice the minus operation is often more intuitive as it corresponds to removing a solid volume
  • 55. CONSTRUCTIVE SOLID GEOMETRY CSG TREE OF OPERATIONS
  • 59. DISTRIBUTION RAY TRACING Distributed ray tracing is a ray tracing method based on randomly distributed oversampling to reduce aliasing artifacts in rendered images. •Distributed ray tracing uses oversampling to reduce aliasing artifacts. Oversampling is a process where instead of sampling a single value, multiple samples are taken and averaged together •The intensity of a point in a scene can be represented analytically by an integral over the illumination function and the reflectance function. The evaluation of this integral, while extremely accurate, is too expensive for most graphics applications. •Instead of approximating an integral by a single scalar value, the function is point sampled and these samples are used to define a more accurate scalar value. The practical benefits of this are: •Gloss (fuzzy reflections) •Fuzzy translucency •Penumbras (soft shadows) •Depth of field •Motion blur
  • 60. • Cast multiple rays from eye through different parts of same pixel • Image function f(x,y) – Color that ray through (x.y) returns • Sampling function s(x,y) – Controls where the samples occur within the pixel – One if sample at (x,y), else zero • Reconstruction filter r(x,y) – Computes the weighted average of resulting colors into a single color – Also weights according to area DISTRIBUTION RAY TRACING OVERSAMPLING
  • 61. SOFT SHADOWS DISTRIBUTION RAY TRACING • Point light sources unrealistic • Use area light source • Cast shadow rays from surface to different locations on light • Hits/rays = % illuminated • Integral is spatial average, Aliasing can occur and be very nasty, particularly with uniform grid
  • 62. GLOSSY SURFACES DISTRIBUTION RAY TRACING Surface microfacets perturb reflection ray directions • Nearby objects reflect more clearly because distribution still narrow • Farther objects reflect more blurry because distribution has spread • Helmholtz reciprocity allows us to sample lobe of BRDF
  • 63. MOTION BLUR • Cast multiple rays from eye through same point in each pixel • Each of these rays intersects the scene at a different time • Reconstruction filter controls shutter speed, length – Box filter – fast shutter – Triangle filter – slow shutter DISTRIBUTION RAY TRACING
  • 64. DISTRIBUTION RAY TRACING EXAMPLE: This example shows a technique for generating soft shadows that is not based on distributed ray tracing. This technique is based on uniformly sampling an area light source. Although the penumbra and umbra of the shadow are clearly visible, the variation between them is rigid.
  • 65. DISTRIBUTION RAY TRACING This example shows a soft shadow generated by distributed ray tracing. The light source was sampled using 10 rays
  • 66. DISTRIBUTION RAY TRACING This example shows a soft shadow generated by distributed ray tracing. The light source was sampled using 50 rays.
  • 67. DISTRIBUTION RAY TRACING This example shows a perfect reflection produced by a traditional (non-distributed) ray tracer. Notice that the edges of the reflection are very sharp.
  • 68. DISTRIBUTION RAY TRACING Glossy Reflection Example - 50 Distributed Rays
  • 69. DISTRIBUTION RAY TRACING Standard Traslucency Example
  • 70. DISTRIBUTION RAY TRACING Fuzzy Translucency Example - 20 Distributed Rays