Shading Chapter 6 CS 480680 Chapter 6 Shading

  • Slides: 75
Download presentation
Shading Chapter 6 CS 480/680 Chapter 6 -- Shading

Shading Chapter 6 CS 480/680 Chapter 6 -- Shading

n Introduction: n We have learned to build three-dimensional models and to display them.

n Introduction: n We have learned to build three-dimensional models and to display them. n However, if you render one of our models, you might be disappointed to see images that look flat. n n We have left out the interaction between light and the surfaces in our models n CS 480/680 This appearance is a consequence of our unnatural assumption that each surface is lit such that it appears to the viewer in a single color. So, we will begin by developing models of light sources and the most common light-material interactions. Chapter 6 -- Shading 2

n We then will investigate how we can apply shading to a polygonal model.

n We then will investigate how we can apply shading to a polygonal model. n We then develop a recursive approximation to a sphere to test our shading algorithms. n We then discuss how light and material properties are specified in Open. GL n and can be added to our sphere approximating program. n We conclude the chapter with a short discussion of the two most important methods for handling global lighting effects: n Ray Tracing and Radiosity CS 480/680 Chapter 6 -- Shading 3

1. Light and Matter n From a physical perspective, a surface can either n

1. Light and Matter n From a physical perspective, a surface can either n emit light by self-emission (as a light bulb does) n or reflect light from other surfaces that illuminate it. CS 480/680 Chapter 6 -- Shading 4

n The equation for solving this shading is called the rendering equation. n This

n The equation for solving this shading is called the rendering equation. n This cannot be solved in general, so we use approximations. n Radiosity and ray-tracing are approximations to this. n Unfortunately these approximations cannot yet be used to render scenes at the rate we can pass polygons through the modeling-projection pipeline. n Therefore, we will focus on a simpler rendering model n CS 480/680 This model is based upon the Phong reflection model Chapter 6 -- Shading 5

n CS 480/680 To get an overview of the process, we can start following

n CS 480/680 To get an overview of the process, we can start following rays of light from a point-light-source Chapter 6 -- Shading 6

n In terms of Computer graphics, we replace the viewer with the projection plane

n In terms of Computer graphics, we replace the viewer with the projection plane n Note that most rays leaving a source do not contribute to the image and are thus of no interest to us. CS 480/680 Chapter 6 -- Shading 7

n The interaction between light and materials can be classified into three groups n

n The interaction between light and materials can be classified into three groups n (a) specular n (b) diffuse n (c) translucent CS 480/680 Chapter 6 -- Shading 8

n Specular Surfaces n appear shiny because most of the light that is reflected

n Specular Surfaces n appear shiny because most of the light that is reflected in a narrow range of angles close to the angle of reflection. n Angle of Incidence is equal to the angle of reflection. n Diffuse Surfaces n reflected light is scattered in all directions. n Translucent Surfaces n allow some light to penetrate the surface and to emerge from another location on the object. n Refraction CS 480/680 Chapter 6 -- Shading 9

2. Light Sources n Light can leave a surface through n self-emission and reflection.

2. Light Sources n Light can leave a surface through n self-emission and reflection. n When we discuss Open. GL lighting in section 7 we shall see that we can easily simulate a selfemission term. CS 480/680 Chapter 6 -- Shading 10

n If we consider a source such as: n each point on the surface

n If we consider a source such as: n each point on the surface can emit light that is characterized by n the direction of emission (q, f) ( (u, t) n the intensity of energy emitted at each wavelength l n CS 480/680 Thus, a general light source can be characterized by an illumination function n I(x, y, z, q, f, l)Chapter 6 -- Shading 11

n From the perspective of the surface that is being illuminated, we can obtain

n From the perspective of the surface that is being illuminated, we can obtain the total contribution of the source by integrating over the surface of the source. n This can be difficult, so we will consider four basic types of sources: n n CS 480/680 ambient lighting, point sources, spotlights, and distant lights These four are sufficient for rendering most simple scenes. Chapter 6 -- Shading 12

n 2. 1 Color Sources n Not only do light sources emit different amounts

n 2. 1 Color Sources n Not only do light sources emit different amounts of light at different frequencies, but also their directional properties can very with frequency. n Consequently, a physically correct model can be complex. n However, since we our visual system is based upon three colors, n for most applications, we can use each of the three colors to obtain what the human observer sees. CS 480/680 Chapter 6 -- Shading 13

n 2. 2 Ambient Light n In some rooms, such as certain classrooms or

n 2. 2 Ambient Light n In some rooms, such as certain classrooms or kitchens, the lights have been designed and positioned to provide uniform illumination throughout the room. n Often this is achieved with light sources that have diffusers whose purpose is to scatter light in all directions. n Florescent lights have covers designed to do this. CS 480/680 Chapter 6 -- Shading 14

n Making such a model and rendering the scene with it would be a

n Making such a model and rendering the scene with it would be a daunting task for a graphics system. n Alternatively, we can look at the desired effect: n to achieve a uniform light level in the room n CS 480/680 This uniform lighting is called Ambient Light. Chapter 6 -- Shading 15

n 2. 3 Point Sources n An ideal point source emits light equally in

n 2. 3 Point Sources n An ideal point source emits light equally in all directions. n n CS 480/680 We can characterize a point light source by a threecomponent color matrix. The intensity of illumination received from a point source is proportional to the inverse square of the distance from the source to the surface. Chapter 6 -- Shading 16

n Scenes rendered with only point sources tend to have high contrast n (objects

n Scenes rendered with only point sources tend to have high contrast n (objects appear either bright or dark) n In the real world, it is the large size of most light sources that contributes to softer scenes. n Umbra n Penumbra CS 480/680 Chapter 6 -- Shading 17

n 2. 4 Spotlights n spotlights are characterized by a narrow range of angles

n 2. 4 Spotlights n spotlights are characterized by a narrow range of angles through which light is emitted. n We can construct a spotlight from a point source by limiting the angles. n For example, we can use a cone CS 480/680 Chapter 6 -- Shading 18

n More realistic spotlights are characterized by the distribution of light in the cone.

n More realistic spotlights are characterized by the distribution of light in the cone. n Usually most of the light is concentrated at the center of the cone. n The intensity is a function of the angle f n As we will see throughout this chapter, cosines are convenient functions for lighting calculations. CS 480/680 Chapter 6 -- Shading 19

n 2. 5 Distant Light Sources n Most shading calculations require the direction from

n 2. 5 Distant Light Sources n Most shading calculations require the direction from the point on the surface to the light source n As we move across a surface, calculating the intensity at each point, we should recompute this vector repeatedly. This is very expensive and is a significant part of the shading calculation. n However, if the light source is far from the surface, the vector does not change much n CS 480/680 Chapter 6 -- Shading 20

n In this case, we are effectively replacing a point light source with a

n In this case, we are effectively replacing a point light source with a source that illuminates objects with parallel rays of light. n Graphics systems can carry out rendering calculations more efficiently for distant light sources than for near ones. n Open. GL allows both CS 480/680 Chapter 6 -- Shading 21

3. The Phong Reflection Model Although we could approach light-material interactions through physical models,

3. The Phong Reflection Model Although we could approach light-material interactions through physical models, n we have chosen to use a model that leads to efficient computations and to be a close enough approximation to physical reality to produce good renderings under a variety of lighting conditions and material properties. n CS 480/680 Chapter 6 -- Shading 22

n The model uses the four vectors shown here to calculate a color for

n The model uses the four vectors shown here to calculate a color for a point p on a surface. n n is the normal vector at p n n v is the vector from p to the viewer or COP l is the vector from p to a light source r is in the direction that a perfectly reflected ray from l would take. n CS 480/680 We discuss its computation in section 6. 4 This is determined by n and l (calculated in 6. 4) Chapter 6 -- Shading 23

n The Phong model supports three types of lightmaterial interactions n Ambient, Diffuse, and

n The Phong model supports three types of lightmaterial interactions n Ambient, Diffuse, and Specular. n For the total Intensity we write: n I = Ia + Id n + I s = L a R a + L d. R d + L s R s where R is the reflection term n with the understanding that the computation will be done for each of the primaries and each source. CS 480/680 Chapter 6 -- Shading 24

n 3. 1 Ambient Reflection n The intensity of ambient light La is the

n 3. 1 Ambient Reflection n The intensity of ambient light La is the same at every point on the surface. n Some light is absorbed and some is reflected. n n n A surface has of course, three ambient coefficients n n n CS 480/680 The amount reflected is given by the ambient reflection coefficient, Ra=ka (0 £ ka £ 1) Thus Ia = ka La kar, kag, and kab and they can be different Hence, a sphere appears yellow under white ambient light if its blue ambient coefficient is small and its red and green coefficients are large. Chapter 6 -- Shading 25

n 3. 2 Diffuse Reflection A perfectly diffuse reflector scatters the light that it

n 3. 2 Diffuse Reflection A perfectly diffuse reflector scatters the light that it reflects equally in all directions. n Perfectly diffuse surfaces are so rough that there is no preferred angle of reflection n CS 480/680 Chapter 6 -- Shading 26

n 3. 3 Specular Reflection If we employ only ambient and diffuse reflections, our

n 3. 3 Specular Reflection If we employ only ambient and diffuse reflections, our images will be shaded and will appear three-dimensional, but all the surfaces will look dull, somewhat like chalk. n What is missing is the highlights n CS 480/680 Chapter 6 -- Shading 27

n A specular surface is smooth. n A mirror is a perfectly specular surface.

n A specular surface is smooth. n A mirror is a perfectly specular surface. n Modeling specular surfaces realistically can be complex n This is because the pattern is not symmetric, it depends upon the wavelength and it changes with the reflection angle. n The Phong model adds a term for specular reflection. n The amount of light that the viewer sees depends upon the angle f between r and the reflector v CS 480/680 Chapter 6 -- Shading 28

n The Phong Model uses the equation = ks. Lscosaf n ks is the

n The Phong Model uses the equation = ks. Lscosaf n ks is the fraction of the incoming specular light that is reflected. n a is the shininess coefficient. n Is n CS 480/680 As a is increased, the reflected light is concentrated in a narrower region, centered on the perfect reflector. Chapter 6 -- Shading 29

4. Computation of Vectors n The illumination and reflection models that we have derived

4. Computation of Vectors n The illumination and reflection models that we have derived are sufficiently general that they can be applied to either curved or flat surfaces, to parallel or perspective views, and to distant or near surfaces. n Most require vectors and dot products. n In this section we see what additional techniques can be applied when our objets are composed of flat polygons. CS 480/680 Chapter 6 -- Shading 30

n 4. 1 Normal Vectors n Plane n Typically the definition is given as

n 4. 1 Normal Vectors n Plane n Typically the definition is given as n ax+ by+ cz + d = 0 n It could also be given as. n n (p-p ) = 0 0 n If we were given 3 noncollinear points, we could find the normal by CS 480/680 n n = (p 2 -p 0) x (p 1 -p 0) n we must be careful about the order of the vectors. Reversing the order changes the surface from outward pointing to inward pointing. Chapter 6 -- Shading 31

n Curved Surfaces n We could go through the math of how a sphere

n Curved Surfaces n We could go through the math of how a sphere is defined. n We could go through parametric equations of a sphere n But we are only interested in the direction of the normal, so if the sphere is centered at the origin, we can say the normal is p CS 480/680 Chapter 6 -- Shading 32

n In Open. GL we can associate a normal with a vertex through functions

n In Open. GL we can associate a normal with a vertex through functions such as n gl. Normal 3 f(nx, ny, nz); n gl. Normal 3 fv(pointer_to_normal); n Normals are modal variables. n If we define a normal before a sequence of vertices n n this normal is associated with all the vertices and is used for the lighting calculations at all the vertices n The problem remains, however, that we have to determine these normals ourselves. CS 480/680 Chapter 6 -- Shading 33

n 4. 2 Angle of Reflection n Once we have calculated the normal at

n 4. 2 Angle of Reflection n Once we have calculated the normal at a point, we can use this normal and the direction of light to compute the direction of a perfect reflection n angle of incidence is equal to the angle of reflection CS 480/680 Chapter 6 -- Shading 34

n 4. 3 Use of the Halfway Vector n n CS 480/680 If we

n 4. 3 Use of the Halfway Vector n n CS 480/680 If we use the Phong model with specular reflections in our rendering, the dot product r. v should be recalculated at every point on the surface We can obtain an interesting approximation by using the unit vector halfway between the viewer vector and the light-source vector: Chapter 6 -- Shading 35

n n If we replace r. v with n. h, we avoid calculation of

n n If we replace r. v with n. h, we avoid calculation of r However, the halfway angle is smaller than the angle used for specular computation, so if we use the same exponent e in (n. h)e the specular highlights will be smaller, n so we use a different value of n CS 480/680 e to fix this. Exercise 6. 8 helps you see how much work this saves. Chapter 6 -- Shading 36

n 4. 4 Transmitted Light n Consider a surface that transmits all the light

n 4. 4 Transmitted Light n Consider a surface that transmits all the light that strikes it n If the speed of light differs in the two materials, the light is bent at the surface n Let hl and ht be the indices of refraction n Snell’s law states that CS 480/680 Chapter 6 -- Shading 37

Therefore, we can calculate the direction of the transmitted light. n A more general

Therefore, we can calculate the direction of the transmitted light. n A more general expression for what happens at a transmitting surface corresponds to this figure n n some light is transmitted, n some is reflected, n and the rest is absorbed. CS 480/680 Chapter 6 -- Shading 38

5. Polygonal Shading n n CS 480/680 Assuming that we can compute normal vectors,

5. Polygonal Shading n n CS 480/680 Assuming that we can compute normal vectors, given a set of light sources and a viewer, both the lighting and illumination models that we have developed can be applied at every point on a surface. Consider the polygon mesh shown here. We will consider three ways to shade the polygons: flat, interpolative or Gourand, and Phong shading Chapter 6 -- Shading 39

n 5. 1 Flat Shading n The three vectors - l, n, and v

n 5. 1 Flat Shading n The three vectors - l, n, and v - can vary n n n If all three are constant, the shading calculations only need to be carried out once for each polygon. In Open. GL we specify flat shading through n n CS 480/680 but for a flat polygon, n is constant if we assume the viewer does not change, v is constant if the light source is distance, l is constant gl. Shade. Model(GL_FLAT); This can be disappointing in its results Chapter 6 -- Shading 40

n 5. 2 Interpolative and Gourand Shading n If we use: n gl. Shade.

n 5. 2 Interpolative and Gourand Shading n If we use: n gl. Shade. Model(GL_SMOOTH); n n n CS 480/680 Then Open. GL interpolates colors for other primitives like lines The normals are computed at each vertex. Colors and intensities of interior points are interpolated between vertices. Problem: normals are discontinuous at the vertex Solution: average them Color plates 3 -5 show flat shading up to interpolative. Chapter 6 -- Shading 41

n 5. 3 Phong Shading n n Even the smoothness introduced by Gourand shading

n 5. 3 Phong Shading n n Even the smoothness introduced by Gourand shading may not prevent bands. Phong proposed that instead of interpolating the intensities, interpolate the normals n n CS 480/680 and then do calculation of intensities using the interpolated normal (typically at scan conversion) This is much smoother, but at a greater computational cost. Chapter 6 -- Shading 42

6. Approximation of a Sphere by Recursive Subdivision n We have used the sphere

6. Approximation of a Sphere by Recursive Subdivision n We have used the sphere as an example curved surface to illustrate shading calculations. n However, the sphere is not an object that is supported within Open. GL n Both the GL utility library (GLU) and the GL Utility Toolkit (GLUT) contain spheres n n CS 480/680 GLU via quadric surfaces n A topic discussed in Chapter 10 GLUT via polygonal approximation Chapter 6 -- Shading 43

n This section develops a polygonal approximation to a sphere. n This figure shows

n This section develops a polygonal approximation to a sphere. n This figure shows an approximation to a sphere drawn with this code CS 480/680 Chapter 6 -- Shading 44

7. Light Sources in Open. GL supports the four types of light sources that

7. Light Sources in Open. GL supports the four types of light sources that we just described, and allows at least 8 light sources per program. n Each light source must be individually specified and enabled n n CS 480/680 gl. Lightfv(source, parameter, pointer_to_array) gl. Lightf(source, parameter, value); Chapter 6 -- Shading 45

n There are four vector parameters that we can set n The position (or

n There are four vector parameters that we can set n The position (or direction) of the light, the amount of ambient, diffuse, and specular light associated with a source n For example: n n n n CS 480/680 gl. Enable(GL_LIGHTING); gl. Enable(GL_LIGHT 0); gl. Lightfv(GL_LIGHT 0, GL_POSITION, light 0_pos); gl. Lightfv(GL_LIGHT 0, GL_AMBIENT, ambinet 0); gl. Lightfv(GL_LIGHT 0, GL_DIFFUSE, diffuse 0); gl. Lightfv(GL_LIGHT 0, GL_SPECULAR, specular 0); Note that we must enable both lighting and the particular source. Chapter 6 -- Shading 46

n We can also set a global ambient term that is independent of any

n We can also set a global ambient term that is independent of any light n gl. Light. Model(GL_LIGHT_MODEL_AMIENT, global_ambient_data); n We can convert a source to a spotlight by choosing: n The spotlight direction (GL_SPOT_DIRECTION) n The exponent (GL_SPOT_EXPONENT) n And the angle (GL_SPOT_CUTOFF) n If we have objects that we need to have the light interact properly with both sides we may need to set n CS 480/680 gl. Light. Model(GL_LIGHT_MODEL_TWO_SIDED, GL_TRUE); Chapter 6 -- Shading 47

8. Specification of Materials in Open. GL n Material properties in Open. GL match

8. Specification of Materials in Open. GL n Material properties in Open. GL match up directly with the supported light sources and with the Phong reflection model. n We can also specify different material properties for the front and the back faces of a surface n All our reflection parameters are specified through the functions: n gl. Materialfv(face, type, pointer_to_array); n gl. Materialf(face, value); CS 480/680 Chapter 6 -- Shading 48

n For Example: n n Note: n n we use GL_FRONT and GL_BACK The

n For Example: n n Note: n n we use GL_FRONT and GL_BACK The shininess of a surface (the exponent in the specular-reflection term) is specified as follows: n CS 480/680 If both the specular and diffuse coefficients are the same (as is of the case), we can specify both by using GL_DIFFUSE_AND_SPECULAR To specify different front- and back-face properties, n n gl. Materialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); gl. Matrialg(GL_FRONT, GL_SHININESS, 100. 0); Chapter 6 -- Shading 49

n Open. GL also allows us to define surfaces that have an emissive component

n Open. GL also allows us to define surfaces that have an emissive component This characterizes self-luminous sources. n This is useful if you want a light source to appear in your image. n n For example this defines a small amount of blue-green emission: n n CS 480/680 It is unaffected by any light source And it does not affect any other surface. Glfloat emission[ ] = {0. 0, 0. 3, 1. 0}; gl. Materialfv(GL_FRONT_AND_BACK, GL_EMISSION, emission); Chapter 6 -- Shading 50

9. Shading of the Sphere Model We can now shade our spheres. n If

9. Shading of the Sphere Model We can now shade our spheres. n If we are to shade our approximate spheres with Open. GL’s shading model, we must assign normals. n n Following our previous approach, we use the cross product, and then normalize the result CS 480/680 Chapter 6 -- Shading 51

cross(point 3 a, point 3 b, point 3 c, point 3 d) { d[0]=(b[1]-a[1])*(c[2]-a[2])-(b[2]-a[2])*(c[1]-a[1]);

cross(point 3 a, point 3 b, point 3 c, point 3 d) { d[0]=(b[1]-a[1])*(c[2]-a[2])-(b[2]-a[2])*(c[1]-a[1]); d[0]=(b[2]-a[2])*(c[0]-a[0])-(b[0]-a[0])*(c[2]-a[2]); d[0]=(b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0]); normal(d); } void normal(point 3 p) { float d = 0. 0; int i; for(i=0; i<3; i++) d += p[i]; d = sqrt(d); if(d>0. 0) for(i=0; i<3; i++) p[i]/=d; } CS 480/680 Chapter 6 -- Shading 52

n Assuming the light sources have been defined and enabled: void triangle(point 3 a,

n Assuming the light sources have been defined and enabled: void triangle(point 3 a, point 3 b, point 3 c) { point 3 n; cross(a, b, c, n); gl. Begin(GL_POLYGON); gl. Normal 3 fv(n); gl. Vertex 3 fv(a); gl. Vertex 3 fv(b); gl. Vertex 3 fv(c); gl. End(); } CS 480/680 Chapter 6 -- Shading 53

n The results f flat shading the sphere done this way is shown here:

n The results f flat shading the sphere done this way is shown here: n Notice the silhouette edge of the sphere showing the polygons. n We can easily apply interpolative shading by setting the true normal at the vertex. CS 480/680 Chapter 6 -- Shading 54

void triangle(point 3 a, point 3 b, point 3 c) { point 3 n;

void triangle(point 3 a, point 3 b, point 3 c) { point 3 n; int i; gl. Begin(GL_POLYGON); for(i=0; i<3; i++)n[i]=a[i]; normal(n); gl. Normal 3 fv(n); gl. Vertex 3 fv(a); for(i=0; i<3; i++)n[i]=a[i]; normal(n); gl. Normal 3 fv(n); gl. Vertex 3 fv(b); for(i=0; i<3; i++)n[i]=a[i]; normal(n); gl. Normal 3 fv(n); gl. Vertex 3 fv(c); gl. End(); } CS 480/680 Chapter 6 -- Shading 55

n The results of this are shown here: n Although this produced a more

n The results of this are shown here: n Although this produced a more realistic image, this method is not generalizable. n See exercises 6. 9 and 6. 10 to see where it falls apart. CS 480/680 Chapter 6 -- Shading 56

10. Global Rendering There are limitations imposed by the local lighting model that we

10. Global Rendering There are limitations imposed by the local lighting model that we have used. n Consider, for example, an array of spheres n CS 480/680 Chapter 6 -- Shading 57

n Our lighting model cannot handle these situations. n It also cannot produce shadows.

n Our lighting model cannot handle these situations. n It also cannot produce shadows. n If these effects are important, than we can use a more sophisticated (and slower) rendering technique, such as ray tracing and radiosity. n Ray Tracing works well for highly specular surfaces; for example, in scenes composed of highly reflective and translucent objects, such as glass balls. n Radiosity is best suited for scenes with perfectly diffuse surfaces, such as the interior of buildings. CS 480/680 Chapter 6 -- Shading 58

n 10. 1 Ray Tracing n In many ways ray tracing is an extension

n 10. 1 Ray Tracing n In many ways ray tracing is an extension of our approach to rendering with a local lighting model. n It is based upon the observation that, of the rays of light leaving a source, the only ones that contribute to our image are those that enter the lens of our synthetic camera and pass through the COP. CS 480/680 Chapter 6 -- Shading 59

n Most of the rays that leave a source do not enter the lens

n Most of the rays that leave a source do not enter the lens and do not contribute to our image. n Hence attempting to follow all rays from a light source is a time wasting endeavor. n However, if we reverse the direction of the rays, and consider only those rays starting at the COP, we know that these casting rays MUST contribute to the image. CS 480/680 Chapter 6 -- Shading 60

n n Rays that go off to infinity can be assigned a background color.

n n Rays that go off to infinity can be assigned a background color. Rays that strike a surface require us to calculate a shade for the point of intersection. If we just use the Phong model we would produce the same image as our local renderer. n However, we can do much more! n n The process that we have just describes thus far requires all of the same steps as we used in our pipeline renderer Object modeling, Projection, Visible surface determination. n However the order is different. n n CS 480/680 Also, the renderer works on a vertex-by-vertex basis and the ray tracer works on a pixel-by-pixel Chapter 6 -- Shading 61

n In ray tracing, rather than immediately applying our reflection model, we first check

n In ray tracing, rather than immediately applying our reflection model, we first check whether the point of intersection is illuminated. n We do this by computing shadow or feeler rays from the point on the surface to each light source. CS 480/680 Chapter 6 -- Shading 62

n Suppose some of our surfaces are highly reflective n We can follow a

n Suppose some of our surfaces are highly reflective n We can follow a shadow ray as it bounces from surface to surface, until it either goes off to infinity or intersects a source. n CS 480/680 Such calculations are usually done recursively Chapter 6 -- Shading 63

n Ray tracing is particularly good at handling surfaces that are both reflecting and

n Ray tracing is particularly good at handling surfaces that are both reflecting and transmitting. n We follow a cast ray to a surface and follow both the reflecting ray (shadow ray) and the transmittal ray n The easiest way to describe a ray tracer is recursively. CS 480/680 Chapter 6 -- Shading 64

CS 480/680 Chapter 6 -- Shading 65

CS 480/680 Chapter 6 -- Shading 65

n CS 480/680 Color Plate 23 Chapter 6 -- Shading 66

n CS 480/680 Color Plate 23 Chapter 6 -- Shading 66

n CS 480/680 Color Plate 23 Chapter 6 -- Shading 67

n CS 480/680 Color Plate 23 Chapter 6 -- Shading 67

n 10. 2 Radiosity is ideal for a scene consisting of only perfectly diffuse

n 10. 2 Radiosity is ideal for a scene consisting of only perfectly diffuse surfaces. n Suppose we have the following scene n n CS 480/680 Our simple shading model has not considered the diffuse-diffuse interactions. Chapter 6 -- Shading 68

n The rendering equation, if we cold solve it, would give the correct shading

n The rendering equation, if we cold solve it, would give the correct shading for all points on these surfaced. n n CS 480/680 If we make the assumption that all surfaces are perfectly diffuse, then we can simplify the rendering equation to a point where a numerical method exists. The basic radiosity method breaks the scene into small flat polygons (patches) Chapter 6 -- Shading 69

n The basic radiosity method breaks the scene into small flat polygons (patches) Patches

n The basic radiosity method breaks the scene into small flat polygons (patches) Patches are then considered pair wise to consider light interaction (form factors) – This is O(n 2) n Once the form factors are known we then can solve the rendering equations. n n CS 480/680 Once these are done, the scene can be rendered in a walkthrough as fast as we could render with a local lighting model. Chapter 6 -- Shading 70

n CS 480/680 Color Plate 24 Chapter 6 -- Shading 71

n CS 480/680 Color Plate 24 Chapter 6 -- Shading 71

11. Summary n We have developed a lighting model that fits well with our

11. Summary n We have developed a lighting model that fits well with our pipeline approach to graphics. n With it we can create a variety of lighting effects, and can employ different types of light sources. n Although we cannot create the global effects of a ray tracer, a good graphics workstation can render a polygonal scene using the Phong reflection model and interpolative shading in the same amount of time it can render a scene without shading!!! CS 480/680 Chapter 6 -- Shading 72

n The recursive subdivision technique is a powerful one that reappears in Chapters 10

n The recursive subdivision technique is a powerful one that reappears in Chapters 10 and 11 when curves are rendered. n This chapter concludes our development of polygonal-based graphics. n You should now be able to generate scenes with lighting and shading. n Techniques for even more sophisticated images, such as texture mapping involve using the pixellevel capabilities of the graphics systems are considered in Chapter 9. n CS 480/680 Now is a good time for you to write an application program. Chapter 6 -- Shading 73

12. Suggested Readings n The use of lighting and reflection in computer graphics has

12. Suggested Readings n The use of lighting and reflection in computer graphics has followed two parallel paths: the physical and the computational Foley (90) gives a great discussion on these models. n Phong put together his model in 1975 n Ray tracing was introduced to computer graphics by Appel in 1968. n Radiosity is based upon a method first used in heat transfer (Sie 81) and was applied to computer graphics in 1984. n n CS 480/680 The Open. GL Programmer’s Guide (97 a) contains many good hints on effective use of Open. GL’s Chapter 6 -- Shading rendering capability. 74

Exercises -- Due next class CS 480/680 Chapter 6 -- Shading 75

Exercises -- Due next class CS 480/680 Chapter 6 -- Shading 75