Title: Computer Graphics
1Computer Graphics
2Lecture Outline
- 2D vs. 3D graphics
- Basics of 3D graphics
- Graphics hardware
- Application Program Interfaces
- Comparisons and benchmarks
- Computer Graphics Applications
3The Emergence of 3-D Graphics
- 2-D graphics has been used for years for
illustration, diagrams, 2-D CAD, etc. - 3-D graphics has until recently been available
only on high-end workstations - 3-D graphics is now available on standard PCs
4Applications of 3-D Graphics
- CAD
- Scientific visualization
- virtual reality
- simulation
- games
5Pixel Graphics Vs. Vector Graphics
- Pixel graphics
- paint programs
- eg., Windows Paintbrush
- Vector graphics
- lines and polygons
- eg., Microsoft Draw
62-D Versus 3-D Graphics
Two-dimensional
Three-dimensional
73-D Wireframe Graphics
- Three dimensional objects are drawn as meshes of
connected points - Interaction and animation requires geometric
calculations only - The resulting image is often ambiguous
or
?
wireframe image
83-D Shaded Solids
- Three dimensional objects are drawn as smoothly
shaded solid objects - More calculations are needed than for wireframe
- Slower than wireframe, but more realistic
shaded
wireframe
9Typical Graphics Functions
- Draw
- Pick and Select
- Transform
- Shade and Render
10Draw
- Draw lines or polygons connecting specified points
11Pick and Select
- Identify the graphic object under the cursor
- Identify the graphic objects inside a region
12Transform
Transformed
133-D Transform
14Shade and Render
- Colour and shade surfaces, and display the image
on the screen
15Graphics generation
Geometry and colour calculation
Frame buffer and display
User application
Rasteriz- ation
Graphics pipeline
16User Application
Z
Y
X
17Geometry Calculation
Z
(xw, yw, zw)
Y
X
World coordinates
18Colour Calculation
Colour is calculated based on surface
properties, light direction and colour, using
lighting models.
19Rasterization
Transform polygon to pixels
20Hidden Surface Removal
- When several overlapping polygons are drawn on
the screen, which one is on top?
Which is right?
21Z-buffering
This pixel is drawn on screen
- A fast hardware solution is the Z-buffer
- The depth of each pixel relative to the screen
is calculated and saved in a buffer - The pixel with the smallest depth is the one that
is displayed - The other pixels are on surfaces that are hidden
Screen
Polygons
Z
22Lighting Models and Shading
- For visual realism, lighting models have been
developed to illuminate the surfaces of solid
models - These models incorporate
- ambient lighting and illumination
- diffuse reflection of directional lighting
- specular reflection of directional lighting
23Lighting Types
24Ambient Illumination
- Ambient light comes from many directions, as a
result of multiple reflections and emission from
many sources - The resulting surface illumination is uniform
- Depends only on object material
25Diffuse Reflection
- Dull, matte surfaces reflect directional light
equally in all directions
26Specular Reflection
- Shiny surfaces reflect light in one direction
- The reflection is the colour of the incident
light, not the colour of the object - Specular reflection is the source of highlights
27Dull and Shiny Surfaces
28Lighting Models
- Real objects are illuminated by a combination of
these three illumination types. - CAD systems like IDEAS allow the user to define
- colour and location of lights
- types and intensities of lights (point, diffuse,
etc.) - object material properties, including colour,
specularity, reflection coefficients
29Example
Powerpoint can vary the lighting and material
30Lighting Models
- There are several popular shading algorithms
- Flat shading
- each polygon has a uniform colour
- the surface appears faceted
- Phong or Gouraud shading
- the colour is varied smoothly across the polygons
- the result is a surface that appears to be smooth
Flat
Gouraud
31Flat Shading
- The simplest form of shading is flat shading
- Each polygon is uniformly coloured, depending on
its orientation relative to the light source
32Flat Shading
33Flat Shading
n
?
d
34Gouraud and Phong Shading
- Flat shading is simple, but gives a faceted
appearance - Gouraud and Phong developed techniques to
smoothly interpolate the illumination across
polygons - The resulting shading is smooth and continuous
35Gouraud Shading
- The surface normal at the vertices is calculated
by averaging the adjoining face normals - The vertex intensity is then calculated
- The intensity is interpolated across the polygon
based on the vertices
vertex normal
face normals
36Phong Shading
- Rather than interpolating the lighting, Phong
shading interpolates the surface normal across
the polygons - The intensity is then calculated based on the
interpolated normal - This gives more realistic specular lighting
37Ray Tracing and Radiosity
- Ray tracing and radiosity are two techniques for
achieving the ultimate in visual realism - These techniques work well with curved surfaces
38Ray Tracing
- Ray tracing traces a ray of light from the eye to
a light source - Along the way, the light ray may be occluded (in
shadow), reflected or refracted - Ray tracing realistically renders scenes with
shiny and transparent objects
39Radiosity
- In many scenes, illumination is primarily diffuse
- Diffuse illumination results from the absorption
and reflection of diffuse light from many objects
in the scene - Radiosity uses thermal models of emission and
reflection of radiation to accurately calculate
diffuse lighting - Radiosity is very good at rendering architectural
interiors
40Texture Mapping
- For realism, photographic textures are mapped
onto the surfaces of objects - Example textures
- woodgrain
- concrete
- grass
- marble
- Texture mapping is very computationally intensive
41Other Graphics Effects
- Effects that are fairly easy to achieve include
- Fog
- Transparency
42Example - Wireframe
43Example - Flat Shaded
44Example - Smooth Shaded
45Example - Texture Mapped
46Example - Shadows
47Example - Ray Traced
Green glass
48Examples
texture mapping
reflections
shadows
49Graphics Standards
- Graphics functions are incorporated into a C,
FORTRAN, or Pascal program by using a library of
functions or subroutines - This library of functions is known as an
Application Program Interface (API) - There is no single standard, but several APIs are
in wide use.
50 A Selection of Graphics APIs
- GKS
- 2-D graphics only
- Windows GDI (Graphics Device Interface)
- 2-D only
- PHIGS (Programmers Hierarchical Interactive
Graphics Standard) - Xlib
- X-windows graphics commands
- PEX
- PHIGS Extension to X
51Emerging Standards in APIs
- OpenGL (developed by Silicon Graphics)
- open standard
- available on all platforms
- intended for professional-level graphics like CAD
- Direct3D
- developed by Microsoft
- Windows only
- intended for games
52Double Buffering
- For smooth animations, some graphics cards
support double buffering - A new image is drawn in one buffer while the
other buffer is displayed on the screen - When the update is finished, the buffers swap
so that change on the screen is instantaneous - This prevents flicker as the image is redrawn.
53Frame Buffers
- A generic VGA frame buffer typically stores 8
bits per pixel (256 colours) - Graphics cards with more memory use 24 bit frame
buffers - 16 million colours
- For most PCs, this is as good as it gets
54Frame Buffers
- High end graphics hardware supports frame buffers
with over 100 bits per pixel! - two 24 bit images
- 24 bit Z-buffer (depth)
- overlay bits
- alpha bits for transparency
- and other special purpose bits
- These bits are sometimes called bit planes
- This requires much more graphics memory than in
common in PCs
55Stereo vision using 3-D glasses
- One frame buffer contains the left eye view, the
other contains the right eye view - The views are rapidly alternated on the screen
- Glasses with liquid crystal shutters synchronize
the left and right views - The results are amazing!
56Graphics Generation
Geometry and colour calculation
Frame buffer and display
User application
Rasteriz- ation
Graphics pipeline
57Graphics Designs
- Software pipeline
- all processing done in software
- slow, inexpensive
- example PC with 2D graphics card
- Software geometry, hardware rasterization
- good compromize
- example Matrox Millenium graphics card
- Hardware pipeline
- all processing done in hardware
- very fast, expensive
- high-end Silicon Graphics workstations
58Graphics Performance Comparison
Source OPC CDRS results
59Price Comparison
Source OPC CDRS results
60Price/Performance Comparison
Source OPC CDRS results
61Summary
- 3D graphics important for engineering
applications - 3D graphics is now available on standard PCs
62(No Transcript)