COMP471 - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

COMP471

Description:

A given surface can emit, reflect, etc this energy. Light bulb ... Translucent. October 2, 2002. Serguei A. Mokhov, mokhov_at_cs.concordia.ca. 9. OpenGL and Light ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 19
Provided by: alcorCo
Category:

less

Transcript and Presenter's Notes

Title: COMP471


1
COMP471 Computer Graphics
  • OpenGL Let There Be Light

2
Whats Light?
  • Light is energy
  • A given surface can emit, reflect, etc this
    energy.
  • Light bulb is emitting surface
  • Some other surface reflecting base on properties
    and material of that surface
  • White light contains all the color spectrum

3
Light Sources
  • Ambient
  • Point
  • Spotlight
  • Distant

4
Ambient Light
  • Uniform illumination of the objects in a given
    environment.
  • Coming from nowhere and going to nowhere.
  • Its a diffuse light w/o a direction
  • Good to highlight a little a dark scene

5
Point Light
6
Spotlight
  • GL_SPOT_CUTOFF ?

?
7
Distant Light Source
  • Parallel
  • The source is very-very far (like Sun)
  • Directional vector determines such a parallel
    light source

8
Material
  • Surfaces can have different material properties.
  • These properties determine how a given surface
    will reflect a light.

Diffuse
Secular (shiny)
Translucent
9
OpenGL and Light
  • Light sources
  • Spotlight
  • Distant
  • Emissive
  • Material

10
Light Sources
  • Enable Lighting (another OpenGL state)
  • glEnable(GL_LIGHTING)
  • Enable one of the light sources
  • glEnable(GL_LIGHT0)
  • Define light source atttibutes
  • glLight(GL_LIGHT0, .)

11
Material
  • GLfloat ambient 0.2,0.2,0.2,1.0
  • glMaterialfv(GL_FRONT,GL_AMBIENT, ambient)

12
Light Positioning
  • Fixed
  • Moving around stationary objects
  • Moving along with the viewpoint
  • NOTE Position and direction of light are
    affected by the current Model-View matrix.

13
Fixed Light Position
  • glMatrixMode(GL_MODELVIEW)
  • glLoadIdentity()
  • glLightfv(, GL_POSITION, pos)
  • other transformations

14
Independently Moving Light
  • Set viewpoint coordinates
  • gluLookAt()
  • glPushMatrix()
  • glTranslate() glRotate()
  • glLight()
  • glPopMatrix()
  • draw objects

These transformations will apply only to the
light source.
15
Moving Light Source Along With the Viewpoint
  • Set light source position pos
  • glMatrixMode(GL_MODELVEIW)
  • glLoadIdentity()
  • glLightfv(..., GL_POSITION, pos)
  • Change the viewpoint

16
Normals
  • For the light to highlight proper side of an
    object, a normal has to be defined for that side.
  • Use glNormal() right before you draw the polygon
    for it to be lit properly.
  • There are default normals however, they might
    not be what you want them to be, so when dealing
    with light and textures mapping explicitly state
    the normals.

17
Normals (2)
void Cubedraw() // Front
glNormal3f(0.0, 0.0, 1.0) drawFace(0, 3, 2,
1, 0) // Right glNormal3f(1.0, 0.0,
0.0) drawFace(2, 3, 7, 6, 1) // Bottom
glNormal3f(0.0, -1.0, 0.0) drawFace(0, 4,
7, 3, 2)
// Top glNormal3f(0.0, 1.0, 0.0)
drawFace(1, 2, 6, 5, 3) // Back
glNormal3f(0.0, 0.0, -1.0) drawFace(4, 5, 6,
7, 4) // Left glNormal3f(-1.0, 0.0,
0.0) drawFace(0, 1, 5, 4, 5)
18
References
  • Jianxiang Dong Slides from Fall 2001
Write a Comment
User Comments (0)
About PowerShow.com