next up previous
Next: Conclusion Up: Implementation and Results Previous: Edge Lines

Approximation to New Shading Model

  The new shading model presented in Section 4.2.2 cannot be implemented directly in high-level graphics packages that use Phong shading. However, the Phong lighting model can be used as a basis for approximating our model. This is in the spirit of the nonlinear approximation to global illumination used by Walter et al. [37]. In most graphics systems (e.g., OpenGL) negative colors for the lights can be used. Then Equation 4.1 can be approximated by two lights in directions and with intensities (kwarm - kcool)/2 and (kcool - kwarm)/2 respectively, and an ambient term of (kcool + kwarm)/2. This assumes the object color is set to white. The Phong highlight should be turned off to remove the jarring artifacts caused by the negative blue light. Highlights could be added on systems with accumulation buffers [16].

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.

This approximation is shown compared to traditional Phong shading and the exact model in Figure 5.2. Using this approximation, I was able to add the new shading to the Alpha_1 system as well.

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.


next up previous
Next: Conclusion Up: Implementation and Results Previous: Edge Lines