Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.

Similar presentations


Presentation on theme: "CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008."— Presentation transcript:

1 CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008

2 Today Finish transformation in OpenGL Lighting Reading – Shirley, Ch 9.1, 9.2

3 Connecting primitives glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); glRotate(-90, 0, 0, 1); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); glRotate(-90, 0, 0, 1); Draw_block_B(); A B

4 3D Example: A robot arm Consider this robot arm with 3 degrees of freedom: – Base rotates about its vertical axis by  – Upper arm rotates in its xy-plane by  – Lower arm rotates in its xy-plane by  h1h1 h2h2 h3h3 Base Upper arm Lower arm Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  ) z x y x y x

5 Robot arm implementation The robot arm can be displayed by keeping a global matrix and computing it at each step: Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Do the matrix computations seem wasteful? How to translate the whole robot? Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  ) Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  )

6 Instead of recalculating the global matrix each time, we can just update it in place by concatenating matrices on the right: Robot arm implementation, better Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); }

7 OpenGL maintains the model-view matrix, as a global state variable which is updated by concatenating matrices on the right. display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } Robot arm implementation, OpenGL

8 Hierarchical modeling Hierarchical models can be composed of instances using trees: – edges contain geometric transformations – nodes contain geometry (and possibly drawing attributes) How might we draw the tree for the robot arm?

9 A complex example: human figure Q: What’s the most sensible way to traverse this tree?

10 Human figure implementation, OpenGL figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... } figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... }

11 So far… We’ve talked exclusively about geometry. – What is the shape of an object? glBegin() … glEnd() – How do I place it in a virtual 3D space? glMatrixMode() … – How to change viewpoints gluLookAt() – How do I know which pixels it covers? Rasterization – How do I know which of the pixels I should actually draw? Z-buffer, BSP

12 So far glColor(…); Apply_transforms(); Draw_objects(); glColor(…); Apply_transforms(); Draw_objects(); Lit surface Flat shaded

13 Next… Once we know geometry, we have to ask one more important question: – To what value do I set each pixel? Answering this question is the job of the shading model. Other names: – Lighting model – Light reflection model – Local illumination model – Reflectance model – BRDF

14 An abundance of photons Properly determining the right color is really hard. Particle Scattering

15 An abundance of photons Properly determining the right color is really hard. Translucency

16 An abundance of photons Properly determining the right color is really hard. Refraction

17 An abundance of photons Properly determining the right color is really hard. Global Effect

18 Our problem We’re going to build up to an approximation of reality called the Phong illumination model. It has the following characteristics: – not physically based – gives a “first-order” approximation to physical light reflection – very fast – widely used In addition, we will assume local illumination, i.e., light goes: light source -> surface -> viewer. No interreflections, no shadows.

19 Setup… Given: – a point P on a surface visible through pixel p – The normal N at P – The lighting direction, L, and intensity, L ,at P – The viewing direction, V, at P – The shading coefficients at P Compute the color, I, of pixel p. Assume that the direction vectors are normalized:

20 “Iteration zero” The simplest thing you can do is… Assign each polygon a single color: where – I is the resulting intensity – k e is the emissivity or intrinsic shade associated with the object This has some special-purpose uses, but not really good for drawing a scene.

21 “Iteration one” Let’s make the color at least dependent on the overall quantity of light available in the scene: – k a is the ambient reflection coefficient. really the reflectance of ambient light “ambient” light is assumed to be equal in all directions – L a is the ambient light intensity. Physically, what is “ambient” light?

22 Ambient Term Hack to simulate multiple bounces, scattering of light Assume light equally from all directions Slide from Ravi Ramamoorthi

23 Wavelength dependence Really, k e, k a, and L a are functions over all wavelengths. Ideally, we would do the calculation on these functions. For the ambient shading equation, we would start with: then we would find good RGB values to represent the spectrum I( ). Traditionally, though, k a and I a are represented as RGB triples, and the computation is performed on each color channel separately:

24 Diffuse reflection So far, objects are uniformly lit. – not the way things really appear – in reality, light sources are localized in position or direction Diffuse, or Lambertian reflection will allow reflected intensity to vary with the direction of the light.

25 Diffuse reflectors Diffuse reflection occurs from dull, matte surfaces, like latex paint, or chalk. These diffuse or Lambertian reflectors reradiate light equally in all directions.

26 Diffuse reflectors Diffuse reflection occurs from dull, matte surfaces, like latex paint, or chalk. These diffuse or Lambertian reflectors reradiate light equally in all directions. Picture a rough surface with lots of tiny microfacets.

27 Diffuse reflectors …or picture a surface with little pigment particles embedded beneath the surface (neglect reflection at the surface for the moment): The microfacets and pigments distribute light rays in all directions. Embedded pigments are responsible for the coloration of diffusely reflected light in plastics and paints. Note: the figures above are intuitive, but not strictly (physically) correct.

28 Diffuse reflectors, cont. The reflected intensity from a diffuse surface does not depend on the direction of the viewer. The incoming light, though, does depend on the direction of the light source:

29 “Iteration two” The incoming energy is proportional to cos , giving the diffuse reflection equations: where: – k d is the diffuse reflection coefficient – L d is the intensity of the light source – N is the normal to the surface (unit vector) – L is the direction to the light source (unit vector)

30 Specular reflection Specular reflection accounts for the highlight that you see on some objects. It is particularly important for smooth, shiny surfaces, such as: – Metal, polished stone, plastics, apples, Skin

31 Specular reflection Properties: – Specular reflection depends on the viewing direction V. – For non-metals, the color is determined solely by the color of the light. – For metals, the color may be altered (e.g., brass)

32 Specular reflection “derivation” For a perfect mirror reflector, light is reflected about N, so For a near-perfect reflector, you might expect the highlight to fall off quickly with increasing angle . Also known as: – “rough specular” reflection – “directional diffuse” reflection – “glossy” reflection

33 Derivation, cont. One way to get this effect is to take (R·V), raised to a power n s. As n s gets larger, – the dropoff becomes {more,less} gradual – gives a {larger,smaller} highlight – simulates a {more,less} mirror-like surface

34 “Iteration three” The next update to the Phong shading model is then: where: – k s is the specular reflection coefficient – n s is the specular exponent or shininess – R is the reflection of the light about the normal (unit vector) – V is viewing direction (unit vector)

35 Specular Reflection Improvement Compute based on normal vector and “halfway” vector, H – Always positive when the light and eye are above the tangent plane – Not quite the same result as the other formulation (need 2H) LV NH

36 Putting It Together Just sum all the terms If there are multiple lights, sum contributions from each light Several variations, and approximations …

37 Lights OpenGL supports three different kinds of lights: ambient, directional, and point. Spot lights are also supported as a special form of point light. We’ve seen ambient light sources, which are not really geometric. Directional light sources have a single direction and intensity associated with them.

38 Point lights The direction of a point light sources is determined by the vector from the light position to the surface point. Physics tells us the intensity must drop off inversely with the square of the distance: Sometimes, this distance-squared dropoff is considered too “harsh.” A common alternative is: with user-supplied constants for a, b, and c.

39 Spotlights OpenGL also allows one to apply a directional attenuation of a point light source, giving a spotlight effect. The spotlight intensity factor is computed in OpenGL as: where – L is the direction to the point light. – S is the center direction of the spotlight. –  is the cutoff angle for the spotlight – e is the angular falloff coefficient –

40 “Iteration four” Since light is additive, we can handle multiple lights by taking the sum over every light. Our equation is now: This is the Phong illumination model. Which quantities are spatial vectors? Which are RGB triples? Which are scalars?

41 Choosing the parameters Experiment with different parameter settings. To get you started, here are a few suggestions: – Try n s in the range [0,100] – Try k a + k d + k s < 1 – Use a small k a (~0.1) nsns kdkd ksks MetallargeSmall, color of metal Large, color of metal Plasticmedium Medium, color of plastic Medium, white Planet0varying0

42 Materials in OpenGL The OpenGL code to specify the surface shading properties is fairly straightforward. For example: GLfloat ke[] = { 0.1, 0.15, 0.05, 1.0 }; GLfloat ka[] = { 0.1, 0.15, 0.1, 1.0 }; GLfloat kd[] = { 0.3, 0.3, 0.2, 1.0 }; GLfloat ks[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat ns[] = { 50.0 }; glMaterialfv(GL_FRONT, GL_EMISSION, ke); glMaterialfv(GL_FRONT, GL_AMBIENT, ka); glMaterialfv(GL_FRONT, GL_DIFFUSE, kd); glMaterialfv(GL_FRONT, GL_SPECULAR, ks); glMaterialfv(GL_FRONT, GL_SHININESS, ns); Notes: – The GL_FRONT parameter tells OpenGL that we are specifiying the materials for the front of the surface. – Only the alpha value of the diffuse color is used for blending. It’s usually set to 1.

43 Shading in OpenGL The OpenGL lighting model allows you to associate different lighting colors according to material properites they will influence. Thus, our original shading equation: becomes: where you can have a global ambient light with intensity L a in addition to having an ambient light intensity L a j associated with each individual light.

44 BRDF The Phong illumination model is really a function that maps light from incoming (light) directions  in to outgoing (viewing) directions  out : This function is called the Bi-directional Reflectance Distribution Function (BRDF). Here’s a plot with  in held constant: BRDF’s can be quite sophisticated…

45 BRDF measurement Stanford Graphics Lab

46 More sophisticated BRDF’s Westin, Arvo, Torrance 1992 Cook and Torrance, 1982

47 Gouraud vs. Phong interpolation Now we know how to compute the color at a point on a surface using the Phong lighting model. Does graphics hardware do this calculation at every point? Typically not (although this is changing)… Smooth surfaces are often approximated by polygonal facets. So How do we compute the shading for such a surface?

48 Faceted shading Assume each face has a constant normal: If we have constant material properties over the surface, how will the color of each triangle vary? Result: faceted, not smooth, appearance.

49 Faceted shading (cont’d)

50 Gouraud interpolation To get a smoother result that is easily performed in hardware, we can do Gouraud interpolation. Here’s how it works: 1.Compute normals at the vertices. 2.Shade only the vertices. 3.Interpolate the resulting vertex colors.

51 Facted shading vs. Gouraud interpolation

52 Gouraud interpolation artifacts Gouraud interpolation has significant limitations. – If the polygonal approximation is too coarse, we can miss specular highlights.

53 Phong interpolation To get an even smoother result with fewer artifacts, we can perform Phong interpolation. Here’s how it works: 1.Compute normals at the vertices. 2.Interpolate normals and normalize. 3.Shade using the interpolated normals.

54 Gouraud vs. Phong interpolation

55 Define a light in OpenGL GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_POSITION, light_position); GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_POSITION, light_position);

56 Light.c void init(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void init(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSolidSphere (1.0, 20, 16); glFlush (); } void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSolidSphere (1.0, 20, 16); glFlush (); }

57 Light.c

58 Demo

59 Complex lighting How to have multiple lights? How to change lighting positions? How to change color material?

60 Multiple lights GLfloat light1_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat light1_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light1_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light1_position[] = { -2.0, 2.0, 1.0, 1.0 }; GLfloat spot_direction[] = { -1.0, -1.0, 0.0 }; glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.5); glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5); glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.2); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0); glEnable(GL_LIGHT1); GLfloat light1_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat light1_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light1_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light1_position[] = { -2.0, 2.0, 1.0, 1.0 }; GLfloat spot_direction[] = { -1.0, -1.0, 0.0 }; glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.5); glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5); glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.2); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0); glEnable(GL_LIGHT1);

61 Moving light source Method 1: – Use glLightfv(GL_LIGHT1, GL_POSITION, light1_position); Method 2: – Use transformation

62 Moving a light source Use glLightfv(GL_LIGHT1, GL_POSITION, light1_position);

63 Moving light source static GLdouble spin; void display(void) { GLfloat light_position[] = { 0.0, 0.0, 1.5, 1.0 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotated(spin, 1.0, 0.0, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glPopMatrix(); glutSolidTorus (0.275, 0.85, 8, 15); glPopMatrix(); glFlush(); } static GLdouble spin; void display(void) { GLfloat light_position[] = { 0.0, 0.0, 1.5, 1.0 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotated(spin, 1.0, 0.0, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glPopMatrix(); glutSolidTorus (0.275, 0.85, 8, 15); glPopMatrix(); glFlush(); }

64 Rotating a light source demo.

65 glColorMaterial glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_DIFFUSE); /* now glColor* changes diffuse reflection */ glColor3f(0.2, 0.5, 0.8); /* draw some objects here */ glColorMaterial(GL_FRONT, GL_SPECULAR); /* glColor* no longer changes diffuse reflection */ /* now glColor* changes specular reflection */ glColor3f(0.9, 0.0, 0.2); /* draw other objects here */ glDisable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_DIFFUSE); /* now glColor* changes diffuse reflection */ glColor3f(0.2, 0.5, 0.8); /* draw some objects here */ glColorMaterial(GL_FRONT, GL_SPECULAR); /* glColor* no longer changes diffuse reflection */ /* now glColor* changes specular reflection */ glColor3f(0.9, 0.0, 0.2); /* draw other objects here */ glDisable(GL_COLOR_MATERIAL);

66 glColorMaterial Demo

67 glColorMaterial void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) { /* change red */ diffuseMaterial[0] += 0.1; if (diffuseMaterial[0] > 1.0) diffuseMaterial[0] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; case GLUT_MIDDLE_BUTTON: if (state == GLUT_DOWN) { /* change green */ diffuseMaterial[1] += 0.1; if (diffuseMaterial[1] > 1.0) diffuseMaterial[1] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) { /* change blue */ diffuseMaterial[2] += 0.1; if (diffuseMaterial[2] > 1.0) diffuseMaterial[2] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; default: break; } void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) { /* change red */ diffuseMaterial[0] += 0.1; if (diffuseMaterial[0] > 1.0) diffuseMaterial[0] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; case GLUT_MIDDLE_BUTTON: if (state == GLUT_DOWN) { /* change green */ diffuseMaterial[1] += 0.1; if (diffuseMaterial[1] > 1.0) diffuseMaterial[1] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) { /* change blue */ diffuseMaterial[2] += 0.1; if (diffuseMaterial[2] > 1.0) diffuseMaterial[2] = 0.0; glColor4fv(diffuseMaterial); glutPostRedisplay(); } break; default: break; }

68 Shading in OpenGL, cont’d Notes: You can have as many as GL_MAX_LIGHTS lights in a scene. This number is system-dependent. For directional lights, you specify a light direction, not position, and the attenuation and spotlight terms are ignored. The directions of directional lights and spotlights are specified in the coordinate systems of the lights, not the surface points as we’ve been doing in lecture.

69 Compute vertex normals

70

71 Stationary Light We know how to


Download ppt "CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008."

Similar presentations


Ads by Google