MTEC1311: Computer Graphics Lecture#1
Introduction to Computer
Graphics
Dr. M. Munlin
Assistance Professor
Faculty of information Science and Technology
Mahanakorn University of Technology
IST, MUT Dr.M. Munlin : Computer Graphics
1
Objectives
• Learn elements of graphics
• Learn
L graphics
hi applications
li ti
• Learn image formation
• Learn camera model
• Learn graphics pipeline architecture
• Learn
L application
li ti P Programming
i IInterface
t f (API)
IST, MUT Dr.M. Munlin : Computer Graphics
2
1
Computer Graphics
• Computer graphics deals with all aspects
of creating images with a computer
- Hardware
- Software
- Applications
IST, MUT Dr.M. Munlin : Computer Graphics
3
Example
• Where did this image come from?
• What hardware/software did we need to
produce it?
IST, MUT Dr.M. Munlin : Computer Graphics
4
2
Preliminary Answer
• Application: The object is an artist’s
rendition of the sun for an animation to be
shown in a domed environment
(planetarium)
• Software: Maya for modeling and
rendering but Maya is built on top of
OpenGL
• Hardware: PC with graphics card for
modeling and rendering
IST, MUT Dr.M. Munlin : Computer Graphics
5
Basic Graphics System
Output device
Input devices
Image formed in FB
IST, MUT Dr.M. Munlin : Computer Graphics
6
3
Output Device: CRT
Can be used either as a line-drawing
device (calligraphic) or to display contents
of frame buffer (raster mode)
IST, MUT Dr.M. Munlin : Computer Graphics
7
Shadow Mask CRT
Ensure that an electron beam excites only
phosphors of the proper pixel.
IST, MUT Dr.M. Munlin : Computer Graphics
8
4
Output Device: Projection TV
• Projection TVs can provide a much bigger
picture than CRT can
• It can be a plasma TV or color LCD
IST, MUT Dr.M. Munlin : Computer Graphics
9
Color LCD
An LCD that can show colors must have
three sub-pixels with red, green and blue
color filters to create each color pixel.
IST, MUT Dr.M. Munlin : Computer Graphics
10
5
Computer Graphics: 1960-1970
• Wireframe graphics
- Draw only lines
• Sketchpad
• Display Processors
• Storage tube
wireframe representation
of sun object
IST, MUT Dr.M. Munlin : Computer Graphics
11
Sketchpad
• Ivan Sutherland’s
Sutherland s PhD
thesis at MIT
- Recognized the potential of man-machine
interaction
- Loop
• Display
p y something g
• User moves light pen
• Computer generates new display
- Sutherland also created many of the now
common algorithms for computer graphics
IST, MUT Dr.M. Munlin : Computer Graphics
12
6
Display Processor
• Rather than have the host computer try to
refresh display use a special purpose computer
called a display processor (DPU)
• Graphics stored in display list (display file) on
display processor
• Host compiles display list and sends to DPU
IST, MUT Dr.M. Munlin : Computer Graphics
13
Computer Graphics: 1970-1980
• Raster Graphics
• Beginning
B i i off graphics
hi standards
t d d
- IFIPS
• GKS: European effort
– Becomes ISO 2D standard
• Core: North American effort
– 3D but fails to become ISO standard
• Workstations and PCs
IST, MUT Dr.M. Munlin : Computer Graphics
14
7
Raster Graphics
• Image produced as an array (the raster)
of picture elements (pixels) in the frame
buffer
IST, MUT Dr.M. Munlin : Computer Graphics
15
Computer Graphics: 1980-1990
Realism comes to computer graphics
smooth shading environment bump mapping
mapping
IST, MUT Dr.M. Munlin : Computer Graphics
16
8
Computer Graphics: 1980-1990
• Special purpose hardware
- Silicon Graphics geometry engine
• VLSI implementation of graphics pipeline
• Industry-based standards
- PHIGS
• Networked graphics: X Window System
• Human-Computer Interface (HCI)
IST, MUT Dr.M. Munlin : Computer Graphics
17
Computer Graphics: 1990-2000
• OpenGL API
• Completely
C l t l computer-generated
t t d feature-
f t
length movies (Toy Story) are successful
• New hardware capabilities
- Texture mapping
g
- Blending
- Accumulation, stencil buffers
IST, MUT Dr.M. Munlin : Computer Graphics
18
9
Computer Graphics: 2000-
• Photorealism
• Graphics
G hi cards d ffor PC
PCs d
dominate
i t market
k t
- Nvidia, ATI
• Game boxes and game players determine
direction of market
• Computer graphics routine in movie
industry: Maya, Lightwave
• Programmable pipelines
IST, MUT Dr.M. Munlin : Computer Graphics
19
Graphics Applications
Film and animation
IST, MUT Dr.M. Munlin : Computer Graphics
20
10
Graphics Applications
Games
IST, MUT Dr.M. Munlin : Computer Graphics
21
Graphics Applications
Medical Imaging
IST, MUT Dr.M. Munlin : Computer Graphics
22
11
Graphics Applications
Computer Aided Design (CAD)
IST, MUT Dr.M. Munlin : Computer Graphics
23
Graphics Applications
Scientific Visualisation
IST, MUT Dr.M. Munlin : Computer Graphics
24
12
Image Formation
• In computer graphics, we form images
which are generally two dimensional using
a process analogous to how images are
formed by physical imaging systems
- Cameras
- Microscopes
- Telescopes
- Human visual system
IST, MUT Dr.M. Munlin : Computer Graphics
25
Elements of Image Formation
• Objects
• Viewer
Vi
• Light source(s)
• Attributes that govern how light interacts
with the materials in the scene
• Note the independence of the objects, the
viewer, and the light source(s)
IST, MUT Dr.M. Munlin : Computer Graphics
26
13
Light
• Light is the part of the electromagnetic spectrum that
causes a reaction in our visual systems
y
• Generally these are wavelengths in the range of about
350-750 nm (nanometers)
• Long wavelengths appear as reds and short
wavelengths as blues
IST, MUT Dr.M. Munlin : Computer Graphics
27
Ray Tracing and
Geometric Optics
One way to form an image is to
f ll
follow rays off light
li ht ffrom a
point source finding which
rays enter the lens of the
camera. However, each
ray off light
li ht may h have
multiple interactions with objects
before being absorbed or going to infinity.
IST, MUT Dr.M. Munlin : Computer Graphics
28
14
Additive and Subtractive Color
• Additive color
- Form a color by adding amounts of three
primaries
• CRTs, projection systems, positive film
- Primaries are Red (R), Green (G), Blue (B)
• Subtractive color
- Form a color by filtering white light with cyan
(C) M
(C), Magenta
t (M)
(M), and dY
Yellow
ll (Y) filt
filters
• Light-material interactions
• Printing
• Negative film
IST, MUT Dr.M. Munlin : Computer Graphics
29
Graphics Pipeline
Architecture
• Process objects one at a time in the order
they are generated by the application
- Can consider only local lighting
• Pipeline architecture
application
pp display
program
• All steps can be implemented in hardware
on the graphics card
IST, MUT Dr.M. Munlin : Computer Graphics
30
15
Vertex Processing
• Much of the work in the pipeline is in converting
object representations from one coordinate
system to another
- Object coordinates
- Camera (eye) coordinates
- Screen coordinates
• Every change of coordinates is equivalent to a
matrix transformation
• Vertex processor also computes vertex colors
IST, MUT Dr.M. Munlin : Computer Graphics
31
Projection
• Projection is the process that combines
the 3D viewer with the 3D objects to
produce the 2D image
- Perspective projections: all projectors meet at
the center of projection
- Parallel projection: projectors are parallel,
center of projection is replaced by a direction of
projection
IST, MUT Dr.M. Munlin : Computer Graphics
32
16
Parallel and Perspective
Projection
IST, MUT Dr.M. Munlin : Computer Graphics
33
Primitive Assembly
Vertices must be collected into geometric
objects before clipping and rasterization
can take place
- Line segments
- Polygons
- Curves and surfaces
IST, MUT Dr.M. Munlin : Computer Graphics
34
17
Clipping
Just as a real camera cannot “see” the
whole world,, the virtual camera can onlyy
see part of the world or object space
- Objects that are not within this volume are said
to be clipped out of the scene
IST, MUT Dr.M. Munlin : Computer Graphics
35
Rasterization
• If an object is not clipped out, the appropriate
pixels in the frame buffer must be assigned colors
• Rasterizer produces a set of fragments for each
object
• Fragments are “potential pixels”
- Have a location in frame bufffer
- Color and depth
p attributes
• Vertex attributes are interpolated over objects by
the rasterizer
IST, MUT Dr.M. Munlin : Computer Graphics
36
18
Fragment Processing
• Fragments are processed to determine
the color of the corresponding pixel in the
frame buffer
• Colors can be determined by texture
mapping or interpolation of vertex colors
g
• Fragments may y be blocked by
y other
fragments closer to the camera
- Hidden-surface removal
IST, MUT Dr.M. Munlin : Computer Graphics
37
The Programmer’s Interface
• Programmer sees the graphics system
through a software interface: the
Application Programming Interface (API),
e.g. OpenGL
IST, MUT Dr.M. Munlin : Computer Graphics
38
19
Object Specification
• Most APIs support a limited set of
primitives including
- Points (0D object)
- Line segments (1D objects)
- Polygons (2D objects)
- Some curves and surfaces
• Quadrics
• Parametric polynomials
• All are defined through locations in space
or vertices
IST, MUT Dr.M. Munlin : Computer Graphics
39
OpenGL Object API
type of object
location
ocat o of
o vertex
ve te
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd( );
end of object definition
glClearColor(1.0, 1.0, 1.0, 1.0); // background color white
glColor3f(1.0, 0.0, 0.0); // foreground color red
IST, MUT Dr.M. Munlin : Computer Graphics
40
20
Camera Specification
• Six degrees of freedom
- Position of center of lens
- Orientation
• Lens
• Film size
• Orientation of film plane
IST, MUT Dr.M. Munlin : Computer Graphics
41
OpenGL Camera API
pprojector
j
p
image plane
projection of p
center off projection
j i
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
IST, MUT Dr.M. Munlin : Computer Graphics
42
21
Example: Triangle
IST, MUT Dr.M. Munlin : Computer Graphics 43
GLUT API
glutWireCube(1.0); // wireframe cube
glutInit(&argc, argv); // init program
// init display
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500); // init window size
glutInitWindowPosition(100, 100); // init window pos
glutCreateWindow(argv[0]); // create window
init(); // init program environments
glutDisplayFunc(display); // display function
glutReshapeFunc(reshape); // re-display function
glutMainLoop(); // program loop
IST, MUT Dr.M. Munlin : Computer Graphics
44
22
Example: Cube
IST, MUT Dr.M. Munlin : Computer Graphics
45
Summary
• Elements of graphics consists of HW, SW and
applications.
pp
• Area of graphics applications are entertainment, industry,
medical, academic, etc.
• Image formation consists of object, light and viewer.
• Computer camera model is similar to real camera.
• Graphics pipeline architecture contains several stages to
produce a realistic graphics image
image.
• Application Programming Interface (API) helps
programmer to program graphics much easier.
IST, MUT Dr.M. Munlin : Computer Graphics
46
23
Q&A
0. List 5 major elements of a graphics system
1. Give examples of Graphics HW, SW, and applications.
2. What does the display resolution 1280x800 mean ?
3. How does computer display and image ?
4. Why do we need clipping ?
5. Describe graphics pipelines.
6. How important is API?
7. Explain the camera model.
IST, MUT Dr.M. Munlin : Computer Graphics
47
24