SlideShare a Scribd company logo
CG by Rohit Jasudkar 1
Computer Graphics
21/09/2018
Hidden surfaces and line removal
Curves and surfaces
Surface Rendering methods
Contents
 Hidden surfaces and line removal
• Z buffer Algorithm
• Warnock’s Algorithm
• Painter’s Algorithm
• Backface Removal Algorithm
 Curves and surfaces
• Bezier Curve
• B-splines Curve
 Surface Rendering Methods
• Constant Intensity / Flat Shading
• Gouraurd Shading
• Phong Shading
21/09/2018 CG by Rohit Jasudkar 2
Hidden surfaces and line removal
21/09/2018 CG by Rohit Jasudkar 3
Overlapping Surfaces
Intersecting Surfaces
21/09/2018 CG by Rohit Jasudkar 4
Back faced Surfaces
Occluded Surfaces
Hidden Surface Problem
• When we view a picture containing non
transparent objects and surfaces, then we can’t see
those objects from view which are behind from the
objects closer to eye.
• We must remove these hidden surfaces to get
realistic screen image.
• The identification & removal of these surfaces is
called the Hidden-surface problem .
• Techniques used for solving these problems known
as Visible Surface Detection or Hidden Surface
Removal.
21/09/2018 CG by Rohit Jasudkar 5
21/09/2018 CG by Rohit Jasudkar 6
Classification of Visible Surface Detection
1. Object space methods
2. Image space methods
21/09/2018 CG by Rohit Jasudkar 7
Object space methods
• Methods based on comparison of objects for
their 3D positions and dimensions with
respect to a viewing position.
• Efficient for small number of objects but
difficult to implement.
• Depth sorting (Painter Algorithm) , area
subdivision methods (Warnock’s Algorithm).
21/09/2018 CG by Rohit Jasudkar 8
Image space methods
• Based on the pixels to be drawn on 2D. Try to
determine which object should contribute to that
pixel.
• Running time complexity is the number of pixels
times number of objects.
• Space complexity is two times the number of pixels:
– One array of pixels for the frame buffer
– One array of pixels for the depth buffer
• Depth-buffer (Z-Buffer) and ray casting methods.
21/09/2018 CG by Rohit Jasudkar 9
Z buffer Algorithm
• Also known as depth -Buffer method.
• Proposed by Mr. Edwin Catmull in 1975
• Z-buffer is like a frame buffer, contain
depths
21/09/2018 CG by Rohit Jasudkar 10
Basic Z-buffer idea:
• Rasterize every input polygon
• For every pixel in the polygon interior,
calculate its corresponding z value.
• Track depth values of closest polygon
(smallest z) so far
• Update the pixel values with the color of
the polygon whose z value is the closest to
the eye.
21/09/2018 CG by Rohit Jasudkar 11
• Two buffers are used
– Frame Buffer (Store Background intensity
or Shades)
– Depth Buffer (Store depth (Z) value of every
visible pixel in image space)
• The z-coordinates (depth values) are
usually normalized to the range [0,1]
21/09/2018 CG by Rohit Jasudkar 12
Z – Buffer Algorithm
• Initialize the depth buffer and frame buffer so that
for all buffer positions (x ,y ),
depthBuff (x,y) = 1.0, frameBuff (x,y) = bgColor
• Process each polygon in a scene, one at a time
– For each projected (x ,y ) pixel position of a polygon,
calculate the depth z .
– If z < depthBuff (x,y), compute the surface color at that
position and set
– depthBuff (x,y) = z, frameBuff (x,y) = surfCol (x,y)
21/09/2018 CG by Rohit Jasudkar 13
Calculating depth values (z)
21/09/2018 CG by Rohit Jasudkar 14
0,
)(
0




C
C
DByAx
z
DCzByAx
Using the polygon surface equation:
21/09/2018 CG by Rohit Jasudkar 15
21/09/2018 CG by Rohit Jasudkar 16
21/09/2018 CG by Rohit Jasudkar 17
21/09/2018 CG by Rohit Jasudkar 18
Advantages
• No Sorting of polygons required.
• No Object to Object Comparison.
• Can be applied to non polygonal object.
• Simple to use.
• Computing the required depth values is simple.
21/09/2018 CG by Rohit Jasudkar 19
Disadvantages
• Requires two buffer which makes is
expensive.
• The required z-precision is maintained at
a higher resolution as compared to x,y
precision.
• High memory requirements.
21/09/2018 CG by Rohit Jasudkar 20
Warnock’s Algorithm
• Developed by John Warnocks.
• Based on the hypothesis of how human eye , brain
combination processes the information present in a
scene.
• Divide-and-conquer strategy: spatial partitioning in
the projection plane
• An area of the projection plane is examined
• If all polygons visible in that area can be easily
decided, they are displayed
• Otherwise, it is recursively decided
21/09/2018 CG by Rohit Jasudkar 21
21/09/2018 CG by Rohit Jasudkar 22
21/09/2018 CG by Rohit Jasudkar 23
21/09/2018 CG by Rohit Jasudkar 24
21/09/2018 CG by Rohit Jasudkar 25
At each stage, the projection of each polygon has one of
four relationships to the area of interest (Window)
• Surrounding polygons completely contain the area of
interest
• Intersecting polygons intersect the area of interest
• Contained polygons are completely inside the area
• Disjoint polygons are completely outside the area
21/09/2018 CG by Rohit Jasudkar 26
For each window
• Disjoint polygons, the window is empty therefore
displayed with background intesity.
• Intersecting polygons can be split into disjoint and
contained polygons.
• If there is only one contained polygon, fill area with
background, then scan-fill polygon area.
• If there is a single surrounding polygon, and no
intersecting or contained polygons, display the
surrounding polygons color.
• There are more than one surrounding polygon in
window, front of all other polygons display the
surrounding polygon color in the area.
• Otherwise subdivide the window.
21/09/2018 CG by Rohit Jasudkar 27
Painter’s Algorithm
21/09/2018 CG by Rohit Jasudkar 28
How painter paints objects in the
scene?
• Draw objects from back to
front
• The new object paint will hide
the old object paint.
• It require depth comparisons.
• Also known as Depth sort Algorithm or
Priority Algorithm.
• Two Basic functions:
1. Sort the polygons according to the farthest Z
coordinate
2. Scan convert each polygon in ascending order of
farthest z coordinate (back-to-front)
21/09/2018 CG by Rohit Jasudkar 29
• Simple algorithm:
– Sort all polygons based on their farthest z coordinate
– Resolve ambiguities (if overlapping of objects occurs)
– Draw the polygons in order from back to front
• This algorithm would be very simple if the z
coordinates of the polygons were guaranteed never
to overlap. Unfortunately that is usually not the
case, which means that step 2 can be somewhat
complex.
21/09/2018 CG by Rohit Jasudkar 30
21/09/2018 CG by Rohit Jasudkar 31
Z min
21/09/2018 CG by Rohit Jasudkar 32
Overlapping Problem
21/09/2018 CG by Rohit Jasudkar 33
• All polygons whose z extents overlap must be
tested against each other.
• We start with the furthest polygon and call it P.
Polygon P must be compared with every
polygon Q whose z extent overlaps P's z extent.
5 comparisons are made. If any comparison is
true then P can be written before Q.
21/09/2018 CG by Rohit Jasudkar 34
Test Cases
• 1. Do P and Q's x-extents not overlap?
• 2. Do P and Q's y-extents not overlap?
• 3. Is P entirely on the opposite side of Q's plane from the
viewport?
• 4. Is Q entirely on the same side of P's plane as the viewport?
• 5. Do the projections of P and Q onto the (x,y) plane not
overlap?
If all 5 tests fail we quickly check to see if switching P
and Q will work.
21/09/2018 CG by Rohit Jasudkar 35
21/09/2018 CG by Rohit Jasudkar 36
21/09/2018 CG by Rohit Jasudkar 37
21/09/2018 CG by Rohit Jasudkar 38
21/09/2018 CG by Rohit Jasudkar 39
21/09/2018 CG by Rohit Jasudkar 40
21/09/2018 CG by Rohit Jasudkar 41
Backface Removal Algorithm
21/09/2018 CG by Rohit Jasudkar 42
N = Normal Vector of surface plane (N1 and N2)
V = Viewing direction
N1
N 2
21/09/2018 CG by Rohit Jasudkar 43
if N.V > 0
it is back-face of object from viewing
direction
if N.V < 0
it is front face of object from viewing
direction
Example:
• N1.V < 0 Therefore N1 plane is front face (Visible)
• N2.V > 0 Therefore N2 plane is back face (Invisible)
Curves and surfaces
• A line which is not straight with no sharp
edges is called a curve.
• It is a smoothly flowing line.
21/09/2018 CG by Rohit Jasudkar 44
Interpolation vs. Approximation
• Interpolation
– Goes through all specified points
– Sounds more logical
– Ex. Lagrange’s, Hermite Interpolation Curve
• Approximation
– Does not go through all points
– Here p1, p2, p3, p4 are control points
– Ex. Bezier , B-spline Approximation Curve
21/09/2018 CG by Rohit Jasudkar 45
Bezier Curves
• Bezier curve is discovered by the French
engineer Pierre Bézier.
• These curves can be generated under the
control of other points.
• It has global control.
• Approximate tangents by using control points
are used to generate curve.
21/09/2018 CG by Rohit Jasudkar 46
Cubic Bezier Curve
• The degree of the polynomial defining the curve
segment is one less that the number of defining
polygon point. Therefore, for 4 control points, the
degree of the polynomial is 3, i.e. cubic polynomial.
21/09/2018 CG by Rohit Jasudkar 47
21/09/2018 CG by Rohit Jasudkar 48
|
|
|
t = 0.25
t = 0.5
t = 0.75
21/09/2018 CG by Rohit Jasudkar 49
21/09/2018 CG by Rohit Jasudkar 50
B-spline Curve
21/09/2018 CG by Rohit Jasudkar 51
• P0, P1, P2, P3 are the control points.
• X0, X1, X2, X3 are the knot values.
• Q0, Q1, Q2 are the segments of the curve.
To design a B - spline curve, we need a set of control points, a set
of knots and a order of curve(k).
• B-Spline curve uses (n+1) control points
as P0, P1,…….,Pn.
• Order of Curve (k) means, k points
generate a segment.
2 <= k < n+1
• In e.g. k = 2 means that two point P0, P1
generate the segment Q0.
• Degree of polynomial (k - 1)is depends on
order of curve.
• For e.g. if k=3 degree of polynomial=2
21/09/2018 CG by Rohit Jasudkar 52
• It has local control over the curve.
21/09/2018 CG by Rohit Jasudkar 53
• Number of segment = n – k + 2
• A B-spline curve is defined as a linear combination of
control points Pi and B-spline basis function Ni, k (t)
given by
• Where,
• {pi: i=0, 1, 2….n} are the control points
• k is the order of the polynomial segments of the B-
spline curve. Order k means that the curve is made up
of piecewise polynomial segments of degree k - 1,
• the Ni,k(t) are the “normalized B-spline blending
functions”. They are described by the order k.
21/09/2018 CG by Rohit Jasudkar 54
• B- Spline Curve allows us to change the
number of control points without
changing the degree of polynomial.
• As degree of polynomial is depends on
order of curve (k)
21/09/2018 CG by Rohit Jasudkar 55
Surface Rendering methods
• 3-D image creation phases
– Tessellation.
– Geometry.
– Rendering.
• Shading
21/09/2018 CG by Rohit Jasudkar 56
What Causes Shading?
• Shading caused by different angles
with light, camera at different points
21/09/2018 CG by Rohit Jasudkar 57
• The ray is reflected from the object.
• (If the surface is a transparent surface,
the ray is refracted as well as reflected.)
21/09/2018 CG by Rohit Jasudkar 58
Two types of reflection
• a. Specular/ Regular reflection
• b. Diffused/ Irregular reflection
21/09/2018 CG by Rohit Jasudkar 59
Illumination model
21/09/2018 CG by Rohit Jasudkar 60
21/09/2018 CG by Rohit Jasudkar 61
Constant Intensity / Flat Shading
• Simplest shading algorithm.
• Using an illumination model to determine
the corresponding intensity value for the
incident light.
• Then shade the entire polygon according
to this value.
21/09/2018 CG by Rohit Jasudkar 62
• Each entire polygon is drawn with the
same colour
• Need to know one normal for the entire
polygon
• It is fast shading method
• Lighting equation used once per polygon
21/09/2018 CG by Rohit Jasudkar 63
Gouraurd Shading
• Developed in the 1970s by Henri Gouraud.
• It is the interpolation technique.
• Intensity levels are calculated at each vertex
and interpolated across the surface.
• Intensity values for each polygon are matched
with the values of adjacent polygons along the
common edges.
• This eliminates the intensity discontinuities
that can occur in flat shading.
21/09/2018 CG by Rohit Jasudkar 64
• To render a polygon, Gouraud surface
rendering proceeds as follows:
– Determine the average unit normal vector at each
vertex of the polygon.
– Apply an illumination model at each polygon
vertex to obtain the light intensity at that position.
– Linearly interpolate the vertex intensities over the
projected area of the polygon
21/09/2018 CG by Rohit Jasudkar 65
• The average unit normal vector at V is
given as:
21/09/2018 CG by Rohit Jasudkar 66
• Illumination values are linearly
interpolated across each scan-line as
shown in figure
21/09/2018 CG by Rohit Jasudkar 67
Phong Shading
• A more accurate interpolation based approach for
rendering a polygon was developed by Phong Bui
Tuong.
• Also called as normal-vector interpolation
rendering.
• It interpolates normal vectors instead of intensity
values.
• It requires more calculations and greatly increases
the cost of shading steeply.
21/09/2018 CG by Rohit Jasudkar 68
• To render a polygon, Phong surface rendering
proceeds as follows:
– Determine the average unit normal vector at each
vertex of the polygon.
– Linearly interpolate the vertex normal over the
projected area of the polygon.
– Apply an illumination model at positions along scan
lines to calculate pixel intensities using the interpolated
normal vectors as shown in figure
21/09/2018 CG by Rohit Jasudkar 69
21/09/2018 CG by Rohit Jasudkar 70
21/09/2018 CG by Rohit Jasudkar 71
Any Questions???
21/09/2018 CG by Rohit Jasudkar 72
Thank You…
21/09/2018 CG by Rohit Jasudkar 73

More Related Content

What's hot (20)

PPTX
3D transformation in computer graphics
SHIVANI SONI
 
PPT
Computer graphics iv unit
aravindangc
 
PPTX
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
 
PDF
Lecture 4 Relationship between pixels
VARUN KUMAR
 
PPTX
Computer Graphics: Visible surface detection methods
Joseph Charles
 
PPTX
Shading methods
Rakesh Pandey
 
PPTX
Dda algorithm
Mani Kanth
 
PPTX
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
DOCX
Bezier Curve in Computer Graphics.docx
bcanawakadalcollege
 
PPTX
CRT (Cathode ray tube)
Imran Hossain
 
PDF
Computer graphics curves and surfaces (1)
RohitK71
 
PPT
Visible surface detection in computer graphic
anku2266
 
PPTX
Projection In Computer Graphics
Sanu Philip
 
PPT
Clipping
Mohd Arif
 
PPT
2D transformation (Computer Graphics)
Timbal Mayank
 
PPTX
Image Filtering in the Frequency Domain
Amnaakhaan
 
PPT
Video display devices
Mohd Arif
 
PPTX
Clipping in Computer Graphics
Laxman Puri
 
PPTX
Hough Transform By Md.Nazmul Islam
Nazmul Islam
 
PPTX
Mid point circle algorithm
Mani Kanth
 
3D transformation in computer graphics
SHIVANI SONI
 
Computer graphics iv unit
aravindangc
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
 
Lecture 4 Relationship between pixels
VARUN KUMAR
 
Computer Graphics: Visible surface detection methods
Joseph Charles
 
Shading methods
Rakesh Pandey
 
Dda algorithm
Mani Kanth
 
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
Bezier Curve in Computer Graphics.docx
bcanawakadalcollege
 
CRT (Cathode ray tube)
Imran Hossain
 
Computer graphics curves and surfaces (1)
RohitK71
 
Visible surface detection in computer graphic
anku2266
 
Projection In Computer Graphics
Sanu Philip
 
Clipping
Mohd Arif
 
2D transformation (Computer Graphics)
Timbal Mayank
 
Image Filtering in the Frequency Domain
Amnaakhaan
 
Video display devices
Mohd Arif
 
Clipping in Computer Graphics
Laxman Puri
 
Hough Transform By Md.Nazmul Islam
Nazmul Islam
 
Mid point circle algorithm
Mani Kanth
 

Similar to Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Surface Rendering Methods) (20)

PPT
Implementation
Syed Zaid Irshad
 
PPTX
UNIT 2hidden surface elimination in graphics.pptx
Vinod Deenathayalan
 
PPTX
Computer Graphics - Hidden Line Removal Algorithm
Jyotiraman De
 
PPT
hidden surface removal in computer graphics
srinivasan779644
 
PPT
2IV60_11_hidden_surfaces (6).ppt
ssuser024cb2
 
PPTX
Hidden surface removal algorithm
KKARUNKARTHIK
 
PPTX
Hidden surface removal
Punyajoy Saha
 
PPTX
Computer Graphics Unit 1
aravindangc
 
PPTX
visual realism Unit iii
Arun Prakash
 
PDF
Unit 3 visual realism
Javith Saleem
 
DOCX
Computer graphics question for exam solved
Kuntal Bhowmick
 
PDF
Hidden_surfaces.pdf
Mattupallipardhu
 
PPTX
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
PPT
visible surface detection
Balakumaran Arunachalam
 
PPT
Angel6E25educationmaterial for reference
kanchang3684
 
PPT
october9.ppt
CharlesMatu2
 
PDF
Hidden Surface Removal using Z-buffer
Raj Sikarwar
 
PPT
Unit-2 PPT.ppt
GopalaKrishnanChandr7
 
Implementation
Syed Zaid Irshad
 
UNIT 2hidden surface elimination in graphics.pptx
Vinod Deenathayalan
 
Computer Graphics - Hidden Line Removal Algorithm
Jyotiraman De
 
hidden surface removal in computer graphics
srinivasan779644
 
2IV60_11_hidden_surfaces (6).ppt
ssuser024cb2
 
Hidden surface removal algorithm
KKARUNKARTHIK
 
Hidden surface removal
Punyajoy Saha
 
Computer Graphics Unit 1
aravindangc
 
visual realism Unit iii
Arun Prakash
 
Unit 3 visual realism
Javith Saleem
 
Computer graphics question for exam solved
Kuntal Bhowmick
 
Hidden_surfaces.pdf
Mattupallipardhu
 
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
visible surface detection
Balakumaran Arunachalam
 
Angel6E25educationmaterial for reference
kanchang3684
 
october9.ppt
CharlesMatu2
 
Hidden Surface Removal using Z-buffer
Raj Sikarwar
 
Unit-2 PPT.ppt
GopalaKrishnanChandr7
 
Ad

Recently uploaded (20)

PPTX
Structural Functiona theory this important for the theorist
cagumaydanny26
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PPTX
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PPT
inherently safer design for engineering.ppt
DhavalShah616893
 
PPTX
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
PDF
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
PDF
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
PPTX
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PPTX
drones for disaster prevention response.pptx
NawrasShatnawi1
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
PDF
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
Structural Functiona theory this important for the theorist
cagumaydanny26
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
inherently safer design for engineering.ppt
DhavalShah616893
 
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
site survey architecture student B.arch.
sri02032006
 
drones for disaster prevention response.pptx
NawrasShatnawi1
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
Ad

Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Surface Rendering Methods)

  • 1. CG by Rohit Jasudkar 1 Computer Graphics 21/09/2018 Hidden surfaces and line removal Curves and surfaces Surface Rendering methods
  • 2. Contents  Hidden surfaces and line removal • Z buffer Algorithm • Warnock’s Algorithm • Painter’s Algorithm • Backface Removal Algorithm  Curves and surfaces • Bezier Curve • B-splines Curve  Surface Rendering Methods • Constant Intensity / Flat Shading • Gouraurd Shading • Phong Shading 21/09/2018 CG by Rohit Jasudkar 2
  • 3. Hidden surfaces and line removal 21/09/2018 CG by Rohit Jasudkar 3 Overlapping Surfaces Intersecting Surfaces
  • 4. 21/09/2018 CG by Rohit Jasudkar 4 Back faced Surfaces Occluded Surfaces
  • 5. Hidden Surface Problem • When we view a picture containing non transparent objects and surfaces, then we can’t see those objects from view which are behind from the objects closer to eye. • We must remove these hidden surfaces to get realistic screen image. • The identification & removal of these surfaces is called the Hidden-surface problem . • Techniques used for solving these problems known as Visible Surface Detection or Hidden Surface Removal. 21/09/2018 CG by Rohit Jasudkar 5
  • 6. 21/09/2018 CG by Rohit Jasudkar 6
  • 7. Classification of Visible Surface Detection 1. Object space methods 2. Image space methods 21/09/2018 CG by Rohit Jasudkar 7
  • 8. Object space methods • Methods based on comparison of objects for their 3D positions and dimensions with respect to a viewing position. • Efficient for small number of objects but difficult to implement. • Depth sorting (Painter Algorithm) , area subdivision methods (Warnock’s Algorithm). 21/09/2018 CG by Rohit Jasudkar 8
  • 9. Image space methods • Based on the pixels to be drawn on 2D. Try to determine which object should contribute to that pixel. • Running time complexity is the number of pixels times number of objects. • Space complexity is two times the number of pixels: – One array of pixels for the frame buffer – One array of pixels for the depth buffer • Depth-buffer (Z-Buffer) and ray casting methods. 21/09/2018 CG by Rohit Jasudkar 9
  • 10. Z buffer Algorithm • Also known as depth -Buffer method. • Proposed by Mr. Edwin Catmull in 1975 • Z-buffer is like a frame buffer, contain depths 21/09/2018 CG by Rohit Jasudkar 10
  • 11. Basic Z-buffer idea: • Rasterize every input polygon • For every pixel in the polygon interior, calculate its corresponding z value. • Track depth values of closest polygon (smallest z) so far • Update the pixel values with the color of the polygon whose z value is the closest to the eye. 21/09/2018 CG by Rohit Jasudkar 11
  • 12. • Two buffers are used – Frame Buffer (Store Background intensity or Shades) – Depth Buffer (Store depth (Z) value of every visible pixel in image space) • The z-coordinates (depth values) are usually normalized to the range [0,1] 21/09/2018 CG by Rohit Jasudkar 12
  • 13. Z – Buffer Algorithm • Initialize the depth buffer and frame buffer so that for all buffer positions (x ,y ), depthBuff (x,y) = 1.0, frameBuff (x,y) = bgColor • Process each polygon in a scene, one at a time – For each projected (x ,y ) pixel position of a polygon, calculate the depth z . – If z < depthBuff (x,y), compute the surface color at that position and set – depthBuff (x,y) = z, frameBuff (x,y) = surfCol (x,y) 21/09/2018 CG by Rohit Jasudkar 13
  • 14. Calculating depth values (z) 21/09/2018 CG by Rohit Jasudkar 14 0, )( 0     C C DByAx z DCzByAx Using the polygon surface equation:
  • 15. 21/09/2018 CG by Rohit Jasudkar 15
  • 16. 21/09/2018 CG by Rohit Jasudkar 16
  • 17. 21/09/2018 CG by Rohit Jasudkar 17
  • 18. 21/09/2018 CG by Rohit Jasudkar 18
  • 19. Advantages • No Sorting of polygons required. • No Object to Object Comparison. • Can be applied to non polygonal object. • Simple to use. • Computing the required depth values is simple. 21/09/2018 CG by Rohit Jasudkar 19
  • 20. Disadvantages • Requires two buffer which makes is expensive. • The required z-precision is maintained at a higher resolution as compared to x,y precision. • High memory requirements. 21/09/2018 CG by Rohit Jasudkar 20
  • 21. Warnock’s Algorithm • Developed by John Warnocks. • Based on the hypothesis of how human eye , brain combination processes the information present in a scene. • Divide-and-conquer strategy: spatial partitioning in the projection plane • An area of the projection plane is examined • If all polygons visible in that area can be easily decided, they are displayed • Otherwise, it is recursively decided 21/09/2018 CG by Rohit Jasudkar 21
  • 22. 21/09/2018 CG by Rohit Jasudkar 22
  • 23. 21/09/2018 CG by Rohit Jasudkar 23
  • 24. 21/09/2018 CG by Rohit Jasudkar 24
  • 25. 21/09/2018 CG by Rohit Jasudkar 25
  • 26. At each stage, the projection of each polygon has one of four relationships to the area of interest (Window) • Surrounding polygons completely contain the area of interest • Intersecting polygons intersect the area of interest • Contained polygons are completely inside the area • Disjoint polygons are completely outside the area 21/09/2018 CG by Rohit Jasudkar 26
  • 27. For each window • Disjoint polygons, the window is empty therefore displayed with background intesity. • Intersecting polygons can be split into disjoint and contained polygons. • If there is only one contained polygon, fill area with background, then scan-fill polygon area. • If there is a single surrounding polygon, and no intersecting or contained polygons, display the surrounding polygons color. • There are more than one surrounding polygon in window, front of all other polygons display the surrounding polygon color in the area. • Otherwise subdivide the window. 21/09/2018 CG by Rohit Jasudkar 27
  • 28. Painter’s Algorithm 21/09/2018 CG by Rohit Jasudkar 28 How painter paints objects in the scene? • Draw objects from back to front • The new object paint will hide the old object paint. • It require depth comparisons.
  • 29. • Also known as Depth sort Algorithm or Priority Algorithm. • Two Basic functions: 1. Sort the polygons according to the farthest Z coordinate 2. Scan convert each polygon in ascending order of farthest z coordinate (back-to-front) 21/09/2018 CG by Rohit Jasudkar 29
  • 30. • Simple algorithm: – Sort all polygons based on their farthest z coordinate – Resolve ambiguities (if overlapping of objects occurs) – Draw the polygons in order from back to front • This algorithm would be very simple if the z coordinates of the polygons were guaranteed never to overlap. Unfortunately that is usually not the case, which means that step 2 can be somewhat complex. 21/09/2018 CG by Rohit Jasudkar 30
  • 31. 21/09/2018 CG by Rohit Jasudkar 31 Z min
  • 32. 21/09/2018 CG by Rohit Jasudkar 32
  • 33. Overlapping Problem 21/09/2018 CG by Rohit Jasudkar 33
  • 34. • All polygons whose z extents overlap must be tested against each other. • We start with the furthest polygon and call it P. Polygon P must be compared with every polygon Q whose z extent overlaps P's z extent. 5 comparisons are made. If any comparison is true then P can be written before Q. 21/09/2018 CG by Rohit Jasudkar 34
  • 35. Test Cases • 1. Do P and Q's x-extents not overlap? • 2. Do P and Q's y-extents not overlap? • 3. Is P entirely on the opposite side of Q's plane from the viewport? • 4. Is Q entirely on the same side of P's plane as the viewport? • 5. Do the projections of P and Q onto the (x,y) plane not overlap? If all 5 tests fail we quickly check to see if switching P and Q will work. 21/09/2018 CG by Rohit Jasudkar 35
  • 36. 21/09/2018 CG by Rohit Jasudkar 36
  • 37. 21/09/2018 CG by Rohit Jasudkar 37
  • 38. 21/09/2018 CG by Rohit Jasudkar 38
  • 39. 21/09/2018 CG by Rohit Jasudkar 39
  • 40. 21/09/2018 CG by Rohit Jasudkar 40
  • 41. 21/09/2018 CG by Rohit Jasudkar 41
  • 42. Backface Removal Algorithm 21/09/2018 CG by Rohit Jasudkar 42 N = Normal Vector of surface plane (N1 and N2) V = Viewing direction N1 N 2
  • 43. 21/09/2018 CG by Rohit Jasudkar 43 if N.V > 0 it is back-face of object from viewing direction if N.V < 0 it is front face of object from viewing direction Example: • N1.V < 0 Therefore N1 plane is front face (Visible) • N2.V > 0 Therefore N2 plane is back face (Invisible)
  • 44. Curves and surfaces • A line which is not straight with no sharp edges is called a curve. • It is a smoothly flowing line. 21/09/2018 CG by Rohit Jasudkar 44
  • 45. Interpolation vs. Approximation • Interpolation – Goes through all specified points – Sounds more logical – Ex. Lagrange’s, Hermite Interpolation Curve • Approximation – Does not go through all points – Here p1, p2, p3, p4 are control points – Ex. Bezier , B-spline Approximation Curve 21/09/2018 CG by Rohit Jasudkar 45
  • 46. Bezier Curves • Bezier curve is discovered by the French engineer Pierre Bézier. • These curves can be generated under the control of other points. • It has global control. • Approximate tangents by using control points are used to generate curve. 21/09/2018 CG by Rohit Jasudkar 46
  • 47. Cubic Bezier Curve • The degree of the polynomial defining the curve segment is one less that the number of defining polygon point. Therefore, for 4 control points, the degree of the polynomial is 3, i.e. cubic polynomial. 21/09/2018 CG by Rohit Jasudkar 47
  • 48. 21/09/2018 CG by Rohit Jasudkar 48 | | | t = 0.25 t = 0.5 t = 0.75
  • 49. 21/09/2018 CG by Rohit Jasudkar 49
  • 50. 21/09/2018 CG by Rohit Jasudkar 50
  • 51. B-spline Curve 21/09/2018 CG by Rohit Jasudkar 51 • P0, P1, P2, P3 are the control points. • X0, X1, X2, X3 are the knot values. • Q0, Q1, Q2 are the segments of the curve. To design a B - spline curve, we need a set of control points, a set of knots and a order of curve(k).
  • 52. • B-Spline curve uses (n+1) control points as P0, P1,…….,Pn. • Order of Curve (k) means, k points generate a segment. 2 <= k < n+1 • In e.g. k = 2 means that two point P0, P1 generate the segment Q0. • Degree of polynomial (k - 1)is depends on order of curve. • For e.g. if k=3 degree of polynomial=2 21/09/2018 CG by Rohit Jasudkar 52
  • 53. • It has local control over the curve. 21/09/2018 CG by Rohit Jasudkar 53
  • 54. • Number of segment = n – k + 2 • A B-spline curve is defined as a linear combination of control points Pi and B-spline basis function Ni, k (t) given by • Where, • {pi: i=0, 1, 2….n} are the control points • k is the order of the polynomial segments of the B- spline curve. Order k means that the curve is made up of piecewise polynomial segments of degree k - 1, • the Ni,k(t) are the “normalized B-spline blending functions”. They are described by the order k. 21/09/2018 CG by Rohit Jasudkar 54
  • 55. • B- Spline Curve allows us to change the number of control points without changing the degree of polynomial. • As degree of polynomial is depends on order of curve (k) 21/09/2018 CG by Rohit Jasudkar 55
  • 56. Surface Rendering methods • 3-D image creation phases – Tessellation. – Geometry. – Rendering. • Shading 21/09/2018 CG by Rohit Jasudkar 56
  • 57. What Causes Shading? • Shading caused by different angles with light, camera at different points 21/09/2018 CG by Rohit Jasudkar 57
  • 58. • The ray is reflected from the object. • (If the surface is a transparent surface, the ray is refracted as well as reflected.) 21/09/2018 CG by Rohit Jasudkar 58
  • 59. Two types of reflection • a. Specular/ Regular reflection • b. Diffused/ Irregular reflection 21/09/2018 CG by Rohit Jasudkar 59
  • 60. Illumination model 21/09/2018 CG by Rohit Jasudkar 60
  • 61. 21/09/2018 CG by Rohit Jasudkar 61
  • 62. Constant Intensity / Flat Shading • Simplest shading algorithm. • Using an illumination model to determine the corresponding intensity value for the incident light. • Then shade the entire polygon according to this value. 21/09/2018 CG by Rohit Jasudkar 62
  • 63. • Each entire polygon is drawn with the same colour • Need to know one normal for the entire polygon • It is fast shading method • Lighting equation used once per polygon 21/09/2018 CG by Rohit Jasudkar 63
  • 64. Gouraurd Shading • Developed in the 1970s by Henri Gouraud. • It is the interpolation technique. • Intensity levels are calculated at each vertex and interpolated across the surface. • Intensity values for each polygon are matched with the values of adjacent polygons along the common edges. • This eliminates the intensity discontinuities that can occur in flat shading. 21/09/2018 CG by Rohit Jasudkar 64
  • 65. • To render a polygon, Gouraud surface rendering proceeds as follows: – Determine the average unit normal vector at each vertex of the polygon. – Apply an illumination model at each polygon vertex to obtain the light intensity at that position. – Linearly interpolate the vertex intensities over the projected area of the polygon 21/09/2018 CG by Rohit Jasudkar 65
  • 66. • The average unit normal vector at V is given as: 21/09/2018 CG by Rohit Jasudkar 66
  • 67. • Illumination values are linearly interpolated across each scan-line as shown in figure 21/09/2018 CG by Rohit Jasudkar 67
  • 68. Phong Shading • A more accurate interpolation based approach for rendering a polygon was developed by Phong Bui Tuong. • Also called as normal-vector interpolation rendering. • It interpolates normal vectors instead of intensity values. • It requires more calculations and greatly increases the cost of shading steeply. 21/09/2018 CG by Rohit Jasudkar 68
  • 69. • To render a polygon, Phong surface rendering proceeds as follows: – Determine the average unit normal vector at each vertex of the polygon. – Linearly interpolate the vertex normal over the projected area of the polygon. – Apply an illumination model at positions along scan lines to calculate pixel intensities using the interpolated normal vectors as shown in figure 21/09/2018 CG by Rohit Jasudkar 69
  • 70. 21/09/2018 CG by Rohit Jasudkar 70
  • 71. 21/09/2018 CG by Rohit Jasudkar 71
  • 72. Any Questions??? 21/09/2018 CG by Rohit Jasudkar 72
  • 73. Thank You… 21/09/2018 CG by Rohit Jasudkar 73