1Color and TextureCS148: Intro to CGInstructor: Dan MorrisTA: Sean WalkerJuly 19, 2005Pre-Lecture Business{ Get going on pp3!{ TOBOR’s greatest hits{ Exam question reviewTOBOR’s Greatest HitsTough-guy TOBORMs. TOBORTOBOR’s Greatest HitsRipped TOBORTOBOR 2050Transformation Question (3b)glMatrixMode(GL_PROJECTION);glLoadIdentity();glMatrixMode(GL_MODELVIEW);glLoadIdentity();glRotatef( -90.0 , 0.0 , 1.0 , 0.0 );glScalef( 1.0 , 1.0 , 0.5 );glTranslatef ( 0.0 , 2.0 , 0.0 );glScalef( 0.0 , 2.0 , 2.0 );glTranslatef( 0.0 , -2.0 , 0.0 );glRotatef( 180.0 , 0.0 , 1.0 , 0.0 );glVertex3f( 1.0 , 1.0 , 1.0 );(1,0,0)(0,0,-1)(0,0,-2)(0,-2,-2)(-1,-1,-1)(-1,1,-1)(1,1,1)Transformation Question (3a)glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef( 0.0 , 0.0 , 1.0 );glMatrixMode(GL_PROJECTION);glLoadIdentity();glRotatef( 90.0 , 0.0 , 0.0 , 1.0 );glTranslatef(-1.0 , 0.0 , 0.0 );glMatrixMode(GL_MODELVIEW);glRotatef( 90.0 , 0.0 , 1.0 , 0.0 );glTranslatef( -1.0 , 0.0 , 0.0 );glVertex3f( 2.0 , 0.0 , 0.0 ); (0,0,0)(0,-1,0)(-1,0,0)(0,0,-1)(1,0,0)(2,0,0)2Outline for today{ Color and Color Spaces{ Texture MappingWhat is light?{ Photons: “particles of energy”{ The intensity of a radiation source is defined by its rate of photon emission{ The “character” of a photon is defined by its wavelengthWhat is a color?{ The wavelength of a single photon defines a color{ The wavelength of a beam of “pure”light (one wavelength) defines a color400nm700nmWhat’s wrong with this definition?{ Intuitively, white is a color, but white doesn’t have a wavelength.{ Most “colors” are really combinations of wavelengths{ How many colors are there in this rectangle?Human Color Perception in 1 Slide{ Photons hit our eyes and activate cone photoreceptors{ A signal is sent up the optic nerve to our brain, and we perceive color{ There are only three kinds of cones in our eye, each sensitive to a range of wavelengthsWhy do coneresponsesoverlap?A Better Definition of Color{ A color is a particular pattern of cone activation: a perceived color{ There are many combinations of wavelengths that can produce the same color3Representing Color{ We need a way to represent this concept of color for applications in CG and print{ An intuitive way based on what we just learned:z A color is three numbers, each of which roughly represents the amount of activation of one cone type{ This is the theoretical basis for the RGB color model{ In practice, R, G, and B are wavelengths that are intended to optimally stimulate the RGB conesThe RGB Color Space{ Colors are combinations of the primaries R, G, and B:C = rR + gG + bB{ This is called an “additive color space”{ Can represent colors as points in the RGB coordinate space:Limitations of RGB{ Not all colors can be expressed in a purely additive space{ There are visible colors you can’t describe with RGB!What’s a negative color?CIE color experiments{ 1931: folks at CIE gave people dials to control red green, and blue guns { Gave them a “test color” to match with the dials{ If they couldn’t match a color, they could addsome RGB to the test color (this counted as “negative color”){ Generated standard “color matching” curvesCIE Color{ Defined a standard set of “primary colors” (X, Y, and Z) that could be mixed together to form the visible spectrum{ These “colors” were actually mixtures of many wavelengthsCIE XYZ Color Space{ X, Y, and Z can be treated as a color space just like R, G, and B{ C = X + Y + Z{ If we normalize for total brightness, we can get values that truly describe color (tone){ x = X / ( X + Y + Z )y = Y / ( X + Y + Z )z = Z / ( X + Y + Z ){ If we pick a constant brightness and call it 1.0, we can plot all possible colors on the x,y space…4CIE XYZ Chromaticity Diagram{ Represents all the visible colors in terms of (x,y){ Edges represent pure colors{ E is the “white point”EColor gamuts{ Gamut: the set of colors a particular device or color space can represent{ The triangle shows the standard RGB gamut… pretty disappointing…{ Most display devices are built to roughly match thisCan any three visible colors have a gamut that fills the visible space?Why not use CIE XYZ?{ CIE XYZ is a great theoretical space with an ideal gamut, but it doesn’t represent:z How we see (cone activation)z How monitors workz How printers workz Anything intuitive to an artist or programmer{ Used to define every other color spaceRGB revisited{ What an RGB space really is: a set of primaries R, G, and B defined in terms of X and Y{ There are many RGB spaces (sRGB, Adobe RGB, NTSC (TV) RGB){ People keep making up new ones because they better represent RGB hardware or because they have bigger gamutsWhat other spaces do we use?{ RGB is fairly intuitive and represents monitor activation well{ Doesn’t map well to what printers can produce{ Most printers print on white paper and the ink removes reflected color{ So we define a subtractive color space for printers…CMY: A Subtractive Color Space{ color = C + M + Yz C Æ cyan, M Æ magenta, Y Æ yellow{ (0,0,0) is white, (1,1,1) is black{ C = 1 – R, M = 1 – G, Y = 1 – B5CMYK: A hack to fix CMY{ Printers are built with cyan, yellow, and magenta ink{ (1,1,1) should be black, but in practice it’s not{ So printers add black ink to make true blackWhy else use black ink?Limitations of RGB and CMY{ Some operations are hard to express in RGB/CMY: make this color “more pale”, make this color “more vivid”{ Image processing applications and artists often need access to these operations{ Presenting a 2D color chooser in RGB is tough, since a “slice” from the RGB cube contains very similar colorsThe HSV color space{ Hue: what tone is this color (red, blue, teal, etc.)?z Red is 0˚ or 360˚{ Saturation: how colorful is this color?z 0 is grayscale, no color{ Value: how bright is this color?z 0 is blackVisualizing the HSV color spaceredyellowgreencyanbluemagentaWhat color space does Photoshop’s color picker display?OpenGL Trivia{ There is another (very rarely used) matrix mode in OpenGL:glMatrixMode(GL_COLOR);{ The color matrix is applied to all (RGBA) colors before they’re displayedWhat might I use the color matrix for?6Outline for today{ Color and Color Spaces{ Texture MappingWhat have we done so far?{ We can render 3D objects to the screen in glorious color{ We can apply realistic lighting to objects using geometry and surface normals{ But rendering something like this would require hella
View Full Document