Title: CG for Vision Research
1CG for Vision Research
- Lecture 2
- Winter Term 05-06
- Quoc Vuong, Franck Caniard, MPI
2OpenGL Projections Transformations Graphics
Primitives Textures Lighting Material Properties
Vision Research Viewpoint Effect Structure from X
(Motion, Shading, Stereo) Active
Exploration Navigation
GLUT Window Management Input Devices Event
Loop Timing
Fun/Advanced Modeling Animations Mapping (bumps,
terrains) Physics Simulation Sound (OpenAL)
3Lighting Materials Properties
4Lighting ? Realism
www.cs.kuleuven.be/cwis/research/graphics/RENDERPA
RK/
5more render time
www.winosi.onlinehome.de/Gallery_t14_01.htm
6The Cornell Box Which is real and which is
synthesized?
Left is real!
www.graphics.cornell.edu/online/box/compare.html
7Lighting
Illumination/Lighting Model
Shading Model
Global
Local
Flat
Gouraud
Phong
Reflected
Ambient
Directed
Scattered
www.ntsc-uk.com/features/BeautyPixelDeep/GouraudPh
ong.jpg
Directional
Positional
8Illumination Model
surface normal
Diffuse Reflection
Specular Reflection
Specifies interaction between light ray and
material
9- Material properties defined by illumination model
- Materials have a separate ambient, diffuse and
specular component
Mathworks 3-D Visualization
10en.wikipedia.org/wiki/Phong_shading
11Shading Model
- Specifies how illumination is applied locally to
vertices and ultimately pixels - Flat Compute the colour for a polygon, and use
this colour for the entire polygon - Gouraud Compute colour at vertices and
interpolate these colours across the polygon - Phong Compute colour by normal interpolation
during rasterization (Not implement in OpenGL lt
2.0)
12Flat
Gouraud
13Shape-from-Shading
- Three important components of shading models
- Position of light source
- Position of eye
- Surface normal
14Demos!
- Material properties (Lesson26_ball.exe)
- Shadows (Lesson27_shadows.exe)
15Culling
- For rendering efficiency, dont draw polygons
that are not visible - Culling or back-face elimination simple
operation that compares surface normals of
polygons to viewpoint and removes polygons that
cannot be seen
viewing volume
16Lighting Mat. Prop. in OpenGL
17Lighting in 5 Easy Steps
- Initialize OpenGL for lighting
- Define Normal vectors at each vertex
- From model, analytically or by polygon
approximation - Create, select and position one or more light
sources - Create and select a lighting model
- Global ambient level
- Location of viewpoint
- Define material properties of each object
- Colour (ambient, diffuse and emission)
- Specularity and shininess
18Initialization
19Create Light Source
20Types of Light Sources
21Material Properties
22Template Code 2
23Basic Structure
24The Event Loop (GLUT)
25Event-driven Model
- Standard approach in graphical-user interfaces
- Every action of program is response to user
events - Nothing (idle)
- Press key button
- Press mouse button or move mouse (or both)
- Interactivity with user
26The glutMainLoop
- void glutMainLoop(void)
- // pseudo-code
- loop forever
-
- check event queue
- if (event)
- // user performed some action (e.g., pressed
key) - invoke appropriate callback function (e.g.,
keyboard) -
- else
- // user idle
- if (idle function exists)
- invoke idle function (e.g., display scene)
-
- else
- sleep for 1 time unit
-
-
-
27The Loop Thickens
GLUT Event Loop
28- Make stationary light source
- Make light source move with viewpoint
- Add at least another light source
- Combine movelight.c with material.c
29This slide left intentionally blank