C++ Code fragment for generating the two lights, using the OpenGL API:
GLfloat R_warm, G_warm, B_warm,R_cool, G_cool, B_cool; R_warm=207/255.0; G_warm=207/255.0; B_warm=145/255.0; R_cool=80/255.0; G_cool=80/255.0; B_cool=145/255.0; GLfloat hi_diffuse[] = { (R_warm-R_cool)/2.0, (G_warm-G_cool)/2.0, (B_warm-B_cool)/2.0 }; GLfloat lo_diffuse[] = { (R_cool-R_warm)/2.0, (G_cool-G_warm)/2.0, (B_cool-B_warm)/2.0 }; GLfloat hi_position[] = { 1, 1, EYE, 1 }; GLfloat lo_position[] = { -1, -1, EYE, 1 }; GLfloat ambient[] = { 0.5, 0.5, 0.5 }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, hi_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, hi_position); glEnable( GL_LIGHT0 ); glLightfv(GL_LIGHT1, GL_DIFFUSE, lo_diffuse); glLightfv(GL_LIGHT1, GL_POSITION, lo_position); glEnable( GL_LIGHT1 );
Phong shading model for colored object. | New shading model without edge lines. |
New shading model: edge lines, highlights, and cool-to-warm hue shift. | Approximation: Phong shading, two colored lights, and edge lines. |
Figure 5.2: Comparison of traditional computer graphics techniques and techniques for creating technical illustrations. |
A light source cannot be used for metals on a conventional API. However, either environment maps or texture maps can be used to produce alternating light and dark stripes.