Color
  • The main purpose of an OpenGL application is to determine the color of each pixel in the window

  •  
  • Contents of this session:
    • Color Perception
    • Computer Color
    • RGBA vs Color-index
    • Specifying a Color and Shading Model

     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Color Perception
  • The Human Visual System (HVS) recognizes light in the range from 390 nm (violet) 720 nm (red) 
  •  Perceived colors are a combination of light of different frequencies
  • The cone cells in the retena are sensitive to red, green and blue frequencies
    • (the HVS is least sensitive to blue)
  •  A monitor emultates visible colors by lighting pixels with a combination of red/green/blue colors.
  • OpenGL represents color in RGB - other color models (HLS/HSV/CMYK) must be converted to and from RGB.

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Computer Color
  • The hardware causes different amounts of R/G/B light emmision for each pixel
  •  Two ways to encode the color information for the application
    • RGB (or RGBA)
    • Color index
  •  Color index mode stores table entries for each pixel
  • The colormap is not fixed size and can vary between platforms

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Colorspace

     (image from http://www.swin.edu.au/astronomy/pbourke/colour/colourspace/)
     
  • Red, Green, and Blue intensities vary from 0.0 to 1.0 
  •  Each axis of the color space represents RGB intensities
  • Examples of OpenGL colors:
    • Red:          glColor3f(1.0, 0.0, 0.0)
      Yellow:     glColor3f(1.0, 1.0, 0.0)
      Magenta:  glColor(1.0, 0.0, 1.0)
  • NOTE! other operations (texture/lighting/blending) may affect the final color in the framebuffer

  •  

     
     
     
     
     

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Coloring
  • Early in execution, the color display mode (RGBA or Color Index) is set
  •  The mode cannot be changed after it is set
    • But there are workarounds ...
  • Color is based on several factors:
    • The per-vertex color definition (via glColor3f())
    • The interaction of the light source(s) with the surface normal and the material properties
    • Rasterization
    • The shading model
    • Blending 
    • Texturing
    • Anti-alising
    • Fog
    • Bit-wise operation (logical ops)

     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 6
  •  

  •  

     
     
     

  •  

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 7
  •  

  •  

     
     
     

  •  

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 8
  •  

  •  

     
     
     

  •  

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 9
  •  

  •  

     
     
     

  •  

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 10
  •  

  •  

     
     
     

  •  

  •