# Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,

## Presentation on theme: "Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,"— Presentation transcript:

Presented by: Stacy C. Lovell

How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green, and Blue (RGB) Sensation of color is created in our brains by averaging and recognizing millions of combinations of red, green, and blue

The eye Retina contains cones that register different photons rods cones light bipolar ganglion horizontal amacrine

Newton observed that color is not inherent in objects, rather, the surface of an object reflects some colors and absorbs others. We only perceive the reflected colors.

OpenGL Colors OpenGL can have one of two color modes, Indexed colors or RGBA. When we defined the window we defined the color mode: glutInitDisplayMode( GLUT_RGBA … ) Once defined it cannot be changed.

RGB (and sometimes A) Color model Red, green, and blue pixels are assigned brightness values 0 to 1 where 0 is none or dark (0,0,0) = black (1,1,1) = white You can then specify the exact color to be mixed A computer monitor is only capable of producing a certain range of color, and is further reduced by the limitations of computer hardware. It can display up to 16.7 million colors (with 24 bitplanes)

RGBA mode continued A certain amount of color data is stored at each pixel, determined by number of bitplanes in framebuffer Bitplane contains 1 bit of data for each pixel If there are eight color bitplanes, there are 8 color bits per pixel, and hence 2 8 = 256 different values or colors that can be stored at the pixel.

Color Depth Jumlah bitplane yang digunakan untuk mewakili satu nilai warna RGB Color biasanya ditampilkan dalam 24 bits (3 bytes atau 8 bits tiap warna) contoh (255, 255, 255) putih

RGBA Color As you can see, color can have 3 of 4 values: R- the Red color value. G- the Green color value. B- the Blue color value. A- the Transparent color value.

Alpha Alpha value has no direct affect on color displayed on screen Used for blending and transparency

Color Cube

Specifying color in OpenGL glColor3f(1.0, 0.0, 0.0); //sets RGB color to red glBegin(GL_POINTS); glVertex3f(….) //draw some vertices glEnd(); The color drawn will be red until it is changed glColor4f (1.0,0.0,0.0,0.5) ; //to set an alpha value

Colors glColor3f(face color) render_face() glColor3f(eye color) render_eyes() glColor3f(hair color) render_hair() glColor3f(teeth color) render_teeth()

There are two modes, RGBA and color-index mode -- we wont be dealing with color-index mode, but feel free to read up on it if you are interested If lighting is enabled, color is determined from the interaction of the transformation matrices with the surface normals and other material properties A 2-bit indexed color image. The color of each pixel is represented by a number; each number (the index) corresponds to a color in the color table (the palette).pixelpalette

Dithering The technique of using combinations of some colors to create the effect of other colors For example, to display pink, the hardware can fill the region by alternating red and white pixels. glEnable(GL_DITHER); or glDisable Enabled by default

Dithering

Specifying a shading model Lines and filled polygons can be drawn with a single color (flat shading) or with many different colors (smooth shading) glShadeModel(GL_SMOOTH); //default Or GL_FLAT For smooth shading, colors along the line segment are interpolated between vertex colors For polygons, colors along the interior are interpolated between vertex colors

Shading Models glShadeModel(GL_FLAT); glBegin(GL_QUADS); glColor3f (1.0,0.0,0.0); glVertex3f(0.0,0.0,0.0); glColor3f (0.0,1.0,0.0); glVertex3f(1.0,0.0,0.0); glColor3f (0.0,0.0,1.0); glVertex3f(1.0,1.0,0.0); glColor3f (1.0,1.0,0.0); glVertex3f(0.0,1.0,0.0); glEnd();

Shading Models glShadeModel(GL_SMOOTH); glBegin(GL_QUADS); glColor3f (1.0,0.0,0.0); glVertex3f(0.0,0.0,0.0); glColor3f (0.0,1.0,0.0); glVertex3f(1.0,0.0,0.0); glColor3f (0.0,0.0,1.0); glVertex3f(1.0,1.0,0.0); glColor3f (1.0,1.0,0.0); glVertex3f(0.0,1.0,0.0); glEnd();

Similar presentations