1 / 33

Graphics: Conceptual Model

Graphics: Conceptual Model. Real Light. Human Eye. Real Object. Synthetic Light Source. Synthetic Camera. Human Eye. Synthetic Model. Real Object. Display Device. Graphics System. Lights, Surfaces, and Imaging. Objects. Proj. Plane. COP. Lights, Surfaces, and Imaging. Light

afram
Télécharger la présentation

Graphics: Conceptual Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphics: Conceptual Model Real Light Human Eye Real Object Synthetic Light Source Synthetic Camera Human Eye Synthetic Model Real Object Display Device Graphics System

  2. Lights, Surfaces, and Imaging Objects Proj. Plane COP

  3. Lights, Surfaces, and Imaging Light Source Objects Proj. Plane COP

  4. Modes of Interaction ofLight with Materials Specular Surface Reflection Diffuse Surface Reflection Translucent Surface Note: Any given surface can have some of all three properties.

  5. Reflection Rough Surface: Light is reflected equally in all directions. Diffuse Smooth Surface: Light is reflected at an angle near to the incident angle. Specular

  6. Illuminating Surfaces y x z We can define illumination function: To obtain total light, must integrate over total surface.

  7. Simpler Models • Exact model can easily get nasty to use! Three simplifications • will help. • 1. We can consider four simplified classes of light sources • ambient • point • spotlight • distant • 2. Human color perception allows us to consider illumination • function in terms of the three primary colors. • 3. We can (or must) neglect: • multiple reflections • obstruction of light path by objects

  8. Ambient Light Simulates situations where light sources are designed to produce uniform lighting throughout a scene. Ambient light can be thought of as present everywhere, coming from all directions. Characterized by a scalar intensity, Ia , that is identical at every point in the scene. Although every surface receives the same illumination, each surface can reflect the light differently.

  9. Point Sources An ideal point source radiates equally in all directions. It can be characterized by: Intensity of illumination from a point source is proportional to the inverse square of the distance between the point and the illuminated surface.

  10. Spotlights Spotlights are point sources for which the angle through which light has been emitted has been limited. q s l

  11. Distant Sources Most shading calculations require the direction from the point on a surface to the light source. As light sources are moved to larger distances, this direction approaches a constant. Therefore the point source location will be replaced by a vector indicating the direction of the source.

  12. Reflection Rough Surface: Light is reflected equally in all directions. Diffuse Smooth Surface: Light is reflected at an angle near to the incident angle. Specular

  13. n v l r Vectors Used byPhong Lighting Model COP p p is an arbitrary point on a surface. n is the unit normal to the surface at p. l is a unit vector in the direction of the light source. r is a unit vector in the direction of a perfectly (specular) reflection v is a unit vector in thedirection of the viewer.

  14. Elements of the Phong Lighting Model At each point p there is an illumination matrix from the ith light source: At each point p there is a reflection matrix for the ith light source: Assuming the calculations will be done separately for each primary, we can sum over light sources to get:

  15. Elements of the Phong Lighting ModelAmbient Reflection The intensity of ambient light is the same at every point on the surface. The percentage of light reflected is given by: Note that the ambient reflection terms can be different for red, green and blue.

  16. Elements of the Phong Lighting ModelDiffuse Reflection Intensity of illumination is dependent upon the incidence angle of light from the source: n l q Adding a term for attenuation with distance from source:

  17. Elements of the Phong Lighting ModelSpecular Reflection For a shiny surface, most light is reflected around vector r, corresponding to a reflected angle equal to the angle of incidence. If f is the angle between v and r, Adding a distance term, and expressing the cosine in terms of a dot product:

  18. The Complete Phong Model Specular term Diffuse term Ambient term Distance term

  19. Specification of the Normal in OpenGL Specification of the current normal is modaland associated with vertices. glNormal3f(nx,ny,nz); glNormal3fv(pointer_to_normal_vector); You have to calculate the normals yourself.

  20. Calculation of Normals Normal exists at every point for mathematically defined smooth surfaces. Exists for each polygon in surface defined by flat polygons. What about the shared lines? Polygonal Case: p2 p1 n p0

  21. Shading in OpenGL:Flat Shading OpenGL uses the current normal and calculates the color at the first vertex of a polygon. This color is used for the entire polygon. Requested by: glShadeModel(GL_FLAT); Flat shading exaggerates the visual effect of the boundaries between polygons due to the Mach band effect.

  22. Mach Band Effect(Mach, 1865) Color Science, Concepts and Methods Wyszecki, Stiles

  23. Mach Band Effect

  24. Mach Band Effect

  25. Shading in OpenGL:Smooth Shading Requested by: glShadeModel(GL_SMOOTH); Lighting calculations will be done at each vertex using the material properties, and the vectors v and l calculated for that vertex. Bilinear interpolation is used to determine color values in the interior of the polygon. Gouraud Shading: Normal at a vertex is the normalized average of the normals of the polygons that share that vertex.

  26. Gouraud Shading

  27. Specifying Light Sources in OpenGL General form: glLightf(source, parameter, value); glLightfv(source, parameter, *array); source is one of at least eight lights: GL_LIGHTi Parameters: GL_AMBIENT contains four values that specify the ambient RGBA intensity of the light. Default is (0.0, 0.0, 0.0, 1.0). GL_DIFFUSE contains four values that specify the diffuse RGBA intensity of the light. Default is (1.0, 1.0, 1.0, 1.0). GL_SPECULAR contains four values that specify the secular RGBA intensity of the light. Default is (1.0, 1.0, 1.0, 1.0).

  28. Specifying Light Sources in OpenGl GL_POSITION specifies the position of the light in homogeneous object coordinates. If the w component is zero, the light is treated as a directional source. GL_SPOT_DIRECTION specifies the direction of the light in homogeneous object coordinates. Default is (0.0, 0.0, -1.0) GL_SPOT_EXPONENT spotlight exponent, default 0.0 GL_SPOT_CUTOFF spot cutoff angle in [0,90] or (default) 180. GL_CONSTANT_ATTENUATION constant atten. factor, default 1.0 GL_LINEAR_ATTENUATION linear atten. factor, default 0.0 GL_QUADRATIC_ATTENUATION quadratic atten. factor, default 0.0

  29. Enabling the Lights and Lighting Enabling a light source: glEnable(GL_LIGHTi ); Enabling lighting: glEnable (GL_LIGHTING);

  30. Specifying Materials in OpenGL General form: glMaterialf(face, parameter,value); glMaterialfv(face, parameter,*array); face is GL_FRONT, GL_BACK, GL_FRONT_AND_BACK parameter is: GL_AMBIENT four values that specify the ambient RGBA reflectance of the material. (0.2,0.2,0.2,1.0) GL_DIFFUSE four values that specify the diffuse RGBA reflectance of the material. (0.8,0.8,0.8,1.0) GL_SPECULAR four values that specify the ambient RGBA reflectance of the material. (0.0,0.0,0.0,1.0) GL_SHININESS specifies the specular reflectance exponent of the material. 0.0

  31. Lighting ChecklistLighting = Lights + Materials + Model • Lights • Color of lights is set as desired. • Recommended: all lights set to white for diffuse, specular, and ambient • Lights are positioned correctly. • Remember lights are positioned with current MODELVIEW transformation at time of calling glLightfv() + GL_POSITION. • Remember position (point) vs. direction (vector). • Remember: Lights are objects and retain properties. • Required lights are enabled. • Lighting is enabled.

  32. Lighting ChecklistLighting = Lights + Materials + Model • Materials • Color of materials is set as desired. • Recommended: Set ambient color to zero initially until lighting is working perfectly. Use ambient with care! • Remember: Material properties are modal and there is only one current material. Therefore set all properties that are required and keep track of current state. • Be sure the proper normal is set for every polygon drawn. • Make sure the normal is of unit magnitude. You can use glEnable(GL_NORMALIZE). • Remember: Normals are modal, like materials. • Do not use glcolor3f() with lighting. Do not use glColorMaterial() in submissions for this class.

  33. Lighting ChecklistLighting = Lights + Materials+ Model • Model • glShadeModel() determines where lighting is calculated • GL_SMOOTH calculates at each polygon vertex and interpolates (default) • GL_FLAT calculates at first vertex and uses one color • glLightModel() sets global properties of lighting • GL_LIGHT_MODEL_TWO_SIDE reverses normals for back facing polygons. This is the only argument that we should ever require. • Do not use this function unless you really understand what the effects are.

More Related