- Date:15 May 2020
- Views:18
- Downloads:0
- Pages:20
- Size:435.38 KB

Description:

So far all objects that we have created have had a flat look thus failed to show the 3 D nature of the model This was because we assumed that each surface has one color If we look at the photograph of a sphere it does not appear as a uniformly colored circle rather with many shades of colors that gives it the spherical appearance The gradations or shades of colors give 2 D images the

Transcription:

Light and Surface,Rather than looking at a global energy balance. we follow rays of light from light emitting or,Self luminous surfaces which we call light. We then model what happens to these rays,as they interact with reflecting surfaces. A viewer can see a ray of light,That has directly comes to her eyes. from the light sources or,that comes to her eyes after.

being reflected from a reflecting,In computer graphics we replace. the viewer s eyes with the,projection plane,Chapter 6 3. Interaction Between Light and Materials, There are three groups of interactions between light and materials. Specular Surface Diffuse Surface Translucent Surface. Specular Surface appears shiny because most of the light that is reflected is. scattered in a narrow range of angles close to the angle of reflection mirrors. Diffuse Surface is characterized by reflected light being scattered in all directions. walls painted with a flat paint A perfectly diffuse surface scatter light equally in. all directions, Translucent Surface allows some light to penetrate the surface and to emerge. from another location on the object An example would be the light that goes. through water,Chapter 6 4,Chapter 6 2,Light Sources.

There are two fundamental processes for light to leave a surface. Self emission and,reflection, Some light sources such as a light bulb may reflect the. light that comes from surrounding too,In general a light source can be characterized by. a six variable illumination function I x y z, Note that we need two angles to specify a direction. The total contribution of a light source,can be obtained by integrating over the. surface of the source But this integral I x1 y1 z1 1 1. is very difficult,I x2 y 2 z 2 2 2,We consider four basic types of sources.

1 Ambient lighting 2 point sources,3 spotlight and 4 distant light. Chapter 6 5,Color Sources, Light sources emit different amounts of light at different frequencies but also. their directional properties can vary with frequency This results in complexity. The model of human visual system is based on three color theory that says we. perceive three primaries red green and blue rather than a full color. distribution, We describe a source through a three component intensity or luminance I I g. Ambient Light I b, In some cases the lights have been designed and positioned to provide uniform. illumination throughout the room Such illumination is achieved via large. sources that have diffusers that scatter light in all directions In theory we can. create such a source by modeling all the distributed sources and then. integrating the illumination from these sources at each point on a reflecting. surface This is hard to do Instead we use ambient light I ar. Chapter 6 I ab 6,Chapter 6 3,Point Sources I r p 0.

An ideal point source emits light equally in all directions defined as I p0 I g p 0. The intensity of a illumination received from a point source is I b p 0. Proportional to the inverse square of the distance between the source. and surface 1 r2,Where I p0 denote any of the components p p0. Some areas are fully in shadow umbra and,some are in partial shadow or in the penumbra. A solution assume the source as 1 a bd cd2,where d is the distance and a b and c are the. constants chosen to soften the the lighting,Chapter 6 7. Spotlights, Spotlights are characterized by a narrow range of angles through which light is.

emitted We can construct a simple spotlight from a point source by limiting the. angle at which light from the source can be seen,For 180 this becomes the point source. The realistic spotlight is characterized by the,distribution of light within the cone Usually. most of the light is concentrated at the,center of the cone. How do we find cos s l,s and l are both unit vectors Chapter 6. Chapter 6 4,Distant Light Sources, Most shading calculations require the direction from the point on the surface to the.

light source, As we move across a surface calculating the intensity at each point we should. recompute this vector repeatedly However if the light source is far from the. surface the vector does not change much as we move from one point to another. This is actually similar to the parallel light source and. calculations for this case is the same as that for. parallel projections replace the location of the,light source with direction of the light source x. Hence in homogeneous coordinates p0,This will be replaced with x z. Chapter 6 9,Normal at P Pointing to,The Phong Reflection Model COP. Pointing to, The four vectors that are used on this figure light source.

to compute the color are,p an arbitrary point on the surface. n is the normal at p Pointing to,a ray from a,v is in the direction from p to the COP perfect. l is in the direction of a line from p to the point reflection. light source, r is in the direction that a perfectly reflected ray from l would take. The Phong model supports three types of material light interactions ambient. diffuse and specular, An illumination matrix has the ambient diffuse and specular components in it. Lira Liga Liba 1st row the ambient intensities for red green blue. L i Lird Ligd Libd 2nd row the diffuse terms for red green blue. 3rd row the specular terms for red green blue,Lirs Ligs Libs.

Chapter 6 10,Chapter 6 5,The Phong Reflection Model cont. We construct the model by assuming that we can compute how much of each of. the incident light is reflected at the point of interest. For each point we compute a matrix of reflection terms of the form. Lira Liga Liba Rira Riga Riba,L i Lird Ligd Libd R i Rird Rigd Ribd. Lirs Ligs Libs Rirs Rigs Ribs, The contribution by each color source will be included by adding the ambient. diffuse and specular components For example red intensity that we see at p. from source i is Iir Rira Lira Rird Lird Rirs Lirs Iira Iird Iirs. The total intensity is computed as,I r I ira I ird I irs I ar. Where Iar is the red component of the global ambient light If we assume that the. same calculation should be done for each color we can write a general equation. I Ia Id Is LaRa LdRd LsRs,Chapter 6 11, Consider the illumination and reflection matrices below and a global ambient light.

source of Ia 0 7 0 0 0 2,What would be the intensity of. 10 2 0 1 1 1 red green and blue colors at a, L1 2 4 4 R 1 5 4 1 point defined by the reflection. matrices Note i is the source,5 5 5 5 5 5 number Here we only have one. For red I ir Rira Lira Rird Lird Rirs Lirs, For green I ig Riga Liga Rigd Ligd Rigs Ligs Lira Liga Liba. For blue I ib Riba Liba Ribd Libd Ribs Libs,ird L igd ibd.

Lirs Ligs Libs,Rira Riga Riba,R i Rird Rigd Ribd,Rirs Rigs Ribs. Chapter 6 12,Chapter 6 6, Let s solve the same problem but this time include two light sources. 10 2 0 2 2 10 1 1 1,L1 2 4 4 L 2 4 4 4,R 1 R 2 5 4 1. 5 5 5 5 5 5 5 5 5, When we have more than one source then we have to add the. components on each source NoOfLightSources,ira I ird I irs I ar.

Chapter 6 13,Ambient Reflection, The intensity of ambient light La is the same at every point on the surface Some. of this light is absorbed and some is reflected, The amount reflected is given by the reflection coefficient Ra ka Because only. a positive fraction of the light is reflected we should have. Therefore Ia kaLa, Here La can be any of the individual light sources. A surface has three ambient coefficients kar kag and kab which may be different. A sphere appears yellow under a white ambient light if its blue ambient coefficient. is small and its red and green coefficients are large Why. Chapter 6 14,Chapter 6 7,Polygon Shading, OpenGL exploit the efficiencies possible for rendering flat polygons by. decomposing curved surfaces into many small flat polygons. Consider the following polygon mesh Each polygon is flat and thus has a well. defined normal vector We considered three ways to shade the polygon. 1 flat shading 2 interpolative or Gouraud shading and 3 Phong shading. Chapter 6 15,Flat Shading, The three vectors l n and v can vary as we move from one point to another on.

a surface For a flat polygon however n is constant Also if we assume a distant. viewer v is constant over the polygon Moreover if the light source is distant l is. There are two interpretations of distant 1 the sources is at infinity infinity long. distance and 2 in terms of the size of the polygon relative to how far the polygon. is from the source or viewer,If the three vectors are constant. then the shading calculation,needs to be carried out only once n. for each polygon and each,point on the polygon is,assigned the same shade. This is known as flat or constant,glShadeModel GL FLAT Chapter 6 16. Chapter 6 8,Flat Shading cont, If the flat shading is in place OpenGL uses the normal associated with the first.

vertex of a single polygon for the shading calculation. For primitives such as a triangle strip OpenGL uses the normal of the third vertex. for the first triangle the normal of the fourth for the second and so on. If the light source and viewer is near the polygon the vectors l and v will be. different for each polygon, If the polygon mesh is designed to model a smooth surface flat shading will almost. always be disappointing because we can see even small differences in shading. between adjacent polygons,Chapter 6 17,Flat Shading cont. Lateral inhibition, The human visual system has a remarkable sensitivity to small differences in light. intensity This is due to a property called lateral inhibition We perceive the. increase in brightness as overshooting on one side of an intensity step and. undershooting on the other,Strips known as Mach bands along the edges. Chapter 6 18,Chapter 6 9,Interpolative and Gouraud Shading.

If we set the shading model to be smooth via,glShadeModel GL SMOOTH. then OpenGL interpolates colors for other primitives such as lines. Can you see the problem when four vertices meet, In Gouraud shading we define the normal at a vertex. to be the normalized average of the normals of the. polygons that share the vertex,n1 n2 n3 n4,n1 n2 n3 n4. How do we know which vertices to use for, We need a data structure that keeps the list of all vertices then we traverse to. obtain the averaged normals Such a data structure must include minimally. polygons vertices normals and material properties,Chapter 6 19.

Phong Shading, Even the smoothness introduced by Gouraud shading may not prevent the. appearance of Mach bands, In Phong shading we interpolate normals across each polygon instead of. interpolating vertex intensities, We can compute vertex normals by interpolating over the normals of the polygons. that share the vertex,Next we can use the bilinear interpolation. to interpolate the normals over the polygon,n 1 n A nB.

We can do a similar interpolation on all, Once we have the normal at each point we can make an independent shading. calculation,Chapter 6 20,Chapter 6 10, Approximation of a Sphere by Recursive Subdivision. In OpenGL the utility library GLU creates sphere using quadratic surface and. the utility toolkit GLUT uses a polygonal approximation to create spheres. Here we will develop our own polygonal approximation to a sphere We use the. interaction betweens shading parameters and polygonal approximation to curved. surfaces We used recursive subdivision to generate approximations to curves. and surfaces to any desired level of accuracy, The starting point is a tetrahedron but we can start with any regular polyhedron. whose faces could be divided initially into triangles. A regular tetrahedron is composed of 4 equilateral triangles determined by four. 0 0 1 0 2 2 3 1 3 6 3 2 3 1 3 6 3 2 3 1 3, All these vertices lie on the unit surface centered at the origin. Chapter 6 21, Approximation of a Sphere by Recursive Subdivision cont.

First is to define the four vertices globally,point v 0 0 0 0 1 0 0 0 0 942809 0 33333. 0 816497 0 471405 0 333333 0 816497 0 471405 0 333333. void triangle point a point b point c, display one triangle using a line loop for wire frame a singlenormal for. constant shading or three normals for interpolative shading. glBegin GL POLYGON,glNormal3fv a,glVertex3fv a,glVertex3fv b. glVertex3fv c,glEnd Tetrahedron,Chapter 6 22,Chapter 6 11. Approximation of a Sphere by Recursive Subdivision cont. The tetrahedron can be drawn by,void tetrahedron, Apply triangle subdivision to faces of tetrahedron.

triangle v 0 v 1 v 2,triangle v 3 v 2 v 1,triangle v 0 v 3 v 1. triangle v 0 v 2 v 3, We can get a closer approximation to the sphere by subdividing each face of. tetrahedron into smaller triangles Subdividing into triangles ensure that the new. facets will be flat,Subdividing a triangle,We will use the. bisecting sides method,Bisect angles computing the bisecting sides. Centrum Chapter 6 23, Approximation of a Sphere by Recursive Subdivision cont.

After we have subdivided a facet as described in the previous page we can move. the new vertices that we created by bisection to the unit sphere by normalizing. each bisected vertex using a simple normalization function such as. void normal point3 p,double d 0 0,for i 0 i 3 i d p i p i. if d 0 0 for i 0 i 2 i p i d,Chapter 6 24,Chapter 6 12. Approximation of a Sphere by Recursive Subdivision cont. We can now subdivide a single triangle defined by the vertices numbered a b and c. point3 v1 v2 v3,for j 0 j 3 j v1 j v a j v b j,for j 0 j 3 j v2 j v a j v c j. for j 0 j 3 j v3 j v c j v b j,triangle v a v2 v1,triangle v c v3 v2. triangle v b v1 v3,triangle v1 v2 v3,Chapter 6 25, Approximation of a Sphere by Recursive Subdivision cont.

We can use this code in our tetrahedron routine to generate 16 triangles rather than. 4 but we would rather repeat the subdivision process n times to generate. successively closer approximation to the sphere,void tetrahedron int m. Apply triangle subdivision to faces of tetrahedron. divide triangle v 0 v 1 v 2 m,divide triangle v 3 v 2 v 1 m. divide triangle v 0 v 3 v 1 m,divide triangle v 0 v 2 v 3 m. Chapter 6 26,Chapter 6 13, Approximation of a Sphere by Recursive Subdivision cont. void divide triangle point3 a point3 b point3 c int m. point v1 v2 v3,for j 0 j 3 j v1 j a j b j,for j 0 j 3 j v2 j a j c j.

for j 0 j 3 j v3 j c j b j,divide triangle a v2 v1 m 1. divide triangle c v3 v2 m 1,divide triangle b v1 v3 m 1. divide triangle v1 v2 v3 m 1,else triangle a b c,Chapter 6 27. Light Sources in OpenGL, OpenGL supports the four types of light sources that we previously discussed and. allows at least eight light sources in a program Each must be individually. specified and enabled The parameters are similar to those required by the Phong. glLightfv source parameter pointer to array,glLightf source parameter value.

These two allow us to set the required vector and scalar parameters respectively. Example the first source GL LIGHT0 at 1 0 2 0 3 0,GLfloat light0 pos 1 0 2 0 3 0 1 0. set the 4th component to 0 to get a distant source with direction vector. GLfloat light0 dir 1 0 2 0 3 0 0 0,What is this one. GLfloat diffuse0 1 0 0 0 0 0 1 0,GLfloat ambient0 1 0 0 0 0 0 1 0. GLfloat specular0 1 0 1 0 1 0 1 0,Chapter 6 28,Chapter 6 14. Light Sources in OpenGL cont, A single light source with a white specular component and red ambient and diffuse.

GLfloat diffuse0 1 0 0 0 0 0 1 0,GLfloat ambient0 1 0 0 0 0 0 1 0. GLfloat specular0 1 0 1 0 1 0 1 0,glEnable GL LIGHTING. glEnable GL LIGHT0,glLightfv GL LIGHT0 GL POSITION light0 pos. glLightfv GL LIGHT0 GL AMBIENT ambient0,glLightfv GL LIGHT0 GL DIFFUSE diffuse0. glLightfv GL LIGHT0 GL SPECULAR specular0, Note we must enable both lighting and the particular source.

A global ambient source can be added independently. GLfloat global ambient 0 1 0 1 0 1 1 0, glLightModelfv GL LIGHT MODEL AMBIENT global ambient. Chapter 6 29,Light Sources in OpenGL cont,The components of the distance attenuation model. d d 1 a bd cd2,Must be set individually,glLightf GL LIGHT0 GL CONSTANT ATTENUATION a. We can convert a positional source to a spotlight by choosing the spotlight. direction GL SPOT DIRECTION the exponent GL EXPONENT and the. angle GL SPOT CUTOFF All three are specified by glLightf and glLightfv. There are two other light parameters provided by OpenGL that should be. considered,GL LIGHT MODEL LOCAL VIEWER and,GL LIGHT MODEL TWO SIDE. If you wish to perform full light calculation you can use. glLightModel GL LIGHT MODEL LOCAL VIEWER GL TRUE,To make sure that both back and front are seen.

Chapter 6 30,glLightModel GL LIGHT MODEL TWO SIDE GL TRUE.

Recent Views:

- Student handbook food safety education
- B gamma glutamyltransferase activity in human vulnerable
- Super profile doors sections maharashtra aluminium
- Test amp balance report
- As amazon web services
- Aeesp cooling water
- Biology paper 2 dsepp
- A first course on time series analysis uni wuerzburg de
- Project zusp construction system world bank
- Using fsqca university of manchester