1 / 23

CS425

CS425. OpenGL Materials. What Color Is It?. white light. green & blue absorbed. Looks red. What Color Is It?. white light. red & blue absorbed. Looks green. What Color Is It?. white light. blue absorbed. Looks yellow. What Color Is It?. red light. ?. red absorbed. cyan.

dino
Download Presentation

CS425

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. CS425 OpenGL Materials

  2. What Color Is It? white light green & blue absorbed Looks red

  3. What Color Is It? white light red & blue absorbed Looks green

  4. What Color Is It? white light blue absorbed Looks yellow

  5. What Color Is It? red light ? red absorbed cyan

  6. What Color Is It? red light red absorbed cyan Looks black

  7. What Color Is It? magenta light ? blue absorbed

  8. What Color Is It? magenta light blue absorbed Looks red

  9. Material Response to Light • The material specified in OpenGL can have three different responses to the light hitting it plus one emissive characteristic. • You can separately specify the response to: • Ambient • Diffuse • Specular • And you can specify that the material “emits light”

  10. glMaterial{if}v(face, pname, param) • face • GL_FRONT • GL_BACK • GL_FRONT_AND_BACK

  11. glMaterial{if}v(face, pname, param) • pname • GL_AMBIENT (ambient color of material) • GL_DIFFUSE (diffuse color of material) • GL_AMBIENT_AND_DIFFUSE (both) • GL_SPECULAR (specular color of material) • GL_SHININESS (specular exponent) • GL_EMISSION (emissive color of material) • GL_COLOR_INDEXES (ambient, diffuse, and specular color indices)

  12. param The value for the pname’d material property Example GLfloat mat_amb_diff [ ] = {0.1, 0.5, 0.8, 1.0}; glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff); glMaterial{if}v(face, pname, param )

  13. diffuse & specular (low shininess) diffuse & specular (high shininess) + (.3,.2,.2,.0) emmissive, no specular Diffuse only (.1, .5, .8. 1.0) NO Ambient specular (1,1,1,1) shininess (5.0) specular (1,1,1,1) shininess (100.0) (.7, .7, .7) Ambient (.8, .8, .2) Ambient

  14. Nate Robbins Lightmaterial

  15. Color Material Mode • I didn’t find this previously. • Causes the material property specified to track the value of the current color (glColor*) • glColorMaterial(face, mode) • “face” and “mode” are same as for glMaterial. • Must use glEnable (see example)

  16. glColorMaterial example glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_DIFFUSE); glColor3f(0.2, 0.5, 0.8); /* draw some objects */ glColorMaterial(GL_FRONT, GL_SPECULAR); /*glColor no longer changes diffuse reflection, it now changes secular reflection */ glColor3f(0.9, 0.0, 0.2); /* draw some other objects */ glDisable(GL_COLOR_MATERIAL);

  17. colormat.c

  18. Two Sided Materials GLfloat outside = {0.2, 1.0, 1.0, 1.0}; GLfloat inside = {1.0, 0.5, 0.5, 1.0}; … glMaterialfv(GL_FRONT, GL_DIFFUSE, outside); glMaterialfv(GL_BACK, GL_DIFFUSE, inside); … glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

  19. Additional Clipping Plane A B C D Plane equation GLdouble eqn[ ] = {0.0, -1.0, 0.07, 0.5}; … glEnable(GL_CLIP_PLANE0); … glClipPlane(GL_CLIP_PLANE0, eqn); See cutting.c (handout)

  20. Two Sided Materials with Cutting Plane

  21. Same formula that Denbigh gave. OpenGL Attenuation c = constant factor l = linear factor q = quadratic factor d = distance

  22. Function Calls • You use the glLightf function to select attenuation factors. Default values are kc=1, kl=0, kq=0. • glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2.0); • glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0); • glLlightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0);

  23. kc=0 kl=0 kq=0.001 kc=0 kl=1 kq=0 kc=0 kl=0.5 kq=0 kc=0 kl=0.2 kq=0 kc=0 kl=0.1 kq=0 kc=0 kl=0.01 kq=0 kc=0 kl=0 kq=0.1 kc=1 kl=0 kq=0.001 kc=1 kl=0 kq=0 + =

More Related