0% found this document useful (0 votes)
59 views73 pages

UNIT 7 Visible Surface Determination

Uploaded by

yehid13435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views73 pages

UNIT 7 Visible Surface Determination

Uploaded by

yehid13435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

https://genuinenotes.

com

Visible Surface

Nipun Thapa (Computer Graphics)


Determination
Unit 7

1
https://genuinenotes.com
Visible Surface Detection (Hidden
Surface Removal) Method
It is the process of identifying those parts of a scene that
are visible from a chosen viewing position. There are numerous
algorithms for efficient identification of visible objects for
different types of applications. These various algorithms are
referred to as visible-surface detection methods. Sometimes

Nipun Thapa (Computer Graphics)


these methods are also referred to as hidden-surface
elimination methods.
• To identify those parts of a scene that are visible from a
chosen viewing position (visible-surface detection methods).
• Surfaces which are obscured by other opaque (solid) surfaces
along the line of sight are invisible to the viewer so can be
eliminated (hidden-surface elimination methods).
2
https://genuinenotes.com

Visible Surface Determination..


Visible surface detection methods are broadly classified
according to whether they deal with objects or with their projected
images.
These two approaches are
• Object-Space methods(OSM):

Nipun Thapa (Computer Graphics)


• Deal with object definition
• Compares objects and parts of objects to each other within the scene
definition to determine which surface as a whole we should label as
visible.
• E.g. Back-face detection method
• Image-Space methods(ISM):
• Deal with projected image
• Visibility is decided point by point at each pixel position on the projection
plane.
• E.g. Depth-buffer method, Scan-line method, Area-subdivision method
• Most visible surface detection algorithm use image-space-method 3
but in some cases object space methods are also used for it.
https://genuinenotes.com

Visible Surface Determination..

• List Priority Algorithms


• This is a hybrid model that combines both object and image
precision operations. Here, depth comparison & object splitting
are done with object precision and scan conversion (which relies

Nipun Thapa (Computer Graphics)


on ability of graphics device to overwrite pixels of previously
drawn objects) is done with image precision.
• E.g. Depth-Shorting method, BSP-tree method

4
https://genuinenotes.com

Visible Surface Determination

Nipun Thapa (Computer Graphics)


5
https://genuinenotes.com

Visible Surface Determination

Nipun Thapa (Computer Graphics)


6
https://genuinenotes.com

Visible Surface Determination

Nipun Thapa (Computer Graphics)


7
https://genuinenotes.com

Object-Space methods

Nipun Thapa (Computer Graphics)


8
https://genuinenotes.com

Object-Space methods

Nipun Thapa (Computer Graphics)


9
https://genuinenotes.com

Image Space Methods

Nipun Thapa (Computer Graphics)


10
https://genuinenotes.com

Image Space Methods

Nipun Thapa (Computer Graphics)


11
https://genuinenotes.com

Nipun Thapa (Computer Graphics)


12
https://genuinenotes.com

Back – Face Detection Method


• A fast and simple object-space method for identifying the back faces
of a polyhedron.
• It is based on the performing inside-outside test.
TWO METHODS:
First Method:

Nipun Thapa (Computer Graphics)


• A point (x, y, z) is "inside" a polygon surface with plane parameters
A, B, C, and D if Ax+By+Cz+D < 0 (from plane equation).
• When an inside point is along the line of sight to the surface, the
polygon must be a back face.
• In eq. Ax+By+Cz+D=0
if A,B,C remain constant , then varying value of D result in a whole
family of parallel plane
if D>0, plane is behind the origin (Away from observer)
if D<0 , plane is in front of origin (toward the observer) 13
https://genuinenotes.com

Back – Face Detection Method


Second Way
• Let N be normal vector to a polygon surface, which has
Cartesian components (A, B, C). In general, if V is a vector in
the viewing direction from the eye (or "camera") position,
then this polygon is a back face

Nipun Thapa (Computer Graphics)


if V.N>0.

14
https://genuinenotes.com

Back – Face Detection Method

Nipun Thapa (Computer Graphics)


15
https://genuinenotes.com

Back – Face Detection Method

Nipun Thapa (Computer Graphics)


16
https://genuinenotes.com

Back – Face Detection Method


A view vector V is constructed from any point on the surface to the
viewpoint, the dot product of this vector and the normal N, indicates visible faces
as follows:
Case-I: (FRONT FACE)
If V.N < 0 the face is visible else face is hidden

Nipun Thapa (Computer Graphics)


Case-II: (BACK FACE)
If V.N > 0 the face is visible else face is hidden

Case-III:
For other objects, such as the concave polyhedron in Fig., more
tests need to be carried out to determine whether there are additional
faces that are totally or partly obscured by other faces. 17
Numerical https://genuinenotes.com
# Find the visibility for the surface AED in rectangular pyramid where an
observer is at P (5, 5, 5).

Solution
Here,
AE = (0-1)i + (1-0)j + (0-0)k = -i + j
AD= (0-1)i + (1-0)j + (1-0)k =-i + k

Step-1:
Normal vector N for AED

Nipun Thapa (Computer Graphics)


Thus, N = AE x AD =

Case-II
Step-2: If observer at P(5, 5, 5) so we can construct the view vector V from
surface to view point A(1, 0, 0) as:
V = AP = (5-1)i + (5-0)j + (5-0)k = 4i + 5j + 5k

Step-3: To find the visibility of the object, we use dot product of view vector V
and normal vector N as:
V.N = (4i + 5j + 5k).(i + j + k) = 4+5+5 = 14> 0 18

This shows that the surface is visible for the observer.


https://genuinenotes.com
Case-I

Step-2: If observer at P(5, 5, 5) so we can construct the view


vector
V from surface to view point A(1, 0, 0) as:
V = PA = (1-5)i + (0-5)j + (0-5)k = -4i - 5j - 5k

Nipun Thapa (Computer Graphics)


Step-3: To find the visibility of the object, we use dot product of
view vector V and normal vector N
as:
V.N = (-4i - 5j - 5k).(i + j + k) = -4-5-5 = -14< 0
This shows that the surface is visible for the observer.

19
https://genuinenotes.com
• # Find the visibility for the surface AED in rectangular pyramid
where an observer is at P (0,0.5, 0).

Nipun Thapa (Computer Graphics)


20
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

• A commonly used image-space approach to detecting visible


surfaces is the depth-buffer method, which compares surface
depths at each pixel position on the projection plane.
• Also called z-buffer method since depth usually measured
along z-axis. This approach compares surface depths at each

Nipun Thapa (Computer Graphics)


pixel position on the projection plane.
• Each surface of a scene is processed separately, one point at a
time across the surface. And each (x, y, z) position on a
polygon surface corresponds to the projection point (x, y) on
the view plane.

21
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

This method requires two buffers:


• A z-buffer or depth buffer: Stores depth values for each pixel
position (x, y).
• Frame buffer (Refresh buffer): Stores the surface-intensity

Nipun Thapa (Computer Graphics)


values or color values for each pixel position.
• As surfaces are processed, the image buffer is used to store
the color values of each pixel position and the z-buffer is used
to store the depth values for each (x, y) position.

22
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

Nipun Thapa (Computer Graphics)


23
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

Initially, all positions in the depth buffer are set to 0


(minimum depth), and the refresh buffer is initialized to the
background intensity. Each surface listed in the polygon tables is
then processed, one scan line at a time, calculating the depth (z-
value) at each (x, y) pixel position. The calculated depth is

Nipun Thapa (Computer Graphics)


compared to the value previously stored in the depth buffer at
that position. If the calculated depth is greater than the value
stored in the depth buffer, the new depth value is stored, and
the surface intensity at that position is determined and placed in
the same xy location in the refresh buffer.
A drawback of the depth-buffer method is that it can only
find one visible surface for opaque surfaces and cannot
accumulate intensity values for transparent surfaces. 24
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)


Algorithm:
1. Initialize both, depth buffer and refresh buffer for all buffer positions (x, y),
depth(x, y) = 0
refresh(x, y) = Ibackground,
(where Ibackground is the value for the background intensity.)

Nipun Thapa (Computer Graphics)


2. Process each polygon surface in a scene one at a time,
( Each surface listed in the polygon tables is then processed, one scan line at a time, calculating the depth (z-value) at each
(x, y) pixel position.)
2.1. Calculate the depth z for each (x, y) position on the polygon.
(The calculated depth is compared to the value previously stored in the depth buffer at that position.)
2.2. If Z > depth(x, y), then set
depth(x, y)=z (If the calculated depth is greater than the value stored in the depth buffer, the new depth value is stored,)
refresh(x, y)= Isurf(x, y),
(where Isurf(x, y) is the intensity value for the surface at pixel position (x, y). )

3. After all pixels and surfaces are compared, draw object using X,Y,Z from depth 25
and intensity refresh buffer.
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

• After all surfaces have been processed the depth buffer


contains depth values for the visible surfaces and the refresh
buffer contains the corresponding intensity values for those
surfaces
Depth value for a surface position (x, y) is

Nipun Thapa (Computer Graphics)


z = (-Ax –By – D)/c …………………(i)

Let depth z’ at (x + 1 , y) Z Z’
z’ = {-A(x+1) – By – D}/c
z’ = {-Ax –By – D-A}/c
z’ = (-Ax –By – D)/c - A/c
or
26
z’ = z – A/c………..(ii)
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

Nipun Thapa (Computer Graphics)


27
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

Nipun Thapa (Computer Graphics)


28
https://genuinenotes.com

Depth – Buffer (Z – Buffer Method)

Nipun Thapa (Computer Graphics)


29
https://genuinenotes.com

Class Work
Q.N.1> Write a procedure to fill the interior of a given ellipse
with a specified pattern. (2070 TU)
.
Q.N.2> What do you mean by line clipping? Explain the

Nipun Thapa (Computer Graphics)


procedures for line clipping. (2070 TU)

30
https://genuinenotes.com

A – Buffer Method
• The A-buffer (anti-aliased, area-averaged, accumulation
buffer) is an extension of the ideas in the depth-buffer
method (other end of the alphabet from "z-buffer").
• A drawback of the depth-buffer method is that it deals only
with opaque(Solid) surfaces and cannot accumulate intensity

Nipun Thapa (Computer Graphics)


values for more than one transparent surfaces.
• The A-buffer method is an extension of the depth-buffer
method.
• The A-buffer is incorporated into the REYES ("Renders
Everything You Ever Saw") 3-D rendering system.
• The A-buffer method calculates the surface intensity for
multiple surfaces at each pixel position, and object edges can 31
be ant aliased.
https://genuinenotes.com

A – Buffer Method
• The A-buffer expands on the depth buffer method to allow
transparencies. The key data structure in the A-buffer is the
accumulation buffer

Nipun Thapa (Computer Graphics)


32
https://genuinenotes.com

A – Buffer Method

Each pixel position in the A-Buffer has two fields


Depth Field : stores a positive or negative real number
• Positive : single surface contributes to pixel intensity

Nipun Thapa (Computer Graphics)


• Negative : multiple surfaces contribute to pixel intensity
Intensity Field : stores surface-intensity information or a pointer value
• Surface intensity if single surface stores the RGB components of the
surface color at that point
• and percent of pixel coverage Pointer value if multiple surfaces
• RGB intensity components
• Opacity parameter(per cent of transparency)
• Per cent of area coverage
• Surface identifier
• Other surface rendering parameters 33
• Pointer to next surface (Link List)
https://genuinenotes.com
A – Buffer Method

If depth is >= 0, then the surface data field stores the depth

Nipun Thapa (Computer Graphics)


of that pixel position as before (SINGLE SURFACE)
(If the depth field is positive, the number stored at that position is the depth of a single
surface overlapping the corresponding pixel area. The intensity field then stores the RCB
components of the surface color at that point and the percent of pixel coverage, as
illustrated first figure.)

If depth < 0 then the data filed stores a pointer to a linked


list of surface data (MULTIPLE SURFACE)
(If the depth field is negative, this indicates multiple-surface contributions to the pixel
intensity. The intensity field then stores a pointer to a linked list of surface data, as in 34
second figure. Data for each surface in the linked list includes: RGB intensity components,
opacity parameter (percent of transparency), depth, percent of area coverage, surface
identifier, other surface-rendering parameters, and pointer to next surface)
https://genuinenotes.com

A – Buffer Method
• The A-buffer can be constructed using methods similar to
those in the depth-buffer algorithm. Scan lines are processed
to determine surface overlaps of pixels across the individual
scan lines. Surfaces are subdivided into a polygon mesh and
clipped against the pixel boundaries. Using the opacity factors

Nipun Thapa (Computer Graphics)


and percent of surface overlaps, we can calculate the intensity
of each pixel as an average of the contributions from the over
lapping surfaces.

35
https://genuinenotes.com

Class Work
Q.N.1 > Explain with algorithm of generating curves. (TU 2071)
Q.N.2 > Set up a procedure for establishing polygon tables for
any input set of data defining an object. (TU 2071)
Q.N.3 > Explain the window to view port transformation with its

Nipun Thapa (Computer Graphics)


applications. (TU 2071/2070)
Q.N.4 > Write a procedure to perform a two-point perspective
projection of an object. (TU 2070)

36
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


• This method uses both object space and image space method.
• In this method the surface representation of 3D object are sorted in
of decreasing depth from viewer.
• Then sorted surface are scan converted in order starting with
surface of greatest depth for the viewer.

Nipun Thapa (Computer Graphics)


37
https://genuinenotes.com
The conceptual steps that performed
in depth-sort algorithm are
1. Sort all polygon surface according to the smallest
(farthest) Z co-ordinate of each.
2. Resolve any ambiguity(doubt) this may cause when the
polygons Z extents overlap, splitting polygons if

Nipun Thapa (Computer Graphics)


necessary.
3. Scan convert each polygon in ascending order of
smaller Z-co-ordinate i.e. farthest surface first (back to
front)

38
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


• In this method, the newly displayed surface is partly or
completely obscure the previously displayed surface.
Essentially, we are sorting the surface into priority order
such that surface with lower priority (lower z, far objects)

Nipun Thapa (Computer Graphics)


can be obscured by those with higher priority (high z-
value).

39
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


• This algorithm is also called "Painter's Algorithm" as it
simulates how a painter typically produces his painting
by starting with the background and then progressively
adding new (nearer) objects to the canvas.

Nipun Thapa (Computer Graphics)


• Thus, each layer of paint covers up the previous layer.
• Similarly, we first sort surfaces according to their distance
from the view plane. The intensity values for the farthest
surface are then entered into the refresh buffer. Taking
each succeeding surface in turn (in decreasing depth
order), we "paint" the surface intensities onto the frame
buffer over the intensities of the previously processed
40
surfaces.
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


Problem

Nipun Thapa (Computer Graphics)


41
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


Problem
• One of the major problem in this algorithm is intersecting polygon
surfaces. As shown in fig. below.

Nipun Thapa (Computer Graphics)


o Different polygons may have same depth.
o The nearest polygon could also be farthest.
42
We cannot use simple depth-sorting to remove the hidden-surfaces in the images.
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)


Solution
• For intersecting polygons, we can split one polygon into
two or more polygons which can then be painted from
back to front. This needs more time to compute

Nipun Thapa (Computer Graphics)


intersection between polygons. So it becomes complex
algorithm for such surface existence.

43
https://genuinenotes.com

DEPTH SORT (Painter Algorithm)

Nipun Thapa (Computer Graphics)


44
https://genuinenotes.com

Scan-Line Method
• This image-space method for removing hidden surfaces is an
extension of the scan-line algorithm for filling polygon
interiors where, we deal with multiple surfaces rather than
one.
• Each scan line is processed with calculating the depth for

Nipun Thapa (Computer Graphics)


nearest view for determining the visible surface of intersecting
polygon. When the visible surface has been determined, the
intensity value for that position is entered into the refresh
buffer.

45
https://genuinenotes.com

Scan-Line Method
• To facilitate the search for surfaces crossing a given scan line,
we can set up an active list of edges from information in the
edge table that contain only edges that cross the current scan
line, sorted in order of increasing x.
• In addition, we define a flag for each surface that is set on or

Nipun Thapa (Computer Graphics)


off to indicate whether a position along a scan line is inside or
outside of the surface. Scan lines are processed from left to
right.
• At the leftmost boundary of a surface, the surface flag is
turned on; and at the rightmost boundary, it is turned off.

46
https://genuinenotes.com

Scan-Line Method
DATA STRUCTURE
• A. Edge table containing
• Coordinate endpoints for each line in a scene
• Inverse slope of each line
• Pointers into polygon table to identify the surfaces bounded by each line
• B. Surface table containing

Nipun Thapa (Computer Graphics)


• Coefficients of the plane equation for each surface
• Intensity information for each surface
• Pointers to edge table
• C. Active Edge List
• To keep a trace of which edges are intersected by the given scan line

Note :
• The edges are sorted in order of increasing x
47
• Define flags for each surface to indicate whether a position is inside or
outside the surface
https://genuinenotes.com

Scan-Line Method
I. Initialize the necessary data structure
1. Edge table containing end point coordinates, inverse slope and
polygon pointer.
2. Surface table containing plane coefficients and surface intensity
3. Active Edge List

Nipun Thapa (Computer Graphics)


4. Flag for each surface
II. For each scan line repeat
1. update active edge list
2. determine point of intersection and set surface on or off.
3. If flag is on, store its value in the refresh buffer
4. If more than one surface is on, do depth sorting and store the
intensity of surface nearest to view plane in the refresh buffer 48
https://genuinenotes.com

Scan-Line Method
• For scan line 1
• The active edge list contains edges AB,BC,EH, FG
• Between edges AB and BC, only flags for s1 == on and
between edges EH and FG, only flags for s2==on
• no depth calculation needed and corresponding surface
intensities are entered in refresh buffer
• For scan line 2
• The active edge list contains edges AD,EH,BC and FG

Nipun Thapa (Computer Graphics)


• Between edges AD and EH, only the flag for surface s1 == on
• Between edges EH and BC flags for both surfaces == on
• Depth calculation (using plane coefficients) is needed.
• In this example ,say s2 is nearer to the view plane than s1, so
intensities for surface s2 are loaded into the refresh buffer
until boundary BC is encountered
• Between edges BC and FG flag for s1==off and flag for s2 ==
on
• Intensities for s2 are loaded on refresh buffer
• For scan line 3
• Same coherent property as scan line 2 as noticed from active 49
list, so no depth
https://genuinenotes.com

Scan-Line Method
Problem:
Dealing with cut through surfaces and
cyclic overlap is problematic when
used coherent properties
• Solution: Divide the surface to

Nipun Thapa (Computer Graphics)


eliminate the overlap or cut through

50
https://genuinenotes.com

Class Work
Q.N.1> What do you mean by homogeneous coordinates? Rotate a triangle
A(5,6), B(6,2) and C(4,1) by 45 degree about an arbitrary pivot point (3,3).
(TU 2072)

Q.N.2> Given a clipping window P(0,0), Q(30,20), S(0,20) use the Cohen
Sutherland algorithm to determine the visible portion of the line A(10,30)

Nipun Thapa (Computer Graphics)


and B(40,0). (TU 2072)

Q.N.3> Explain polygon clipping in detail. By using the sutherland-


Hodgemen Polygon clipping algorithm clip the following polygon. (TU 2072)

51
Binary Space Partitioning
https://genuinenotes.com

(BSP)
• Binary space partitioning is a 3-D graphics programming
technique of dividing a scene into two recursively using
hyperplanes.
• In other words, a 3-D scene is split in two using a 2-D plane,
then that scene is divided in two using a 2-D plane, and so on.

Nipun Thapa (Computer Graphics)


The resulting data structure is a binary tree, or a tree where
every node has two branches.
• The technique is widely used to speed up rendering of 3-D
scenes, especially in games.

52
Binary Space Partitioning
https://genuinenotes.com

(BSP)
• binary space partitioning (BSP) is a method
for recursively subdividing a space into convex
sets by hyperplanes. This subdivision gives rise to a
representation of objects within the space by means of a tree
data structure known as a BSP tree.

Nipun Thapa (Computer Graphics)


• Binary space partitioning was developed in the context of 3D
computer graphics, where the structure of a BSP tree allows
spatial information about the objects in a scene that is useful
in rendering, such as their ordering from front-to-back with
respect to a viewer at a given location, to be accessed rapidly.
Other applications include performing geometrical operations
with shapes (constructive solid geometry) in CAD, collision
detection in robotics and 3D video games, ray tracing and
other computer applications that involve handling of complex 53
spatial scenes.
Binary Space Partitioning
https://genuinenotes.com

(BSP)
• Previous list priority algorithms fail in a number of cases non
of them is completely general
• BSP tree is a general solution, but with its own problems
• Tree size

Nipun Thapa (Computer Graphics)


• Tree accuracy

54
https://genuinenotes.com
Binary Space Partitioning Trees
(Fuchs, Kedem and Naylor `80)
• More general, can deal with inseparable objects
• Automatic, uses as partitions planes defined by the scene
polygons
• Method has two steps:
• building of the tree independently of viewpoint

Nipun Thapa (Computer Graphics)


• traversing the tree from a given viewpoint to get visibility
ordering

55
https://genuinenotes.com

Building a BSP Tree (Recursive)

{1, 2, 3, 4, 5, 6}

Nipun Thapa (Computer Graphics)


The tree

A set of polygons 56
https://genuinenotes.com

Building a BSP Tree (Recursive)

Nipun Thapa (Computer Graphics)


Select one polygon and partition the space and the polygons

57
https://genuinenotes.com

Building a BSP Tree (Recursive)

Nipun Thapa (Computer Graphics)


Recursively partition each sub-tree until all polygons are used up

58
https://genuinenotes.com

Building a BSP Tree (Recursive)


• Start with a set of polygons and an empty tree
• Select one of them and make it the root of the
tree
• Use its plane to divide the rest of the polygons in

Nipun Thapa (Computer Graphics)


3 sets: front, back, coplanar.
• Any polygon crossing the plane is split
• Repeat the process recursively with the front and
back sets, creating the front and back subtrees
respectively
59
https://genuinenotes.com

Building a BSP Tree (Incremental)


• The tree can also be built incrementally:
• start with a set of polygons and an empty tree
• insert the polygons into the tree one at a time
• insertion of a polygon is done by comparing it against

Nipun Thapa (Computer Graphics)


the plane at each node and propagating it to the right
side, splitting if necessary
• when the polygon reaches an empty cell, make a node
with its supporting plane

60
https://genuinenotes.com

Back-to-Front Traversal
void traverse_btf(Tree *t, Point vp)
{
if (t = NULL) return;
endif
if (vp in-front of plane at root of t)
traverse_btf(t->back, vp);
draw polygons on node of t;

Nipun Thapa (Computer Graphics)


traverse_btf;(t->front, vp);
else
traverse_btf(t->front, vp);
draw polygons on node of t;
traverse_btf(t->back, vp);
endif
}

61
https://genuinenotes.com

BSP as a Hierarchy of Spaces

• Each node corresponds to a region of space


• the root is the whole of Rn
• the leaves are homogeneous regions
https://genuinenotes.com

Representation of Polygons

Nipun Thapa (Computer Graphics)


63
https://genuinenotes.com

Representation of Polyhedra

Nipun Thapa (Computer Graphics)


64
https://genuinenotes.com

BSP Trees for Dynamic Scenes


• When an object moves the planes that represent it must be
removed and re-inserted
• Some systems only insert static geometry into the BSP tree
• Otherwise must deal with merging and fixing the BSP cells

Nipun Thapa (Computer Graphics)


(see the book!)

65
https://genuinenotes.com

Recap
• A BSP is a sequence of binary partitions of space
• Can be built recursively or incrementally
• Choice of plane used to split is critical
• BSP trees are hard to maintain for dynamic scenes

Nipun Thapa (Computer Graphics)


66
https://genuinenotes.com

octree
• octree is a tree data structure in which each internal node has
exactly eight children. Octrees are most often used to
partition a three-dimensional spaceby recursively
subdividing it into eight octants.
• Octrees are the three-dimensional analog of quadtrees. The

Nipun Thapa (Computer Graphics)


name is formed from oct + tree, but note that it is normally
written "octree" with only one "t". Octrees are often used
in 3D graphics and 3D game engines.

67
https://genuinenotes.com

octree

Nipun Thapa (Computer Graphics)


68
https://genuinenotes.com

Ray tracing
• 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

Nipun Thapa (Computer Graphics)


visual realism, usually higher than that of typical scanline
renderingmethods, but at a greater computational cost.

69
https://genuinenotes.com

Ray tracing
• This makes ray tracing best suited for applications where
taking a relatively long time to render a frame can be
tolerated, such as in still images and film and television visual
effects, and more poorly suited for real-time applications such
as video games where speed is critical. Ray tracing is capable

Nipun Thapa (Computer Graphics)


of simulating a wide variety of optical effects, such
as reflection and refraction, scattering,and dispersion phenom
ena (such as chromatic aberration).

70
https://genuinenotes.com

Ray tracing

Nipun Thapa (Computer Graphics)


71
https://genuinenotes.com

Ray tracing
• Optical ray tracing describes a method for producing visual
images constructed in 3D computer graphic senvironments,
with more photorealism than either ray casting or scanline
rendering techniques.
• It works by tracing a path from an imaginary eye through

Nipun Thapa (Computer Graphics)


each pixel in a virtual screen, and calculating the color of the
object visible through it.

72
https://genuinenotes.com

Chapter 6

Nipun Thapa (Computer Graphics)


Finished
73

You might also like