SlideShare a Scribd company logo
3
Most read
8
Most read
11
Most read
Shading “  Shading is referred as  the  implementation of illumination model   at the pixel points  or  polygon surfaces of the graphics objects .”
Constant-Intensity Shading A fast and simple method for rendering an object with polygon surfaces is constant intensity shading, also called flat shading. In this method, a single intensity is calculated for each polygon. All points over the surface of the polygon are then displayed with the same intensity value. Constant shading can be useful for quickly displaying the general appearance of a curved surface, as in Fig(1). Fig(1). A polygon mesh approximation of an object (a) is rendered with flat shading (b) and With Gouraud shading  (c).
In general, flat shading of polygon facets provides an accurate rendering for   an object if all of the following assumptions are valid: - The object is a polyhedron and is not an approximation of an object with a curved surface. All light sources illuminating the objects are sufficiently far from the surface so that N . L and the attenuation function are constant over the surface(where N is the unit normal to a surface and L is the unit direction vector to the point light source from a position on the surface). The viewing position is sufficiently far from the surface so that V . R is constant over the surface.(where V is the unit vector pointing to the viewer from the surface position and R represent unit vector in the direction of ideal specular reflection).
Gouraud Shading This intensity-interpolation scheme, developed by Gouraud and generally referred to as Gouraud shading, renders a polygon surface by linearly interpolating intensity values across the surface. Intensity values for each polygon are matched with the values of adjacent polygons along the common edges, thus eliminating the intensity discontinuities that can occur in flat shading. Each polygon surface is rendered with Gouraud shading by performing the following calculations: Determine the average unit normal vector at each polygon vertex. Apply an illumination model to each vertex to calculate the vertex intensity. Linearly interpolate the vertex intensities over the surface of the polygon.
At each polygon vertex, we obtain a normal vector by averaging the surface normals of all polygons starting  that vertex, as illustrated in Fig.(2).  Thus, for any vertex position V, we obtain the unit vertex normal with the calculation Once we have the vertex normals, we can determine the intensity at the vertices from a lighting model. Figure (2). The normal vector at vertex V is calculated as the average of the surface normals for each polygon  sharing that vertex. N 1 N 2 N 3 N 4 V
Following Figure(3)demonstrates the next step: interpolating intensities along the polygon edges. For each scan line, the intensity at the intersection of the scan line with a polygon edge is linearly interpolated from the intensities at the edge endpoints. For the example in Fig.(3), the polygon edge with endpoint vertices at positions 1 and 2 is intersected by the scan line at point 4. A fast method for obtaining the intensity at point 4 is to interpolate between intensities I 1 , and I 2  using only the vertical displacement of the scan line: 3 Y X Scan Line 5 2 4 1 Fig(3). For Gouraud shading, the intensity at point 4 is linearly interpolated from the intensities at vertices 1 and2. The intensity at point 5 is linearly interpolated from intensities at vertices 2 and 3. An interior point p is then assigned an intensity value that is linearly interpolated from intensities at positions 4 and 5. P
Similarly, intensity at the right intersection of this scan line (point 5) is interpolated from intensity values at vertices 2 and 3. Once these bounding intensities are established for a scan line, an interior point (such as point P in Previous Fig(3)) is interpolated from the bounding intensities at points 4 and 5 as I 1 +  I 2 I 4 =  y 4 -y 2 y 1 -y 2 y 1 -y 4 y 1 -y 2 I 4 +  I 5 I P =  X 5 - X P X 5 - X 4 X P - X 4 X 5 - X 4
Incremental calculations are used to obtain successive edge intensity values between scan lines and to obtain successive intensities along a scan line. As shown in following Fig.(4),  3 Y X Scan Lines I 2 I 1 Y-1 I’ I X X+1 Fig.(4) Incremental interpolation  of intensity values along a polygon edge for successive scan lines.
+  I 2 I =  Y - Y 2 Y 1 - Y 2 Y 1 - Y Y 1 - Y 2 I 1 then we can obtain the intensity along this edge for the next scan line, y - I, as I’=I+ Y 1 - Y 2 I 2 - I 1 if the intensity at edge position (x,y) is interpolated as
Similar calculations are used to obtain intensities at successive horizontal pixel positions along each scan line.  When surfaces are to be rendered in color, the intensity of each color component is calculated at the vertices. Gouraud shading can be combined with a hidden-surface algorithm to fill in the visible polygons along each scan line. An example of an object shaded with the Gouraud method appears in following Fig. A polygon mesh approximation of an object (a) is rendered with flat shading (b) and With Gouraud shading  (c).
Gouraud shading removes the intensity discontinuities associated with the constant-shading model, but it has some other deficiencies. Highlights on the surface are sometimes displayed with anomalous shapes, and the linear intensity interpolation can cause bright or dark intensity streaks, called Mach bands, to appear on the surface. These effects can be reduced by dividing the surface into a greater number of polygon faces or by using other methods, such as Phong shading, that require more calculations.
Phong Shading A more accurate method for rendering a polygon surface is to interpolate normal  vectors, and then apply the illumination model to each surface point. This method, developed by Phong Bui Tuong, is called Phong shading, or normal vector interpolation shading. It displays more realistic highlights on a surface and greatly reduces the Mach-band effect. A polygon surface is rendered using Phong shading by carrying out the following  steps: Determine the average unit normal vector at each polygon vertex. Linearly & interpolate the vertex normals over the surface of the polygon. Apply an illumination model along each scan line to calculate projected pixel intensities for the surface points.
Interpolation of surface normals along a polygon edge between two vertices is illustrated in Fig.(5). The normal vector N for the scan-line intersection point along the edge between vertices 1 and 2 can be obtained by vertically interpolating between edge endpoint normals: Scan Line N  N  1 N  3 N  2 Fig.(5)  Interpolation of surface normals Along a polygon edge. N 1 +  N 2 N=  Y - Y 2 Y 1 - Y 2 Y 1 - Y Y 1 - Y 2
Incremental methods are used to evaluate normals between scan lines and along each individual scan line. At each pixel position along a scan line, the illumination model is applied to determine the surface intensity at that point.  Intensity calculations using an approximated normal vector at each point along the scan line produce more accurate results than the direct interpolation of intensities, as in Gouraud shading. The trade-off, however, is that Phong shading requires considerably more calculations.
Fast Phong Shading Surface rendering with Phong shading can be speeded up by using approximations in the illumination-model calculations of normal vectors. Fast Phong shading approximates the intensity calculations using a Taylor-series expansion and triangular surface patches.  Since Phong shading interpolates normal vectors from vertex normals, we can express the surface normal N at any point (x, y) over a triangle as N=Ax+By+C where vectors A, B, and C are determined from the three vertex equations: N k =Ax k +By k +C, k=1,2,3 with (x k ,y k ) denoting a vector position.
Omitting the reflectivity and attenuation parameters, we can write the calculation for light-source diffuse reflection from a surface point (x, y) as L.N |L||N| L.(Ax+By+C) |L||Ax+By+C|   (L.A)x+(L.B)y+(L.C) |L||Ax+By+C| I diff (x,y)=  = =
We can rewrite this expression in the form    ax+by+c   (dx 2 +exy+fy 2 +gx+hy+i) 1/2 eq(1) where parameters such as a, b, c, and d are used to represent the various dot products. For example   L.A |L| Finally, we can express the denominator in Eq. (1) as a Taylor-series expansion  and retain terms up to second degree in x and y. This yields T 5 x 2 +T 4 xy+T 3 y 2 +T 2 x+T 1 y+T 0  eq(2) where each T k , is a function of parameters a, b, c, and so forth. I diff (x,y)=  a= I diff (x,y)=
Using forward differences, we can evaluate Eq. (2) with only two additions for each pixel position (x, y) once the initial forward-difference parameters have been evaluated. Although fast Phong shading reduces the Phong-shading calculations, it still takes approximately twice as long to render a surface with fast Phong shading as it does with Gouraud shading. Normal Phong shading using forward differences takes about six to seven times longer than Gouraud shading. Fast Phong shading for diffuse reflection can be extended to include specular reflections. Calculations similar to those for diffuse reflections are used to evaluate specular terms such as (N.H) ns  in the basic illumination model. In addition, we can generalize the algorithm to include polygons other than triangles and finite viewing positions.

More Related Content

PPT
Image Texture Analysis
PPTX
Computer Graphics
PPTX
Computer graphics ppt
PPTX
Polygon filling algorithm
PPT
2D transformation (Computer Graphics)
PPTX
Segments in Graphics
PPTX
Problem solving in Artificial Intelligence.pptx
Image Texture Analysis
Computer Graphics
Computer graphics ppt
Polygon filling algorithm
2D transformation (Computer Graphics)
Segments in Graphics
Problem solving in Artificial Intelligence.pptx

What's hot (20)

PPTX
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
PPTX
Bezeir curve na B spline Curve
PPTX
Character generation techniques
PPTX
Anti- aliasing computer graphics
PPTX
Output primitives in Computer Graphics
PPT
Visible surface detection in computer graphic
PPTX
Parallel projection
PDF
Unit 3
PPT
Raster scan system
PPTX
Cyrus beck line clipping algorithm
PPT
Composite transformations
PPTX
Frame buffer
PPTX
The sutherland hodgeman polygon clipping algorithm
PPTX
Cohen sutherland line clipping
PPTX
Video display devices
PPTX
3 d display methods
PPT
Hidden surfaces
PPTX
Spline representations
PPTX
Concept of basic illumination model
PPTX
Raster animation
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Bezeir curve na B spline Curve
Character generation techniques
Anti- aliasing computer graphics
Output primitives in Computer Graphics
Visible surface detection in computer graphic
Parallel projection
Unit 3
Raster scan system
Cyrus beck line clipping algorithm
Composite transformations
Frame buffer
The sutherland hodgeman polygon clipping algorithm
Cohen sutherland line clipping
Video display devices
3 d display methods
Hidden surfaces
Spline representations
Concept of basic illumination model
Raster animation
Ad

Viewers also liked (16)

PPT
Illumination model
PPTX
Ray tracing
PPTX
3D Graphics & Rendering in Computer Graphics
PDF
Phong Shading over any Polygonal Surface
PPT
Shading and two type of shading flat shading and gauraud shading with coding ...
PPTX
Illumination Model
PPT
GRPHICS06 - Shading
PPTX
Geometric modelling
PDF
191483523 geometric-modeling
PDF
5 geometric-modeling-ppt-university-of-victoria
PPTX
Parametric modelling
PPT
Geometric Modeling
PPT
Geometric modeling111431635 geometric-modeling-glad (1)
PPTX
Computer Graphics - Hidden Line Removal Algorithm
PPTX
ILLUMINATION & LIGHTING
PPTX
Color Models
Illumination model
Ray tracing
3D Graphics & Rendering in Computer Graphics
Phong Shading over any Polygonal Surface
Shading and two type of shading flat shading and gauraud shading with coding ...
Illumination Model
GRPHICS06 - Shading
Geometric modelling
191483523 geometric-modeling
5 geometric-modeling-ppt-university-of-victoria
Parametric modelling
Geometric Modeling
Geometric modeling111431635 geometric-modeling-glad (1)
Computer Graphics - Hidden Line Removal Algorithm
ILLUMINATION & LIGHTING
Color Models
Ad

Similar to Shading (20)

PPTX
Shading methods
PPT
Computer Vision: Shape from Specularities and Motion
PDF
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
PPTX
L-5 (Line Drawing Algorithms Computer graphics).pptx
PDF
FACE RECOGNITION ALGORITHM BASED ON ORIENTATION HISTOGRAM OF HOUGH PEAKS
PPTX
Visible surface determination
PDF
Rendering equation
DOCX
Reflection, Scaling, Shear, Translation, and Rotation
PPTX
Module 4-Image segmentation.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaa
PPTX
3rd unit.pptx
PPT
graphics notes
PDF
Lec_3_Image Enhancement_spatial Domain.pdf
PDF
matdid950092.pdf
PPTX
Digital image processing
PPT
3 intensity transformations and spatial filtering slides
PDF
Advanced Approach for Slopes Measurement by Non - Contact Optical Technique
PPT
Multimedia color in image and video
PDF
Visual surface detection computer graphics
Shading methods
Computer Vision: Shape from Specularities and Motion
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
L-5 (Line Drawing Algorithms Computer graphics).pptx
FACE RECOGNITION ALGORITHM BASED ON ORIENTATION HISTOGRAM OF HOUGH PEAKS
Visible surface determination
Rendering equation
Reflection, Scaling, Shear, Translation, and Rotation
Module 4-Image segmentation.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaa
3rd unit.pptx
graphics notes
Lec_3_Image Enhancement_spatial Domain.pdf
matdid950092.pdf
Digital image processing
3 intensity transformations and spatial filtering slides
Advanced Approach for Slopes Measurement by Non - Contact Optical Technique
Multimedia color in image and video
Visual surface detection computer graphics

More from Amit Kapoor (17)

DOCX
Tweening and morphing
DOCX
Study from where
PPT
Projection
DOC
Display devices
DOC
Computer graphics syllabus
DOCX
Cg my own programs
PPTX
Animation
DOCX
3 d modeling of objects
PDF
Essential c
PDF
C aptitude scribd
PDF
C in7-days
DOCX
C interview question answer 2
DOCX
C interview question answer 1
DOCX
C notes mca i sem 2011
DOCX
C tutorials
PPT
User defined data type
PPT
2 d transformations by amit kumar (maimt)
Tweening and morphing
Study from where
Projection
Display devices
Computer graphics syllabus
Cg my own programs
Animation
3 d modeling of objects
Essential c
C aptitude scribd
C in7-days
C interview question answer 2
C interview question answer 1
C notes mca i sem 2011
C tutorials
User defined data type
2 d transformations by amit kumar (maimt)

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf

Shading

  • 1. Shading “ Shading is referred as the implementation of illumination model at the pixel points or polygon surfaces of the graphics objects .”
  • 2. Constant-Intensity Shading A fast and simple method for rendering an object with polygon surfaces is constant intensity shading, also called flat shading. In this method, a single intensity is calculated for each polygon. All points over the surface of the polygon are then displayed with the same intensity value. Constant shading can be useful for quickly displaying the general appearance of a curved surface, as in Fig(1). Fig(1). A polygon mesh approximation of an object (a) is rendered with flat shading (b) and With Gouraud shading (c).
  • 3. In general, flat shading of polygon facets provides an accurate rendering for an object if all of the following assumptions are valid: - The object is a polyhedron and is not an approximation of an object with a curved surface. All light sources illuminating the objects are sufficiently far from the surface so that N . L and the attenuation function are constant over the surface(where N is the unit normal to a surface and L is the unit direction vector to the point light source from a position on the surface). The viewing position is sufficiently far from the surface so that V . R is constant over the surface.(where V is the unit vector pointing to the viewer from the surface position and R represent unit vector in the direction of ideal specular reflection).
  • 4. Gouraud Shading This intensity-interpolation scheme, developed by Gouraud and generally referred to as Gouraud shading, renders a polygon surface by linearly interpolating intensity values across the surface. Intensity values for each polygon are matched with the values of adjacent polygons along the common edges, thus eliminating the intensity discontinuities that can occur in flat shading. Each polygon surface is rendered with Gouraud shading by performing the following calculations: Determine the average unit normal vector at each polygon vertex. Apply an illumination model to each vertex to calculate the vertex intensity. Linearly interpolate the vertex intensities over the surface of the polygon.
  • 5. At each polygon vertex, we obtain a normal vector by averaging the surface normals of all polygons starting that vertex, as illustrated in Fig.(2). Thus, for any vertex position V, we obtain the unit vertex normal with the calculation Once we have the vertex normals, we can determine the intensity at the vertices from a lighting model. Figure (2). The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex. N 1 N 2 N 3 N 4 V
  • 6. Following Figure(3)demonstrates the next step: interpolating intensities along the polygon edges. For each scan line, the intensity at the intersection of the scan line with a polygon edge is linearly interpolated from the intensities at the edge endpoints. For the example in Fig.(3), the polygon edge with endpoint vertices at positions 1 and 2 is intersected by the scan line at point 4. A fast method for obtaining the intensity at point 4 is to interpolate between intensities I 1 , and I 2 using only the vertical displacement of the scan line: 3 Y X Scan Line 5 2 4 1 Fig(3). For Gouraud shading, the intensity at point 4 is linearly interpolated from the intensities at vertices 1 and2. The intensity at point 5 is linearly interpolated from intensities at vertices 2 and 3. An interior point p is then assigned an intensity value that is linearly interpolated from intensities at positions 4 and 5. P
  • 7. Similarly, intensity at the right intersection of this scan line (point 5) is interpolated from intensity values at vertices 2 and 3. Once these bounding intensities are established for a scan line, an interior point (such as point P in Previous Fig(3)) is interpolated from the bounding intensities at points 4 and 5 as I 1 + I 2 I 4 = y 4 -y 2 y 1 -y 2 y 1 -y 4 y 1 -y 2 I 4 + I 5 I P = X 5 - X P X 5 - X 4 X P - X 4 X 5 - X 4
  • 8. Incremental calculations are used to obtain successive edge intensity values between scan lines and to obtain successive intensities along a scan line. As shown in following Fig.(4), 3 Y X Scan Lines I 2 I 1 Y-1 I’ I X X+1 Fig.(4) Incremental interpolation of intensity values along a polygon edge for successive scan lines.
  • 9. + I 2 I = Y - Y 2 Y 1 - Y 2 Y 1 - Y Y 1 - Y 2 I 1 then we can obtain the intensity along this edge for the next scan line, y - I, as I’=I+ Y 1 - Y 2 I 2 - I 1 if the intensity at edge position (x,y) is interpolated as
  • 10. Similar calculations are used to obtain intensities at successive horizontal pixel positions along each scan line. When surfaces are to be rendered in color, the intensity of each color component is calculated at the vertices. Gouraud shading can be combined with a hidden-surface algorithm to fill in the visible polygons along each scan line. An example of an object shaded with the Gouraud method appears in following Fig. A polygon mesh approximation of an object (a) is rendered with flat shading (b) and With Gouraud shading (c).
  • 11. Gouraud shading removes the intensity discontinuities associated with the constant-shading model, but it has some other deficiencies. Highlights on the surface are sometimes displayed with anomalous shapes, and the linear intensity interpolation can cause bright or dark intensity streaks, called Mach bands, to appear on the surface. These effects can be reduced by dividing the surface into a greater number of polygon faces or by using other methods, such as Phong shading, that require more calculations.
  • 12. Phong Shading A more accurate method for rendering a polygon surface is to interpolate normal vectors, and then apply the illumination model to each surface point. This method, developed by Phong Bui Tuong, is called Phong shading, or normal vector interpolation shading. It displays more realistic highlights on a surface and greatly reduces the Mach-band effect. A polygon surface is rendered using Phong shading by carrying out the following steps: Determine the average unit normal vector at each polygon vertex. Linearly & interpolate the vertex normals over the surface of the polygon. Apply an illumination model along each scan line to calculate projected pixel intensities for the surface points.
  • 13. Interpolation of surface normals along a polygon edge between two vertices is illustrated in Fig.(5). The normal vector N for the scan-line intersection point along the edge between vertices 1 and 2 can be obtained by vertically interpolating between edge endpoint normals: Scan Line N N 1 N 3 N 2 Fig.(5) Interpolation of surface normals Along a polygon edge. N 1 + N 2 N= Y - Y 2 Y 1 - Y 2 Y 1 - Y Y 1 - Y 2
  • 14. Incremental methods are used to evaluate normals between scan lines and along each individual scan line. At each pixel position along a scan line, the illumination model is applied to determine the surface intensity at that point. Intensity calculations using an approximated normal vector at each point along the scan line produce more accurate results than the direct interpolation of intensities, as in Gouraud shading. The trade-off, however, is that Phong shading requires considerably more calculations.
  • 15. Fast Phong Shading Surface rendering with Phong shading can be speeded up by using approximations in the illumination-model calculations of normal vectors. Fast Phong shading approximates the intensity calculations using a Taylor-series expansion and triangular surface patches. Since Phong shading interpolates normal vectors from vertex normals, we can express the surface normal N at any point (x, y) over a triangle as N=Ax+By+C where vectors A, B, and C are determined from the three vertex equations: N k =Ax k +By k +C, k=1,2,3 with (x k ,y k ) denoting a vector position.
  • 16. Omitting the reflectivity and attenuation parameters, we can write the calculation for light-source diffuse reflection from a surface point (x, y) as L.N |L||N| L.(Ax+By+C) |L||Ax+By+C| (L.A)x+(L.B)y+(L.C) |L||Ax+By+C| I diff (x,y)= = =
  • 17. We can rewrite this expression in the form ax+by+c (dx 2 +exy+fy 2 +gx+hy+i) 1/2 eq(1) where parameters such as a, b, c, and d are used to represent the various dot products. For example L.A |L| Finally, we can express the denominator in Eq. (1) as a Taylor-series expansion and retain terms up to second degree in x and y. This yields T 5 x 2 +T 4 xy+T 3 y 2 +T 2 x+T 1 y+T 0 eq(2) where each T k , is a function of parameters a, b, c, and so forth. I diff (x,y)= a= I diff (x,y)=
  • 18. Using forward differences, we can evaluate Eq. (2) with only two additions for each pixel position (x, y) once the initial forward-difference parameters have been evaluated. Although fast Phong shading reduces the Phong-shading calculations, it still takes approximately twice as long to render a surface with fast Phong shading as it does with Gouraud shading. Normal Phong shading using forward differences takes about six to seven times longer than Gouraud shading. Fast Phong shading for diffuse reflection can be extended to include specular reflections. Calculations similar to those for diffuse reflections are used to evaluate specular terms such as (N.H) ns in the basic illumination model. In addition, we can generalize the algorithm to include polygons other than triangles and finite viewing positions.