CPCS 391
Computer Graphics 1
Instructor: Dr. Sahar Shabanah
Graphics Applications
Course description
• First course in computer graphics covering fundamental concepts and techniques related to 2-D and 3-D graphics.
– Rasterization – Geometry – Shading
– Hidden surface elimination
– Texture mapping – Modeling
– Animation – Ray tracing
– Global illumination – Animation
from M. Woo et al., 1997
Course Outline
– Rasterization – Geometry – Shading
– Hidden surface elimination
– Texture mapping – Modeling
– Ray tracing
– Global illumination
from M. Woo et al., 1997
How to set individual image pixels corresponding to projected geometric objects such as points, lines, polygons, and more complicated shapes. Anti-
aliasing reduces artifacts (“jaggies”) caused by finite image resolution
How to specify the 3-D positions of the camera and the scene objects and their various parts, how to project these to 2-D image locations, and how to represent trans-formations of these positions
How to model light interaction with 3-D surfaces with varying material properties in order to calculate the proper colors perceived by the eye at different image locations
How to efficiently rasterize only the visible parts of scene objects
How to apply “layers” of detail to scene objects to show features, simulate bumps and
reflections, or other precomputed shading effects.
Advanced
Topics
Learning objectives of this course
• Basic understanding of graphics
hardware/software technology and algorithms
• Learn how to use OpenGL to write
2D/3D drawing programs
Lectures
• ST, 11:00 pm-12:30 pm
• Lecture slides will be posted on the course page before each lecture.
• Read thru the lecture notes and the assigned readings before class.
• Be prepared to ask questions.
• Class website:
http://groups.yahoo.com/group/CPCS391_F10/
Textbooks
Any one of these:
1. Fundamentals of Computer Graphics, Peter Shirley, 3rd Revised edition edition (July 21, 2009), ISBN-10: 1568814690, ISBN-13: 978- 1568814698
2. Computer Graphics, C Version (2nd Edition), Donald Hearn, M. Pauline Baker, ISBN-10:
0135309247, ISBN-13: 978-0135309247 (course website)
3. Computer Graphics in C#: Principles and Practice, 3Rev Ed edition, 2008, Authors:
James D. Foley, Andries van Dam, Steven K.
Feiner, John F. Hughes, ISBN-10: 0321399528, ISBN-13: 978-0321399526 (old copy in CS dept.)
Grading
• 20% Lab & Assignments
• 15% Exam 1: Tuesday 27/4-20/3
• 15% Exam2: sunday 8/6-29/4
• 30% Final Project
• 20% Final exam
Computer Graphics
Computer-generated images and models or sequences of such
models and images (i.e., animations, movies)
The scientific study of techniques and methods for generating such images: creation, storage and
manipulation.
Computer Graphics Systems
Interactive
User controls contents, structure, and appearance of objects and their displayed
images via rapid visual feedback
Basic components
• Input: mouse, tablet and stylus, multi_touch
• processing (and storage)
• display/output :screen, printer, video recorder
First interactive graphics system, Sketchpad,
Non-interactive
batch mode
used for:
• final production-quality video
• film (special effects – FX)
3-D Computer Graphics Applications
Manufacturing design (CAD)
• Animations
• Special effects mixed with live footage Movies, TV, commercials
Visual arts
Video games
Scientific visualization
Simulation of natural phenomena
Enabling Modern Computer Graphics
Hardware revolution
Every 12-18 months, computer power improves by factor of 2
in price / performance as size shrinks
Newest processors are 64- bit, 2, 4, 6, 8, or 12 core
• Intel Core i7 – consumer, 4 cores hyper-threaded to provide 8 threads
Graphic subsystems
GPU:
- chip designed for doing graphics operations fast
- Offloads graphics processing from CPU
•nVidia GeForce™, ATI Radeon™
•Advanced Per-pixel lighting
•Millions of triangles per second
•special purpose computation,
• ganged together to make supercomputers
Significant advances in GPUs every 6 months vs. several years for CPUs
nVidia GeForceTM chip
Enabling Modern Computer Graphics
• Mouse,
• tablet & stylus,
• multi-touch,
• force feedback,
• game controllers (e.g., Wii),
• scanner,
• digital camera
• Whole body as interaction device:
• http://www.xbox.co m/kinect
Input
Devices
Cell Phones/PDAs (smartphones), Laptop/Desktops,
Jeff Han ’ s Perceptive Pixel, Microsoft Surface
3D immersive virtual reality systems such as Brown ’ s Cave™
Micro soft Surfa ce
Enabling Modern Computer Graphics
Algorithms and data structures
• Modeling of materials
• Rendering of natural
phenomena
• Acceleration data structures for ray tracing
Parallelization
• Most
operations are embarrassingly parallel:
changing value of one pixel is often
independent of other pixels
Distributed and Cloud computing
• Send
operations into
‘ cloud ’ , get back results, don ’ t care how
• Rendering even available as internet service!
Enabling Modern Computer Graphics
Software Improvements
Graphics Display Hardware
Raster
• (TV, bitmap, pixmap) used in displays and laser printers
• Draw driven by array of pixels (frame buffer): no semantics, lowest form of representation
• “ Jaggies ” (aliasing errors) due to sampling continuous primitives
Vector
• Calligraphic, stroke, random-scan
• Draw driven by display commands (Draw List):
– move (x, y), – char( “ A ” ) , – line(x, y)
Ideal
Drawing Vector
Drawing Raste r
Conceptual Framework for Interactive Graphics
• Graphics library is intermediary between application and display hardware (Graphics System)
• Application program maps application objects to views (images) of those objects by calling on graphics library. Application model contains non-graphical data (e.g., non- geometric object properties)
• User interaction results in modification of model and/or image
• Unlike with FX, images are often means to an end: synthesis, design, manufacturing, visualization,…
Application
program Graphics
Library Graphics System/GP
U Application
Model/data base
Software Hardware
Graphics Libraries
• Examples: OpenGL™, DirectX™, Windows
Presentation Foundation™ (WPF), RenderMan™
• Primitives (characters, lines, polygons, meshes,…)
• Attributes: color- line style- material properties for 3D
• Lights
• Transformations
• Immediate mode vs. retained mode
– immediate mode: no stored representation, package holds only attribute state, and application must
completely draw each frame
– retained mode: library compiles and displays from scenegraph that it maintains, a complex DAG. It is a display-centered extract of the Application Model
• discrete samples to describe visual information
• pixels can be created by digitizing images, using a sample-based “painting” program, etc.
• example programs: Adobe Photoshop™, GIMP™
Sample-based graphics:
• geometrical model, appearance attributes, sampled for visualization (rendering)
• aspects of physical world is visually simulated
• Examples:
• 2D apps: Adobe Illustrator™, Adobe Freehand™, Corel CorelDRAW™
• 3D apps: Autodesk’s AutoCAD2010™, Maya™, 3D Studio Max™
Geometry-based graphics:
Graphics Application Distinctions
18
Images are made up of grid of discrete pixels, for 2D “picture elements”
Pixels are point locations with associated sample values, usually of light intensities/colors, transparency, and other control information
An image is sampled using points locations along the continuous signal and we cannot treat the pixels as little circles or squares
Sample-based Graphics
19
Mathematical
pixel grid LCD display
CRT beam illumination pattern
NB: Can’t resolve adjacent pixels on CRT
1 pixel light intensity
• directly in paint-type program,
• as a sampling of continuous (analog) visual materials. E.g., photograph can be sampled (light intensity/color measured at regular intervals) with scanners, cameras
• Sample values can also be input numerically (e.g., with numbers from computed dataset)
Samples creation
• Image editing: changes made by user, such as cutting and pasting sections, brush-type tools, and processing selected areas
• Image processing: algorithmic operations that are performed on image without user intervention. Includes blurring, sharpening, edge-detection, color balancing, rotating, and warping. Pre-
processing step in computer vision image manipulation
Sample-based Graphics
20
Sampling an Image
• A color value is measured at every grid point and used to color corresponding grid square
• Note: this poor sampling and image reconstruction method creates blocky image
21
3D scene
0 = white, 5 = gray, 10 = black
What ’ s the Advantage?
• image defined in terms of colors at (x, y) on grid,
• change image by altering location or color values
• E.g. reverse mapping above and make 10 = white and 0 = black,
Image alteration
• Pixel information from one image can be copied and pasted into another, replacing or combining with previously stored pixels
Image combining
22
What ’ s the Disadvantage?
• No additional information, no depth information
• can’t examine scene from different point of view
• at most can play with the individual pixels or groups of pixels to change colors, enhance contrast, find edges, etc.
WYSIAYG (What You See Is All You Get):
23
Photo Tourism: Exploring photo collections in 3D (Siggraph 2006)
Image-based
rendering to fake 3D scenes and arbitrary camera positions.
Images constructed by interpolation, composition,
warping and other operations.
Geometry-Based Graphics
• store mathematical descriptions, or “ models, ” of
geometric elements (lines, polygons, polyhedrons…) and associated attributes (e.g., color, material properties).
• Elements are primitive geometric shapes, primitives for short
• Images created as pixel arrays (via sampling of geometry) for viewing, but not stored as part of model. Images of many different views are generated from same model
• Users cannot usually work directly with individual pixels in geometry-based programs; as user manipulates geometric elements, program resamples and redisplays elements
• Increasingly rendering combines geometric and sample- based graphics, both as performance hack and to increase quality of final product
Geometry-based graphics applications
24
What is Geometric Modeling?
•Captures salient features (data, behavior) of thing/phenomenon being modeled
•data includes geometry, appearance attributes…
•Modeling is coping with complexity What is a model?
• Real: some geometry inherent
• physical (e.g., actual object such as a pump)
• non-physical (e.g., mathematical function, weather data)
• Abstract: no inherent geometry, but for visualization
• organizational (e.g., company org. chart)
• quantitative (e.g., graph of stock market) Geometry Types
25
Decomposition of a Geometric Model
• Divide and Conquer
• Hierarchy of geometrical components
• Reduction to primitives (e.g., spheres, cubes, etc.)
• Simple vs. not-so-simple elements (nail vs. screw)
26
Head Shaft Point
composition decomposition
Hierarchical (Tree) Diagram of Nail
• Object to be modeled is (visually) analyzed, and then decomposed into collections of primitive shapes.
• Tree diagram provides visual method of expressing “composed of” relationships of model
• Such diagrams are part of 3D program interfaces (e.g., 3D Studio MAX, Maya)
• As pointer data structure to be rendered, it is called a scenegraph
27
Nail Head
(cylinder)
Body
root node
leaf nodes Shaft
(cylinder)
Point (cone) tree diagram
Composition of a Geometric Model
• Primitives created in decomposition process must be assembled to create final object. Done with affine transformations, T, R, S (as in above example).
28
Primitives
in their own modeling coordinate system
Composition in world (root) coordinate system Translate
Translate and Scale
Translate and Rotate
Modeling vs. Rendering
• Create models
• Apply materials to models
• Place models around scene
• Place lights in scene
• Place the camera
Modeling Rendering
Directional Light Ambient
Light
Point Light
Spot Light
lighting assignment by Patrick Doran, Spring 2009
Take “picture” with camera
Both can be done by modern commercial software:
Autodesk MayaTM ,3D Studio MaxTM, BlenderTM, etc.
29