Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of...

19
Presented by: Stacy C. Lovell

Transcript of Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of...

Page 1: 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,

Presented by: Stacy C. Lovell

Page 2: 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,

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

Page 3: 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,

The eyeRetina contains cones that register

different photonsrods cones

light

bipolar

ganglion

horizontal

amacrine

Page 4: 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,

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.

Page 5: 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,

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.

Page 6: 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,

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)

Page 7: 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,

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 28 = 256 different values or colors that can be stored at the pixel.

Page 8: 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,

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

Page 9: 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,

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.

Page 10: 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,

Alpha

Alpha value has no direct affect on color displayed on screen

Used for blending and transparency

Page 11: 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,

Color Cube

Page 12: 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,

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

Page 13: 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,

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

Page 14: 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,

There are two modes, RGBA and color-index mode -- we won’t 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).

Page 15: 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,

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

Page 16: 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,

Dithering

Page 17: 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,

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

Page 18: 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,

Shading ModelsglShadeModel(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();

Page 19: 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,

Shading ModelsglShadeModel(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();