1 / 22

CS 470 Introduction to Computer Graphics

CS 470 Introduction to Computer Graphics. Color Light Materials. Colors. Consider— Color, as we perceive it, is, usually, a reflection of light from a light source (the sun, a reading lamp.

Télécharger la présentation

CS 470 Introduction to Computer Graphics

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. CS 470Introduction toComputer Graphics Color Light Materials

  2. Colors • Consider— • Color, as we perceive it, is, usually, a reflection of light from a light source (the sun, a reading lamp. • One way to view the idea of color is that objects in the world do not really have inherent colors in the abstract sense. • …rather objects reflect light (to different degrees) … and… • due to properties of the objects, portions of the light is reflected and the rest is absorbed. • The part that is reflected we experience as color.

  3. Colors • therefore, what we experience as color is, in fact, a result of the interaction between light and the material that makes up the objects. • with out light, it could be argued, there is no color. Turn out the lights, what do you see? • Light is important – even in CG, artificially colored objects appear flat, lose their “3dness”. • Light adds character to a model

  4. Light • Light strikes an object and it reflected to our eye – how do we model this in CG? • Phong model of light – way consider and model light. • Need to consider four vectors • L

  5. Light • Phong model – need to consider four vectors – • P – a point on the object where the light strikes. • L – a vector from the light source to P • N – the normal vector – perpendicular to the object’s surface. • R – the perfect reflection vector, exactly the same angle from N as the angle from L to N. • V – the viewer vector – some other angle from N defined by the position of the camera. N V L R P

  6. Lights • Light – four types • Diffused reflection – reflected light spreads out from the object, • a dull look • roughly the same regardless of V • does depend on L • Specular reflection – a concentrated reflection • shininess • Best light on R • amount viewed depends on the angular difference between R and V

  7. Light • Light – four types • Ambient reflection – generally available light – usually from reflected and reflected light from other sources • Emissive light – an object can be a light source. • think of LED, Computer Screen, Stop-light. • not effected by other light sources • not effected by its materals • not effect by the angle of V

  8. Lights • In OpenGL lighting is part of the state. • In OpenGL lights can be a mix of different types --- lights can have multiple components. • In OpenGL you have to turn on lighting. • If you turn on lighting, regular coloring no longer works. • …so, how do you turn on lighting?

  9. Lights glEnable(GL_LIGHTING); turns on the OpenGL functionality to use lighting. glEnable(GL_LIGHT0); Enables a specific light

  10. Lights • Lighting modeling requires the program to provide the normal vector N void glNormal3{b|s|i|d|f}(TYPE dx, TYPE dy, TYPE dz); void glNormal3{b|s|i|d|f}v(TYPE coordvec); defines the normal from object to point dx,dy, dz

  11. Lights • Where do you get the values for the normal vector? • calculate them • i.e. the normal for any point on a sphere is projected from the sphere’s center through that point. • …but wait…

  12. Lights • Lighting modeling requires that the normals N are unit normal (i.e. the sum of the squares of dx, dy,dz is equal to 1. glEnable(GL_NORMALIZE); makes N unit normal Rotations and translations do not effect N length Scaling does effect the length of N

  13. Lights void glLight{i|f}(GLenum light, GLenum param, TYPE value); sets properties of light called light param specifies the property being set or modified. value is the value or values being assigned to the property.

  14. Lights • Some light properties – • GL_POSITION - defines the location of the light in x, y, z, w in camera coordinates. • GL_DIFFUSE – RGBA values to define the color of diffused light. • GL_SPECULAR – RGBA values to define the color of specular light • GL_AMBIENT – RGBA values to define the color of ambient light.

  15. Lights • A note about position coordinates • use 4 dimensional coordinates (include w coordinate. • w coordinate acts as a normal/homogenization coordinate. • w=1 means that the light is a point source with a specific location. • w=0 means that the light from a direction rather than a point (some far off place)

  16. Lights • Light defaults – • LIGHT0 – • no ambient light • diffused and specular light is white (1.0, 1.0, 1.0, 1.0) • All other lights – • everything is black (0.0, 0.0, 0.0, 1.0)

  17. Lights • Spotlights • GL_SPOT_DIRECTION – direction to point the spotlight in dx, dy, dz coordinates • GL_SPOT_CUTOFF – the angle in degrees for the spotlight’s cone of light. • default is 180 degrees – which is not a spotlight

  18. Materials void glMaterial{i|f}(GLenum face, GLenum name, TYPE value); void glMaterial{i|f}v(GLenum face, GLenum name, TYPE *value); defines the properties for materials of objects. face can be GL_FRONT, GL_BACK, GL_FRONT_BACK

  19. Materials • Some material properties – • GL_DIFFUSE – RGBA values to define the color of reflected diffused light. • GL_SPECULAR – RGBA values to define the color of reflected specular light • GL_AMBIENT – RGBA values to define the color of reflected ambient light. • GL_AMBIENT_AND_DIFFUSE – allow ambient and diffused reflected light to set the same.

  20. Materials • Some other material properties GL_EMISSION – declares the material to be a light source. Not effected by other light. GL_SHININESS – determines the reflectivity of the object. Concentrates the reflected light around R.

  21. Materials /* brass material */ glMaterialf(GL_FRONT, GL_AMBIENT, {0.33, 0.22, 0.3, 1.0}); glMaterialf(GL_FRONT, GL_DIFFUSE, {0.78, 0.57, 0.11, 1.0}); glMaterialf(GL_FRONT, G_SPECULAR, {0.99, 0.91, 0.81, 1.0}); glMaterialf(GL_FRONT, GL_SHININESS, 78.0);

More Related