Download presentation

Presentation is loading. Please wait.

1
**SI23 Introduction to Computer Graphics**

Lecture 14 – Polygon Shading Techniques

2
Reflection Models We have seen how the reflected intensity at a point may be calculated A reminder of the Phong reflection model...

3
**Phong Reflection Model**

light source N R eye L V surface I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() / dist dist = distance attenuation factor In practice, we evaluate IRED, IGREEN, IBLUE for red, green, blue intensities: IRED= KaREDIaRED + ( KdRED( L . N ) + Ks( R . V )n ) I*RED/dist

4
**Phong Reflection Model**

Remember calculation depends on: surface normal at a point light source intensity and position material properties viewer position L.N and R.V constant if L, V taken to be far away

5
Viewing Polygons We have also seen how a 3D polygon can be projected to screen space via a sequence of transformations This lecture looks at how we shade the polygon, using our reflection model

6
**Constant (or Flat) Shading**

light viewer Calculate normal (how?) Assume L.N and R.V constant (light & viewer at infinity) Calculate IRED, IGREEN, IBLUE using Phong reflection model Project vertices to viewplane Use scan line conversion to fill polygon N

7
**2D Graphics - Filling a Polygon**

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 See lecture 6 for details of algorithm with edge tables etc See also Hearn&Baker, Ch 3

8
Polygonal Models Recall that we use polygonal models to approximate curved surfaces Constant shading will emphasise this approximation because each facet will be constant shaded, with sudden change from facet to facet

9
Flat Shading

10
Gouraud Shading Gouraud shading attempts to smooth out the shading across the polygon facets Begin by calculating the normal at each vertex N

11
Gouraud Shading N A feasible way to do this is by averaging the normals from surrounding facets Then apply the reflection model to calculate intensities at each vertex

12
Gouraud Shading We use linear interpolation to calculate intensity at edge intersection P IPRED = (1-)IP1RED + IP2RED where P divides P1P2 in the ratio 1- Similarly for Q P4 P2 P1 P3 P Q 1-

13
Gouraud Shading Then we do further linear interpolation to calculate colour of pixels on scanline PQ P2 P1 P3 P Q

14
Gouraud Shading

15
Henri Gouraud Henri Gouraud is another pioneering figure in computer graphics

16
**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

17
**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 banding

18
Phong Shading N Phong shading has a similar first step, in that vertex normals are calculated - typically as average of normals of surrounding faces

19
Phong 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

20
Phong 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

21
Phong Shading

22
**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

23
Gouraud versus Phong

24
**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 P3 P2 Q P P1 P4

25
**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

26
Wall Lights

27
**Wall Lights with Fewer Polygons**

28
Final Note on Normals If a sharp polygon boundary is required, we calculate two vertex normals for each side of the joint NLEFT NRIGHT

29
**Simple Shading - Without Taking Account of Normals**

30
**Constant or Flat Shading - Each Polygon has Constant Shade**

31
Gouraud Shading

32
Phong Shading

33
**Phong Shading with Curved Surfaces**

34
**Better Illumination Model**

35
**Further Study Hearn and Baker, section 14-5**

Think about the relative computational costs of flat, Gouraud and Phong

36
**Acknowledgements Thanks again to Alan Watt for the images**

The following sequence is the famous Shutterbug from Foley et al

Similar presentations

OK

9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.

9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on road accidents uk Ppt on power quality in energy conversion systems Ppt on pin diode applications Ppt on network switching concepts Ppt on business environment nature concept and significance of the number Ppt on 3 idiots movie songs Animated ppt on magnetism worksheet Ppt on multiplexers and demultiplexers Ppt on center of mass Ppt on economic order quantity definition