1gr2-00 gr2 advanced computer graphics agr lecture 7 polygon shading techniques
TRANSCRIPT
![Page 1: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/1.jpg)
1GR2-00
GR2Advanced Computer
GraphicsAGR
GR2Advanced Computer
GraphicsAGR
Lecture 7Polygon Shading Techniques
![Page 2: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/2.jpg)
2GR2-00
Reflection ModelsReflection Models
We have seen how the reflected intensity at a point may be calculated– either by the Phong model or the
physically based Cook and Torrance model
A reminder of the Phong reflection model...
![Page 3: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/3.jpg)
3GR2-00
Phong Reflection ModelPhong Reflection Model
lightsourceN
LR
Veye
surface
I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() / dist
In practice, we evaluate IRED, IGREEN, IBLUE for red, green, blue intensities:IRED= Ka
REDIaRED + ( Kd
RED( L . N ) + Ks( R . V )n ) I*RED/dist
Note: R.V calculation replaced by H.N for speed - H = (L+V)/2
dist = distance attenuation factor
![Page 4: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/4.jpg)
4GR2-00
Phong Reflection ModelPhong Reflection Model
Remember calculation depends on:– surface normal at a point– light source intensity and position– material properties– viewer position
L.N and H.N constant if L, V taken to be far away
![Page 5: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/5.jpg)
5GR2-00
Viewing PolygonsViewing Polygons
We have also seen how a 3D polygon can be projected to screen space via a sequence of transformations
This lecture looksat how we shade the polygon, usingour reflection model
![Page 6: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/6.jpg)
6GR2-00
Constant (or Flat) ShadingConstant (or Flat) Shading
Calculate normal (how?)
Assume L.N and R.V constant (light & viewer at infinity)
Calculate IRED, IGREEN, IBLUE using Phong reflection model
Use scan line conversion to fill polygon
N
lightviewer
![Page 7: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/7.jpg)
7GR2-00
2D Graphics - Revision!2D Graphics - Revision!
Scan line methods used to fill 2D polygons with a constant colour– find ymin, ymax of
vertices– from ymin to ymax do:– find intersection with
polygon edges– fill in pixels between
intersections using specified colour
![Page 8: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/8.jpg)
8GR2-00
Polygonal ModelsPolygonal Models
Recall that we use polygonal models to approximate curved surfaces
Constant shading will emphasise this approximation becauseeach facet will be constant shaded, with sudden change fromfacet to facet
![Page 9: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/9.jpg)
9GR2-00
Flat ShadingFlat Shading
![Page 10: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/10.jpg)
10GR2-00
Gouraud ShadingGouraud Shading
Gouraud shading attempts to smooth out the shading across the polygon facets
Begin by calculating the normal at each vertex
N
![Page 11: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/11.jpg)
11GR2-00
Gouraud ShadingGouraud Shading
A feasible way to do this is by averagingaveraging the normals from surrounding facets
Then apply the reflection model to calculate intensitiesintensities at each vertex
N
![Page 12: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/12.jpg)
12GR2-00
Gouraud ShadingGouraud Shading
We use linear linear interpolation interpolation to calculate intensity at edge intersection P
IPRED = (1-IP1
RED + IP2
RED
where P divides P1P2 in the ratio
Similarly for Q
P4
P2
P1
P3
PQ
![Page 13: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/13.jpg)
13GR2-00
Gouraud ShadingGouraud Shading
Then we do further linear interpolation to calculate colour of pixels on scanline PQ
P2
P1
P3
PQ
![Page 14: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/14.jpg)
14GR2-00
Gouraud ShadingGouraud Shading
![Page 15: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/15.jpg)
15GR2-00
Gouraud Shading Limitations - Specular
Highlights
Gouraud Shading Limitations - Specular
Highlights
Gouraud shading gives intensities within a polygon which are a weighted average of the intensities at vertices– a specular highlight at a vertex
tends to be smoothed out over a larger area than it should cover
– a specular highlight in the middle of a polygon will never be shown
![Page 16: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/16.jpg)
16GR2-00
Gouraud Shading Limitations - Mach Bands
Gouraud Shading Limitations - Mach Bands
The rate of change of pixel intensity is even across any polygon, but changes as boundaries are crossed
This ‘discontinuity’ is accentuated by the human visual system, so that we see either light or dark lines at the polygon edges - known as Mach bandingMach banding
![Page 17: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/17.jpg)
17GR2-00
Phong ShadingPhong Shading
Phong shading has a similar first step, in that vertex normals are calculated - typically as average of normals of surrounding faces
N
![Page 18: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/18.jpg)
18GR2-00
Phong ShadingPhong Shading
However rather than calculate intensity at vertices and then interpolate intensities as we do in Gouraud shading ...
In Phong shading we interpolate normals at each pixel ...
P4
P2
P1
P3
P Q
N2
N1
N
![Page 19: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/19.jpg)
19GR2-00
Phong ShadingPhong Shading
... and apply the reflection model at each pixel to calculate the intensity - IRED, IGREEN, IBLUE
P4
P2
P1
P3
P Q
N2
N1
N
![Page 20: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/20.jpg)
20GR2-00
Phong ShadingPhong Shading
![Page 21: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/21.jpg)
21GR2-00
Phong versus Gouraud Shading
Phong versus Gouraud Shading
A major advantage of Phong shading over Gouraud is that specular highlights tend to be much more accurate– vertex highlight is much sharper– a highlight can occur within a polygon
Also Mach banding greatly reduced The cost is a substantial increase in
processing time because reflection model applied per pixel
But there are limitations to both Gouraud and Phong
![Page 22: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/22.jpg)
22GR2-00
Gouraud versus PhongGouraud versus Phong
![Page 23: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/23.jpg)
23GR2-00
Interpolated Shading Limitations - Perspective
Effects
Interpolated Shading Limitations - Perspective
Effects
Anomalies occur because interpolation is carried out in screen space, after the perspective transformation
Suppose P2 much more distant than P1. P is midway in screen space so gets 50 : 50 intensity (Gouraud) or normal (Phong)
... but in world coordinates it is much nearer P1 than P2
P4
P2
P1
P3
PQ
![Page 24: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/24.jpg)
24GR2-00
Interpolated Shading Limitations - Averaging
Normals
Interpolated Shading Limitations - Averaging
Normals
Averaging the normals of adjacent faces usually works reasonably well
But beware corrugated surfaces where the averaging unduly smooths out the surface
![Page 25: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/25.jpg)
25GR2-00
Wall LightsWall Lights
![Page 26: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/26.jpg)
26GR2-00
Wall Lights with Fewer Polygons
Wall Lights with Fewer Polygons
![Page 27: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/27.jpg)
27GR2-00
Final Note on NormalsFinal Note on Normals
If a sharp polygon boundary is required, we calculate two vertex normals for each side of the joint
NLEFT NRIGHT
![Page 28: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/28.jpg)
28GR2-00
Further StudyFurther Study
There are excellent illustrations of Gouraud and Phong shading at a number of Web sites
Please go to:http://www.scs.leeds.ac.uk/kwb/
GR2and follow the link to Resources
![Page 29: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/29.jpg)
29GR2-00
AcknowledgementsAcknowledgements
Thanks again to Alan Watt for the images
The following sequence is the famous Shutterbug from Foley et al
![Page 30: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/30.jpg)
30GR2-00
Simple Shading -Without Taking Account of
Normals
Simple Shading -Without Taking Account of
Normals
![Page 31: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/31.jpg)
31GR2-00
Constant or Flat Shading -Each Polygon has Constant
Shade
Constant or Flat Shading -Each Polygon has Constant
Shade
![Page 32: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/32.jpg)
32GR2-00
Gouraud ShadingGouraud Shading
![Page 33: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/33.jpg)
33GR2-00
Phong ShadingPhong Shading
![Page 34: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/34.jpg)
34GR2-00
Phong Shading with Curved Surfaces
Phong Shading with Curved Surfaces
![Page 35: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques](https://reader035.vdocuments.us/reader035/viewer/2022062417/5515f4b3550346d46f8b5597/html5/thumbnails/35.jpg)
35GR2-00
Better Illumination ModelBetter Illumination Model