Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.

Similar presentations


Presentation on theme: "Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting."— Presentation transcript:

1 Shading 03/19/2003

2 Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting settings OpenGL uses an additive color model Phong lighting model

3 Lighting Principles Light that is directly reflected off the surface creates a specular highlight Light that is absorbed into the material before it is reflected creates the color we see. (Diffuse color) Material's appearance is the result of a combination of several light and material properties

4 Surface Normals Color determined by several factors –Surface normal and color –Light position –Eye position N

5 Specifying Material Properties glMaterialfv( face, property, value ); Material properties –GL_EMISSION –GL_AMBIENT –GL_DIFFUSE –GL_SPECULAR –GL_SHININESS Primitives have material properties for front and back sides

6 Setting Material Properties GLfloat green[] = { 0.0, 1.0, 0.0, 1.0 }; GLfloat red[] = { 1.0, 0.0, 0.0, 1.0 }; GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, red ); glMaterialfv( GL_FRONT, GL_SPECULAR, white ); glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 100.0 );

7 Determining Vertex Color vertex color = the material emission at that vertex + the global ambient light scaled by the material's ambient property at that vertex + the ambient, diffuse, and specular contributions from all the light sources, properly attenuated

8 Material Properties

9 Ambient Reflection of Material Ambient reflectance affects the overall color of the object. –Diffuse reflectance is brightest where an object is directly illuminated. –Ambient reflectance is most noticeable where an object receives no direct illumination. An object's total ambient reflectance is affected by the global ambient light and ambient light from individual light sources. Like diffuse reflectance, ambient reflectance isn't affected by the position of the viewpoint.

10

11 Lighted, smooth-shaded teapots drawn with different material properties that approximate real materials. The first column has materials that resemble (from top to bottom) emerald, jade, obsidian, pearl, ruby, and turquoise. The second column resembles brass, bronze, chrome, copper, gold, and silver. The third column represents various colors of plastic: black, cyan, green, red, white, and yellow. The fourth column is drawn with similar colors of rubber.

12 Specular Reflectance If gray, the highlight is the color of the light If non gray, the highlight is a combination of the light and the specular color Characteristics of specular highlight set with shininess exponent (0.0-128.0) –High value - concentrated specular reflection –Low value - larger less concentrated (more diffuse) specular reflection

13 Specular Reflectance Specular reflection from an object produces highlights. The amount of specular reflection seen by a viewer does depend on the location of the viewpoint –It's brightest along the direct angle of reflection.

14 Diffuse Reflectance Plays the most important role in determining what you perceive the color of an object to be. Affected by the color of the incident diffuse light and the angle of the incident light relative to the normal direction. (It's most intense where the incident light falls perpendicular to the surface.) Position of the viewpoint doesn't affect diffuse reflectance at all.

15 Ambient Reflectance Affects the overall color of the object. Diffuse reflectance is brightest where an object is directly illuminated, ambient reflectance is most noticeable where an object receives no direct illumination. Object’s total ambient reflectance is affected by the global ambient light and ambient light from individual light sources. Diffuse reflectance, ambient reflectance isn't affected by the position of the viewpoint.

16 Emissive Reflectance Make an object appear to be giving off light of that color. Most real-world objects (except lights) don't emit light, you'll probably use this feature mostly to simulate lamps and other light sources in a scene. Give appearance of slightly glowing. –They're not actually acting as light sources. –Create a light source and position it at the same location as the sphere to create that effect.

17 Twelve spheres, each with different material parameters. The row properties are as follows: row 1 - No ambient reflection row 2 - Grey ambient reflection row 3 - Blue ambient reflection. Column 1 - uses a blue diffuse material color with no specular properties Column 2 - The second column adds white specular reflection with a low shininess exponent Column 3 - The third column uses a high shininess exponent and thus has a more concentrated highlight. Column 4 - The fourth column uses the blue diffuse color and, instead of specular reflection, adds an emissive component.

18 Light Sources glLightfv( light, property, value ); –light specifies which light –multiple lights, starting with GL_LIGHT0 Infinite and local lights Local lights can also be spot lights ( the local light will shine in a direction and its light will be limited to a cone centered around that direction vector. –GL_SPOT_DIRECTION –GL_SPOT_CUTOFF –GL_SPOT_EXPONENT

19 Light in OpenGL Ambient Light Emitted Light Diffuse Light Specular Light

20 Global Ambient Light Uniform light level Light has been scattered so much that you can't tell where it comes from Appears to come from all directions Constant throughout the scene A kludge Ambient light is scattered equally in all directions after hitting an object

21 Emitted Light The simplest light. It originates from an object and is unaffected by any light sources.

22 Diffuse Light Comes from one direction So it's brighter if it comes squarely down on a surface than if it barely glances off the surface After hitting a surface, it's scattered equally in all directions, so it appears equally bright, no matter where the eye is located Any light coming from a particular position or direction probably has a diffuse component.

23 Specular Light Comes from a particular direction Bounces off the surface in a preferred direction A well-collimated laser beam bouncing off a high-quality mirror produces almost 100 percent specular reflection specularity as shininess.

24 Specifying Light Sources in OpenGL Light sources have a number of properties, such as color, position, and direction. void glLight{if}[v](GLenum light, GLenum pname, TYPEparam); Creates the light specified by light, which can be GL_LIGHT0, GL_LIGHT1,..., or GL_LIGHT7. The characteristic of the light being set is defined by pname

25 Position Directional light source –Located infinitely far away from the scene –Rays of light can be considered parallel by the time they reach an object –Sun Positional light source –Located near to the scene –The direction from which the light rays come –Desk lamp

26 Objects drawn with gray material parameters and colored light sources. (left) An infinite light source is used; (right) A local light source is used. With the infinite light source, the highlight (specular reflection) is centered on both the cone and the sphere because the angle between the object and the line of sight is ignored. With a local light source, the angle is taken into account, so the highlights are located appropriately on both objects.

27 Attenuation For real-world lights –the intensity of light decreases as distance from the light increases OpenGL attenuates a light source by multiplying the contribution of that source by an attenuation factor:

28 Light Sources Light color properties –GL_AMBIENT –GL_DIFFUSE –GL_SPECULAR Light attenuation –GL_CONSTANT_ATTENUATION –GL_LINEAR_ATTENUATION –GL_QUADRATIC_ATTENUATION

29

30 Lighting Example GLfloat white[] = { 1, 1, 1, 0 }; GLfloat magenta[] = { 0.8, 0, 0.8, 0 }; GLfloat pos[] = { 2.5, 6, 3.5, 1.0 }; glLightfv( GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE, magenta ); glLightfv( GL_LIGHT0,GL_SPECULAR,white); glLightfv( GL_LIGHT0, GL_POSITION, pos ); glEnable( GL_LIGHT0 ); glEnable( GL_LIGHTING );

31 Enabling Lighting Turn on lighting calculations –glEnable( GL_LIGHTING ); Turn on each light –glEnable( GL_LIGHTn );

32 Polygon Rendering Shading calculations require a tremendous amount of processing. Based on polygon normals or vertex normals and pixel color.

33 Wireframe Shows underlying structure No surfaces are visible No shading necessary

34 Flat Polygon is shaded with a single color. Same geometric polygon normal used for each vertex. If polygon normal points toward a light, the surface is illuminated

35 Faceted Polygon normal is the same for all vertices. If polygon normal points toward a light, the surface is illuminated

36 Smooth Render Style Uses vertex normals Colors are calculated for vertices Colors are interpolated between the vertices for edge colors Colors are interpolated across rendered scan lines

37 Gouraud Shading May be done in hardware Uses vertex normals Interpolated vertex normals to calculate light at every pixel

38 Phong Shading Calculates surface normals at vertices Interpolates surface normals between vertices Calculates color of surface

39 Phong Shading Almost always done off line Better quality than Gouraud Increased rendering time

40 Lighting Principles Review Light that is directly reflected off the surface creates a specular highlight Light that is absorbed into the material before it is reflected creates the color we see. (Diffuse color) Material's appearance is the result of a combination of several light and material properties

41 Rendering Process of producing a two dimensional image from 3D model Rendering Approaches –LOCAL Gouraud Shading Phong Shading –GLOBAL Ray Tracing Radiosity

42 Local Illumination Local –Contribution from the light that goes directly from the light source and is reflected from the surface –Shading of any surface is independent from the shading of all other surfaces

43 Global Illumination Contribution from the light that goes directly from the light source and is reflected from the surface Contribution from the light that is reflected from other surfaces to the current surface

44 Local Illumination Algorithms Scan line rendering Wireframe Faceted or flat shading Gouraud shading Phong shading

45 Photorealism Vs Lighting Visualization Photorealism –Mimic reality but not physically real (ambient light) –Look real –Approximate interplay of lighting Lighting visualization –Used when lighting must match real world –Calculates scene lighting from reality –Distinguishes between natural and electric lights

46 Gouraud Uses vertex normals Colors are calculated for vertices Colors are interpolated between the polygon edges May be done in hardware

47 Phong Shading Uses vertex normals Interpolated vertex normals to calculate light at every pixel Almost always done off line

48 Ray Tracing Ray tracing involves following paths or trees of line segments through the scene to compute the effects of typical light paths.

49 Ray Tracing Advantages Shadows Shiny objects Arbitrary geometry types, anything that you can intersect with a ray

50 Ray Tracing Disadvantages No distance fall-off of light Sharp shadows, Sharp specular reflections

51 Radiosity The rate at which energy leaves a surface Energy per time per unit area "radiosity equation" describes the amount of energy which can be emitted from a surface, as the sum of the energy inherent in the surface (a light source, for example) and the energy which strikes the surface, being emitted from some other surface.

52 Radiosity

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67


Download ppt "Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting."

Similar presentations


Ads by Google