Antialiasing
  • By default lines can appear "jagged"
    • Depecially nearly horizontal or vertical lines
    • Caused because lines are approximated with discrete pixels in the framebuffer (aliasing)

     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Antialiaing (cont)
  • OpenGL calculates a coverage value for each fragment, which is then multiplied by the alpha value


  •  
  •  Determining aliasing can be difficult and can be implementation dependent
    • Some parameters can be changed with glHint()

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Antialising Points and Lines
  • Enable with glEnable()
    • Use GL_POINT_SMOOT or GL_LINE_SMOOTH
  •  RGBA Mode must have blending enabled 
    • GL_SRC_ALPHA (source) 
    • GL_ONE_MINUS_SRC_ALPHA (destination)
    • (GL_ONE for destination will make the lines a bit lighter)

     
  • Items normally do not have to be depth sorted for points and lines

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Antialiasing in color index mode
  • Tricky, but it can be done
  • Difficult to create the colormap

  •  

     
     
     

    (need picture rendered on SGI)

  •  

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Antialiasing Polygons
  • Three ways:
    • Enabling blending (as with lines/points)
    • Accumulation buffer (discussed later ...)
    • Enable GL_POLYGON_SMOOTH
      • glEnable(GL_POLYGON_SMOOTH)
      • If desired, provide hint withGL_POLYGON_SMOOT_HINT
      • Turn off depth buffer
      • set blending to GL_SRC_ALPHA_SATURATE (source) and  GL_ONE (destination)  -- Final color is the sum of the destination and the scaled source color
      • sort the polygons and draw
    (Picture of aapoly)
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Fog
  • To enhance realism fog can be added to a scene

  •  

     

    Image of fog in flight simulator
     

  •  When fog is enabled, polygons farther from the viewpoint begin to fade into the fog color
  • Fog can also implement depth cueing
  • The density of the fog is parameterizable 
  • Fog can provide performance improvements (!)
    • The application's culling frustrum can be modified

     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Using Fog
  • Exp vs Linear

  •  

     



     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Fog Equasions
  • OpenGL fog blends a fog color with the incoming fragment's fog blending factor 

  •  

     

    z = eye coordinate distance between viewpoint and fragment center
    density, start, end are all defined with glFog()
     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Fog Equasions (cont)
     


     

  •  In RGBA mode C = f Ci + (1-f)Cf
    • Ci = incoming fragment color
    • Cf = fog color
  • In Color-Index Mode
    • I = Ii + (1-f) If
    (fogindex.c picture)
     
     
     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Polygon Offset
  • "Z-fighting" or "stitching" can occur for polygons and lines that are equally (or nearly equally) distant from the eyepoint

  • Polygon offset can eliminate this visual artifact
  • Use glEnable with GL_POLYGON_OFFSET_FILL, GL_POLYGON_OFFSET_LINE, or GL_POLYGON_OFFSET_POINT
  • glPolygonOffset(GLfloat factor, GLfloat units) specifies the depth offset:
    • o = m * factor + r * units
    • m = max depth slope     r = implementation-specific "resolvable" factor