Browse Prior Art Database

Mechanism to Clamp and Pack Lit Floating-Point Colors

IP.com Disclosure Number: IPCOM000118544D
Original Publication Date: 1997-Mar-01
Included in the Prior Art Database: 2005-Apr-01
Document File: 2 page(s) / 102K

Publishing Venue

IBM

Related People

Brokenshire, DA: AUTHOR [+2]

Abstract

Disclosed is an efficient method for converting floating-point color intensities to the fixed-point representation commonly accepted by 3D graphics hardware. This algorithm clamps the floating-point intensities to the range (0.0, 1.0), converts them to 8-bit unsigned bytes, and then packs four bytes into a single 32-bit word.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 51% of the total text.

Mechanism to Clamp and Pack Lit Floating-Point Colors

      Disclosed is an efficient method for converting floating-point
color intensities to the fixed-point representation commonly accepted
by 3D graphics hardware.  This algorithm clamps the floating-point
intensities to the range (0.0, 1.0), converts them to 8-bit unsigned
bytes, and then packs four bytes into a single 32-bit word.

      A standard 3D graphics system renders a scene composed of a
collection of vertices arranged into polygons.  Each vertex has a
number of attributes, including a 4-tuple of floating-point
intensities (red, green, blue, and alpha; or RGBA) specifying a
color.  This color can be specified explicitly by a program or
derived implicitly by evaluating a set of lighting equations.

      As each polygon of a scene is drawn, its vertices and their
colors are passed to specialized graphics hardware for display.
Typical hardware accepts RGBA colors as a 32-bit word composed of
four 8-bit integers representing the red, green, blue, and alpha
intensities.

      The floating-point color intensities of a vertex are converted
to 8-bit fixed-point values by applying a linear transformation in
which an intensity of 0.0 is converted to 0 and an intensity of 1.0
is converted to 255.  Prior to conversion, the floating-point
intensities are clamped: any intensities less than 0.0 are set to 0.0
and any intensities greater than 1.0 are set to 1.0.

      This five-step algorithm converts floating-point colors to a
single 32-bit word more efficiently than the algorithms previously in
use.  It exploits specialized hardware in the PowerPC* processor
designed to convert floating-point numbers to signed integers.  This
hardware clamps any floating-point value too large to be represented
as a 32-bit signed integer to the nearest representable value.  The
largest representable positive integer (2^31-1) is denoted as MAXINT
and the smallest representable negative integer (2^31) as MAXNINT.
The steps are  as follows:
  1.  Color Rescaling
        The computed color intensities are rescaled by performing
       a multiply-add operation to obtain a new floating-point
       intensity, where
        colorNew = (2^32 - 1) * colorIn - 2^31.
        In this conversion, a floating-point intensity 0.0 is
       converted to -2^31 (MAXNINT) and an intensity of 1.0 is
       converted to 2^31-1 (MAXINT).
  2.  Float-To-Fixed Conversion

          The rescaled floating-point intensity (colorNew) is
    converted to another floating-point value (colorFixed) in which
    the 32 low-order bits hold the fixed-point value of colorNew,
    rounded to the nearest integer.  This approach uses the PowerPC
    instruction "fctiw" (Floating-Point Convert to Integer Word) to
    perform the conversion.  The fctiw instruction handles overflow
    conditions by clamping.  If colorNew is less than MAXNINT,...