Computer Graphics (CSE 4103)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Department of Computer Science and Engineering,

Computer Graphics (CSE 4103)

University of Dhaka
Computer Graphics (CSE 4103)
3.0 Credits, 45 Hours lectures

Session: 2014-15, CSEDU 18b


Course Instructor:
Ahsan Raja Chowdhury
Assistant Professor
Dept of Computer Science
and Engineering
University of Dhaka
E-mails:
[email protected]
farhan717@{yahoo, gmail}.com

Class Time:
Sunday
10:00 AM- 11:30 AM

Tuesday
10:00 AM- 11:30 AM
Sessional/ Lab classes:
Sunday: 2:00 PM- 5:00 PM
(Gr-1)
Tuesday: 2:00 PM- 5:00 PM
(Gr-2)

Sessional/ Lab coordinators:


Gr-1: Mrs. Suvra Chakraborty and
Ahsan Raja Chowdhury

Gr-2: Mr. Hasnain Heickal and


Ahsan Raja Chowdhury
Books: 1) Computer Graphics, Principles & Practice, Second Edition in C
James D. Foley, Andries van Dam, Steven K. Feiner, John F. Huges
2) Schaim’s Outline Computer Graphics
Roy A. Plastock, Gordon Kalley
Syllabus and Class Outline
Topic Chapter Approx #
No. of classes
1) Introduction: Standard Graphics Primitives, Graphical User 1 1
Interface
2) Basic Raster Graphics Algorithms for Drawing 2D 3 7-8
Primitives: Scan conversion algorithms: Mid-point Line, +
Circle and ellipse Creation Algorithms. Slope independent line Sc
drawing using mid-point line algorithm. Polygons: Difference Series
type of polygons, polygon filling, triangulation, polygon filling
algorithm. Windowing and Clipping: Window Viewpoint,
Zooming, panning, line, text and polygon, clipping algorithms.
3) Introduction to OpenGL - 1
4) Graphics Hardware: Graphics Hardware Display devices, 4 1
Raster refresh graphics display, Use of frame buffer and look
up table Coordinate convention Device coordinate and wild
coordinate system. Vector graphics and raster graphics system.
5) Transformation: Homogeneous coordination, Transformation 5 3
in 3D, Transformation matrices, translation, rotation, scaling.
Syllabus and Class Outline..
Topic Chapter Approx #
No. of classes
7) Projection: Parallel and perspective, standard projection 6 5
matrices.
8) Visible Surface Determination: Painter's algorithm, Z- 15 3
Buffering, Visible surface ray-tracing algorithm.
9) Illumination and Shading: Light Models, Ambient light, 16 2
diffuse and specular reflection, light attenuations, Goraud and
Phong shading, Recursive Ray Tracing.
10) Monochrome and colored light: monochrome light, additive 13 3
and suntractive light, Colored light- RGB, CMY, YIQ, HSV
and HLS color model.
11) Representing curves and surfaces: Polygonal surfaces, 11 4
Parametric Cubic Curves- Hermite, Bezier and B-spline cuves,
parametric bi-cubic surfaces: bicubic splines.
12) Image File Format: PPM file, BMP file. 17 1
13) Introduction to Graphics Programming. The nature of - 1
computer animation.
What is Computer Graphics? (1/2)
• Computer graphics generally means creation,
storage and manipulation of models and images
• Such models come from diverse and expanding set
of fields including physical, biological,
mathematical, artistic, and conceptual/abstract
structures
What is Computer Graphics? (2/2)
• William Fetter coined term “computer graphics” in
1960 to describe new design methods he was
pursuing at Boeing for cockpit ergonomics
• Created a series of widely reproduced images on
“pen plotter” exploring cockpit design, using 3D
model of human body.

“Perhaps the best way to define computer graphics is to find out what it is not. It is not a machine. It is not
a computer, nor a group of computer programs. It is not the know-how of a graphic designer, a
programmer, a writer, a motion picture specialist, or a reproduction specialist.
Computer graphics is all these – a consciously managed and documented technology directed toward
communicating information accurately and descriptively.”
Computer Graphics, by William A. Fetter, 1966
Scope of Computer Graphics
Broad sense: Any computer-driven display of visual information
For example:
Text
Line drawings
Graphs, Charts, Schematics
Realistic Pictures
Any designs

Various tools to work with:


Color, Shading, Texture
Variation in time (movies)
Human 3D perceptual abilities
Interactivity
Application of Computer Graphics (1/2)

User Interfaces: windowing systems, desktops, point and


click interaction etc.
Interactive plotting: 2D and 3D graphical representations of
numerical data in science engineering and business
Office automation: Word processing, desktop publishing,
spreadsheets etc.

Soft copy publication and publicity: e.g., the Web
Computer aided design: VLSI planes trains and automobiles
buildings bridges communication networks optical systems
nuclear reactors etc
Displaying and interpreting results of scientific simulation:
physics, chemistry, geology, biology, climatology, cardiology,
and any other “ology” you can think of.
Application of Computer Graphics (2/2)

Visualizing 3D databases: Medical tomography, engineering


tomography, geological structure, etc.
 Entertainment: Computer and arcade games, cartoons,
special effects, whole movies, virtual environment and
interactive games.
Interactive training: Flight simulators, surgical simulators,
immersive war games and practice scenarios
Process control: Factories, power plants, networks, military
command and control.
Telepresence and augmented perception: Surgery, dangerous
environments
 Art and commerce: snazzy TV ads, virtual real-estate
walkthroughs fun visuals
Cartography: Maps for civilian and military use navigation
boxes
Brief History
Development mostly driven by the cost of various hardware:
1950s: Crude plotting on teletypes, line printers, CRT to camera copy,
simple CRT and light pen displays.
1960s: First interactive systems (Southerland’s Sketchpad), early
CAD/CAM, batch processing, vector displays, mouse (1968), high cost
(many $100K).
1970s: Raster displays (TV technology), cheaper memory, early
graphics standards (e.g., Core), cost starts to come down.
1980s: Cheap microprocessors, personal computers invented and
explode (XEROX Star, Apple Mac, IBM PC) windowing systems,
commodity 2D hardware/software, Improved and extended standards
(GKS, PHIGS), extensive development of 3D technology at high end.
1990s: Processor performance continues to explode; prices for
memory, disks, display devices drop dramatically commodity 3D
hardware and software, realistic 3D animation becomes commercially
viable, interactive 3D virtual environments developed.
GKS: Graphical Kernal System, PHIGS: Programmers Hierarchical Integrated Graphics System
Display/ Output Technology
Hardcopy Vs Electronics Devices and Vector Vs RasterDisplay

Hardcopy devices:
vector technologies: Pen plotters
raster technologies: CRT camera, dot matrix, ink jet, etc

Electronic displays:
vector technologies: swept, direct view storage
raster technologies: CRT, LCD, plasma, etc.
Graphics Display Hardware
Vector (calligraphic, stroke, random- Raster (TV, bitmap, pixmap) used in
scan) displays and laser printers
• Driven by display commands • Driven by array of pixels (no semantics,
– (move (x, y), char(“A”) , line(x, y)…)
lowest form of representation)
• Note “jaggies” (aliasing errors) due to
• Survives as “scalable vector discrete sampling of continuous
graphics” primitives

Ideal Vector
Drawing Drawing Outline Filled
Vector Display
60s through mid 80s Practically obsolete now.

Consists of a buffer memory containing endpoints of vectors


(and characters) to be drawn, and a display processor that
interprets the buffer and sends end points to a vector generator
that drives the electron beam across the screen

Random scan device, needed refresh rate of >Hz to avoid flicker.

Direct-view storage tube (Tektronix 4010) eliminated refresh


cycle and made interactive graphics affordable.
Raster Display(1/2)
Became affordable in mid 70s, based on television technology.

Represents image as an array called a raster of colored dots


called pixels that are refreshed row by row. Each row is called a
raster line.

Consists of a buffer memory containing codes describing the dot


colors hardware that drives one or three electron beams in a
regular scan pattern and a display processor that scans the buffer
in sync with the beam and sets the beam intensities to produce
the desired color.

Cheaper RAM was breakthrough needed to make technology


affordable.
Raster Display(2/2)
Advantages
Lower cost
Less complex driver electronics
Ability to display area filled with color or patterns
Refresh independent of number of objects

Disadvantages
Need for scan conversion, e.g., lines to pixels.
Slower real-time dynamics
Problems with aliasing (the jaggies)
Enabling Modern Computer Graphics (1/5)

• Hardware revolution
– Moore’s Law: every 12-18 months, computer power improves by
factor of 2 in price / performance as feature size shrinks
– Significant advances in commodity graphics chips every 6 months
vs. several years for general purpose CPUs
• NVIDIA GTX Titan Z… 8122 gigaflops
– Newest CPUs are 64-bit, 2, 4, 6, 8, or 10 core
• Intel Core i7 – consumer, up to 6 cores hyperthreaded to provide 12
threads
• Intel Haswell – industrial, 8 cores HT, 16 threads
Enabling Modern Computer Graphics (2/5)

• Graphic subsystems
– Offloads graphics processing from CPU to chip designed for doing
graphics operations quickly
– nVidia GeForce™, AMD Radeon™
– GPUs originally designed to handle special-purpose graphics
computations
– Increasingly, GPUs used to parallelize other types of computation
(known as GPGPU, or General-Purpose Computing on the Graphics
Processing Unit)
• Hardware show and tell: Dept’s NVIDIA GeForce GTX 460s
– 1.35 GHz clock, 1GB memory, 37.8 billion pixels/second fill rate
– Old cards: GeForce 7300 GT: 350 MHz clock, 256 MB memory, 2.8
billion
fill rate

9/4/2014 20
Enabling Modern Computer Graphics (3/4)

• Input Devices
– Mouse, tablet & stylus, multi-touch, force feedback, and
other game controllers (e.g., Wii), scanner, digital camera
(images, computer vision), etc.
– Body as interaction device

Xbox Kinect Leap Motion Nimble UX


Enabling Modern Computer Graphics (4/5)

• Many form factors


– Smartphones/laptops/desktops/tablets
– Microsoft PPI display Samsung
Galaxy S5

– Smart watches Samsung


Galaxy Tab

– Head-mounted displays (HMDs)


– 3D immersive virtual reality spaces
Apple iPhone

Microsoft PPI display

Android Wear Google Glass


Microsoft’s first
Surface
Enabling Modern Computer Graphics (5/5)

• Software Improvements
– Algorithms and data structures
• Modeling of materials
• Rendering of natural phenomena
• “Acceleration data structures” for ray tracing and other
renderers
– 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!
What is Interactive Computer
Graphics? (1/2)
• User controls content, structure, and appearance of
objects and their displayed images via rapid visual
feedback
• Basic components of an interactive graphics system
– input (e.g., mouse, tablet and stylus, multi-touch…)
– processing (and storage)
– display/output (e.g., screen, paper-based printer,
video recorder…)
• First truly interactive graphics system, Sketchpad,
pioneered at MIT by Ivan Sutherland for his 1963 Ph.D.
thesis
• Used TX-2 transistorized “mainframe” at Lincoln Lab
What is Interactive Computer
Graphics? (1/2)

Note CRT monitor, light pen


and function-key panel
What is Interactive Computer
Graphics? (2/2)
• Almost all key elements of interactive graphics system are expressed in first
paragraph of Sutherland’s 1963 Ph.D. thesis, Sketchpad, A Man-Machine
Graphical Communication System:

The Sketchpad system uses drawing as a novel


communication medium for a computer. The system
contains input, output, and computation programs which
enable it to interpret information drawn directly on a
computer display. Sketchpad has shown the most usefulness
as an aid to the understanding of processes, such as the
motion of linkages, which can be described with pictures.
Sketchpad also makes it easy to draw highly repetitive or
highly accurate drawings and to change drawings previously
drawn with it…
Conceptual Framework for Interactive
Graphics
• Graphics library/package 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 may contain lots
of non-graphical data (e.g., non-geometric object properties)
• User interaction results in modification of image and/or model
• This hardware and software framework is 5 decades old but is still useful

Software Hardware

Graphics
System/
GPU
Application Application Graphics
Model / database program Library

9/4/2014 27
Graphics Library
• Examples: OpenGL™, DirectX™, Windows Presentation
Foundation™ (WPF), RenderMan™, HTML5 + WebGL™
• 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
Sample-based Graphics (1/2)
• Sample-based graphics: Discrete
samples are used to describe visual
information
– pixels can be created by digitizing images,
using a sample-based “painting” program,
etc.
– often some aspect of the physical world is
sampled for visualization, e.g.,
temperature across the US
– example programs: Adobe Photoshop™,
GIMP™ , Adobe AfterEffects™
Sample-based Graphics (2/2)
• Once an image is defined as pixel-array, it can be manipulated
– 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 (or pre-
selected portion of image) without user intervention. Blurring, sharpening,
edge-detection, color balancing, rotating, warping. These are front-end
processes to Computer Vision.
What’s the Advantage?
• Once image is defined in terms of colors at
(x, y) locations on grid, can change image
easily by altering location or color values
• E.g., if we reverse our mapping above and
make 10 = white and 0 = black, the image
would look like this:
• Pixel information from one image can be
copied and pasted into another, replacing
or combining with previously stored pixels
What’s the Disadvantage?
• WYSIAYG (What You See Is All You Get): 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.
– But increasingly great success in image-based rendering to fake 3D
scenes and arbitrary camera positions. New images constructed by
interpolation, composition, warping and other operations.
Geometry-Based Graphics (1/2)
• Geometry-based graphics (also called
scalable vector graphics or object-oriented
graphics): geometrical model is created,
along with various appearance attributes,
and is then sampled for visualization
(rendering, a.k.a image synthesis)
– often some aspect of physical world is visually
simulated, or “synthesized”
– examples of 2D apps: Adobe Illustrator™, Adobe
Freehand™, Corel CorelDRAW™
– examples of 3D apps: Autodesk’s AutoCAD™,
Autodesk’s (formerly Alias|Wavefront’s) Maya™,
Autodesk’s 3D Studio Max™
Geometry-Based Graphics (2/2)
• Geometry-based graphics applications
– Store mathematical descriptions, or “models,” of geometric
elements (lines, polygons, polyhedrons, polygonal meshes…) and
associated attributes (e.g., color, material properties).
– Geometric elements are primitive shapes, primitives for short.
– Images are created via sampling of geometry for viewing, but not
stored as part of 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 geometry- and sample-based
graphics, both as performance hack and to increase quality of final
product
– geometric characters on painted or scanned scene images
What is Geometric Modeling?
• What is a model?
• Captures salient features (data, behavior) of thing/phenomenon
being modeled
– data includes geometry, appearance, attributes…
– note similarity to OOP ideas
• Modeling allows us to cope with complexity
• Our focus: modeling and viewing simple everyday objects
• Consider this:
– Through 3D computer graphics, first time in human history we have
abstract, easily changeable 3D forms.
• Has revolutionized working process of many fields – science, engineering,
industrial design, architecture, commerce, entertainment, etc. Profound
implications for visual thinking and visual literacy
• “Visual truth” is gone in the Photoshop and FX-saturated world (but
consider painting and photography…) – seeing no longer is believing…(or
shouldn’t be!)
Modeling vs. Rendering
Modeling
– Create models Both can be done with commercial
– Apply materials to models software:
– Place models around scene Autodesk MayaTM ,3D Studio MaxTM,
– Place lights in scene BlenderTM, etc.
– Place the camera
Rendering
Take “picture” with camera

Point Light
Spot
Light

Directional Light
Ambient
Light
Thank you

You might also like