Introduction to Computer Graphics CS 445 / 645 David Brogan [email protected]...

35
Introduction to Computer Graphics CS 445 / 645 David Brogan David Brogan [email protected] [email protected]

Transcript of Introduction to Computer Graphics CS 445 / 645 David Brogan [email protected]...

Introduction to Computer GraphicsCS 445 / 645

David BroganDavid Brogan

[email protected]@cs.virginia.edu

David BroganDavid Brogan

[email protected]@cs.virginia.edu

Administrivia

SyllabusSyllabus• Instructor/TA coordinatesInstructor/TA coordinates

• PrereqsPrereqs

• TextsTexts

• Assignments Assignments

• Grading & Honor CodeGrading & Honor Code

• Topic listTopic list

SyllabusSyllabus• Instructor/TA coordinatesInstructor/TA coordinates

• PrereqsPrereqs

• TextsTexts

• Assignments Assignments

• Grading & Honor CodeGrading & Honor Code

• Topic listTopic list

Impact of Computers

Moore’s LawMoore’s Law

Power of a CPU doubles every 18 months / 2 Power of a CPU doubles every 18 months / 2 yearsyears

Moore’s LawMoore’s Law

Power of a CPU doubles every 18 months / 2 Power of a CPU doubles every 18 months / 2 yearsyears

Impact of Video Games (Nvidia)

Number of transistors on GPU doubles each 6 mos.Number of transistors on GPU doubles each 6 mos.

• Three times Moore’s LawThree times Moore’s Law

– Good article on Jen-Hsun Huang, Nvidia CEO: Good article on Jen-Hsun Huang, Nvidia CEO: http://www.wired.com/wired/archive/10.07/Nvidia_pr.htmlhttp://www.wired.com/wired/archive/10.07/Nvidia_pr.html

Number of transistors on GPU doubles each 6 mos.Number of transistors on GPU doubles each 6 mos.

• Three times Moore’s LawThree times Moore’s Law

– Good article on Jen-Hsun Huang, Nvidia CEO: Good article on Jen-Hsun Huang, Nvidia CEO: http://www.wired.com/wired/archive/10.07/Nvidia_pr.htmlhttp://www.wired.com/wired/archive/10.07/Nvidia_pr.html

$7 Billion Man $5.6 Billion Man

Worldwiderevenues

Retro flashback???Lee Majors

Col. Steve Austin

Impact of Video Games

But…But…

• Video game sales is roughly same as Hollywood boxofficeVideo game sales is roughly same as Hollywood boxoffice

• Americans bought $3.2 in VCRs and DVDs last yrAmericans bought $3.2 in VCRs and DVDs last yr

• Total revenues to movie studios is 5 times total video game Total revenues to movie studios is 5 times total video game revenuesrevenues

But…But…

• Video game sales is roughly same as Hollywood boxofficeVideo game sales is roughly same as Hollywood boxoffice

• Americans bought $3.2 in VCRs and DVDs last yrAmericans bought $3.2 in VCRs and DVDs last yr

• Total revenues to movie studios is 5 times total video game Total revenues to movie studios is 5 times total video game revenuesrevenues

Future of Consoles

• 33 million PS2s33 million PS2s

• 3.9 million Xboxes3.9 million Xboxes

– MSFT still losing $89 per consoleMSFT still losing $89 per console

• Predicted 200 million PDA/Cell game players in 2005Predicted 200 million PDA/Cell game players in 2005

– Do you believe it?Do you believe it?

• 33 million PS2s33 million PS2s

• 3.9 million Xboxes3.9 million Xboxes

– MSFT still losing $89 per consoleMSFT still losing $89 per console

• Predicted 200 million PDA/Cell game players in 2005Predicted 200 million PDA/Cell game players in 2005

– Do you believe it?Do you believe it?

Graphics Applications

Entertainment: CinemaEntertainment: CinemaEntertainment: CinemaEntertainment: Cinema

Pixar: Monster’s Inc.

Square: Final Fantasy

Graphics Applications

Medical VisualizationMedical VisualizationMedical VisualizationMedical Visualization

MIT: Image-Guided Surgery Project

Th

e V

isib

le H

um

an

Pro

jec

t

Graphics Applications

Everyday UseEveryday Use

• Microsoft’s Whistler OS will use graphics seriouslyMicrosoft’s Whistler OS will use graphics seriously

• Graphics visualizations and debuggersGraphics visualizations and debuggers

• Visualize complex software systemsVisualize complex software systems

Everyday UseEveryday Use

• Microsoft’s Whistler OS will use graphics seriouslyMicrosoft’s Whistler OS will use graphics seriously

• Graphics visualizations and debuggersGraphics visualizations and debuggers

• Visualize complex software systemsVisualize complex software systems

Graphics Applications

Scientific VisualizationScientific VisualizationScientific VisualizationScientific Visualization

Graphics Applications

Computer Aided Design (CAD)Computer Aided Design (CAD)Computer Aided Design (CAD)Computer Aided Design (CAD)

Graphics Applications

Entertainment: GamesEntertainment: GamesEntertainment: GamesEntertainment: Games

GT Racer 3

Polyphony Digital: Gran Turismo 3, A Spec

The Basics

Computer graphics: generating 2D images of a 3D Computer graphics: generating 2D images of a 3D world represented in a computer.world represented in a computer.

Main tasks:Main tasks:

• modelingmodeling: (shape) creating and representing the geometry of : (shape) creating and representing the geometry of objects in the 3D worldobjects in the 3D world

• renderingrendering: (light, perspective) generating 2D images of the : (light, perspective) generating 2D images of the objectsobjects

• animationanimation: (movement) describing how objects change in time: (movement) describing how objects change in time

Computer graphics: generating 2D images of a 3D Computer graphics: generating 2D images of a 3D world represented in a computer.world represented in a computer.

Main tasks:Main tasks:

• modelingmodeling: (shape) creating and representing the geometry of : (shape) creating and representing the geometry of objects in the 3D worldobjects in the 3D world

• renderingrendering: (light, perspective) generating 2D images of the : (light, perspective) generating 2D images of the objectsobjects

• animationanimation: (movement) describing how objects change in time: (movement) describing how objects change in time

Why Study Computer Graphics?

Graphics is coolGraphics is cool

• I like to see what I’m doingI like to see what I’m doing

• I like to show people what I’m doingI like to show people what I’m doing

Graphics is interestingGraphics is interesting

• Involves Involves simulationsimulation, , AI,AI, algorithmsalgorithms, , architecturearchitecture……

I’ll never get an Oscar for my actingI’ll never get an Oscar for my acting

• But maybe I’ll get one for my CG special effectsBut maybe I’ll get one for my CG special effects

Graphics is funGraphics is fun

Graphics is coolGraphics is cool

• I like to see what I’m doingI like to see what I’m doing

• I like to show people what I’m doingI like to show people what I’m doing

Graphics is interestingGraphics is interesting

• Involves Involves simulationsimulation, , AI,AI, algorithmsalgorithms, , architecturearchitecture……

I’ll never get an Oscar for my actingI’ll never get an Oscar for my acting

• But maybe I’ll get one for my CG special effectsBut maybe I’ll get one for my CG special effects

Graphics is funGraphics is fun

Can we learn from history?

Among the studies of natural causes and laws, it is Among the studies of natural causes and laws, it is light that most delights its students. Among all the light that most delights its students. Among all the great branches of mathematics, the certainty of its great branches of mathematics, the certainty of its demonstrations pre-eminently elevates the minds of demonstrations pre-eminently elevates the minds of its investigators. Perspective, therefore, should be its investigators. Perspective, therefore, should be preferred above all man’s discourses and preferred above all man’s discourses and disciplines. In this subject the visual rays are disciplines. In this subject the visual rays are elucidated by means and demonstrations which elucidated by means and demonstrations which derive their glory nor only from mathematics but derive their glory nor only from mathematics but also from physics; the one is adorned equally with also from physics; the one is adorned equally with the flowers of the other.the flowers of the other.

Among the studies of natural causes and laws, it is Among the studies of natural causes and laws, it is light that most delights its students. Among all the light that most delights its students. Among all the great branches of mathematics, the certainty of its great branches of mathematics, the certainty of its demonstrations pre-eminently elevates the minds of demonstrations pre-eminently elevates the minds of its investigators. Perspective, therefore, should be its investigators. Perspective, therefore, should be preferred above all man’s discourses and preferred above all man’s discourses and disciplines. In this subject the visual rays are disciplines. In this subject the visual rays are elucidated by means and demonstrations which elucidated by means and demonstrations which derive their glory nor only from mathematics but derive their glory nor only from mathematics but also from physics; the one is adorned equally with also from physics; the one is adorned equally with the flowers of the other.the flowers of the other.

Leonardo da Vinci (1400’s) quoting John Pecham (1200’s)

Perspective

Machines

Leonardo Again

There are some who look at the things produced by nature There are some who look at the things produced by nature through glass, or other surfaces or transparent veils. through glass, or other surfaces or transparent veils. They trace outlines on the surface of the transparent They trace outlines on the surface of the transparent medium… But such an invention is to be condemned in medium… But such an invention is to be condemned in those who do not know how to portray things without it, those who do not know how to portray things without it, no how to reason about nature with their minds… They no how to reason about nature with their minds… They are always poor and mean in every invention and in the are always poor and mean in every invention and in the composition of narratives, which is the final aim of this composition of narratives, which is the final aim of this sciencescience

There are some who look at the things produced by nature There are some who look at the things produced by nature through glass, or other surfaces or transparent veils. through glass, or other surfaces or transparent veils. They trace outlines on the surface of the transparent They trace outlines on the surface of the transparent medium… But such an invention is to be condemned in medium… But such an invention is to be condemned in those who do not know how to portray things without it, those who do not know how to portray things without it, no how to reason about nature with their minds… They no how to reason about nature with their minds… They are always poor and mean in every invention and in the are always poor and mean in every invention and in the composition of narratives, which is the final aim of this composition of narratives, which is the final aim of this sciencescience

Perspective

LorenzettiLorenzetti

• Birth of the VirginBirth of the Virgin

• 13421342

LorenzettiLorenzetti

• Birth of the VirginBirth of the Virgin

• 13421342

LeonardoLeonardo

• The Last SupperThe Last Supper

• 14981498

LeonardoLeonardo

• The Last SupperThe Last Supper

• 14981498

Shape

We Labor On…

Light Stage – 2002USC, Institute forCreative Technologies

Note: Paul Debevec will visit UVa in October to talk about this and other cool things

Display Technologies

Cathode Ray Tubes (CRTs)Cathode Ray Tubes (CRTs)

• Most common display device todayMost common display device today

• Evacuated glass bottleEvacuated glass bottle

• Extremely high voltageExtremely high voltage

• Heating element (filament)Heating element (filament)

• Electrons pulled towards Electrons pulled towards anode focusing cylinderanode focusing cylinder

• Vertical and horizontal deflection platesVertical and horizontal deflection plates

• Beam strikes phosphor coating on front of tubeBeam strikes phosphor coating on front of tube

Cathode Ray Tubes (CRTs)Cathode Ray Tubes (CRTs)

• Most common display device todayMost common display device today

• Evacuated glass bottleEvacuated glass bottle

• Extremely high voltageExtremely high voltage

• Heating element (filament)Heating element (filament)

• Electrons pulled towards Electrons pulled towards anode focusing cylinderanode focusing cylinder

• Vertical and horizontal deflection platesVertical and horizontal deflection plates

• Beam strikes phosphor coating on front of tubeBeam strikes phosphor coating on front of tube

Electron Gun

Contains a filament that, when heated, emits a stream of Contains a filament that, when heated, emits a stream of electronselectrons

Electrons are focused with an electromagnet into a sharp Electrons are focused with an electromagnet into a sharp beam and directed to a specific point of the face of the beam and directed to a specific point of the face of the picture tubepicture tube

The front surface of the picture tube is coated with small The front surface of the picture tube is coated with small phospher dotsphospher dots

When the beam hits a phospher dot it glows with a brightness When the beam hits a phospher dot it glows with a brightness proportional to the strength of the beam and how often it is proportional to the strength of the beam and how often it is excited by the beamexcited by the beam

Contains a filament that, when heated, emits a stream of Contains a filament that, when heated, emits a stream of electronselectrons

Electrons are focused with an electromagnet into a sharp Electrons are focused with an electromagnet into a sharp beam and directed to a specific point of the face of the beam and directed to a specific point of the face of the picture tubepicture tube

The front surface of the picture tube is coated with small The front surface of the picture tube is coated with small phospher dotsphospher dots

When the beam hits a phospher dot it glows with a brightness When the beam hits a phospher dot it glows with a brightness proportional to the strength of the beam and how often it is proportional to the strength of the beam and how often it is excited by the beamexcited by the beam

Display Technologies: CRTs

Vector DisplaysVector Displays

• Anybody remember Anybody remember BattlezoneBattlezone? ? TempestTempest? ?

Display Technologies: CRTs

Vector DisplaysVector Displays

• Early computer displays: basically an oscilloscopeEarly computer displays: basically an oscilloscope

• Control X,Y with vertical/horizontal plate voltage Control X,Y with vertical/horizontal plate voltage

• Often used intensity as ZOften used intensity as Z

Name two disadvantagesName two disadvantages

Just does wireframeJust does wireframe

Complex scenes Complex scenes visible flicker visible flicker

Vector DisplaysVector Displays

• Early computer displays: basically an oscilloscopeEarly computer displays: basically an oscilloscope

• Control X,Y with vertical/horizontal plate voltage Control X,Y with vertical/horizontal plate voltage

• Often used intensity as ZOften used intensity as Z

Name two disadvantagesName two disadvantages

Just does wireframeJust does wireframe

Complex scenes Complex scenes visible flicker visible flicker

Display Technologies: CRTs

Raster DisplaysRaster Displays

• Raster: A rectangular array of points or dotsRaster: A rectangular array of points or dots

• Pixel: One dot or picture element of the rasterPixel: One dot or picture element of the raster

• Scan line: A row of pixelsScan line: A row of pixels

Raster DisplaysRaster Displays

• Raster: A rectangular array of points or dotsRaster: A rectangular array of points or dots

• Pixel: One dot or picture element of the rasterPixel: One dot or picture element of the raster

• Scan line: A row of pixelsScan line: A row of pixels

Display Technologies: CRTs

Raster DisplaysRaster Displays• Black and white television: an oscilloscope with a fixed Black and white television: an oscilloscope with a fixed

scan pattern: left to right, top to bottomscan pattern: left to right, top to bottom

• To paint the screen, computer needs to synchronize To paint the screen, computer needs to synchronize with the scanning pattern of rasterwith the scanning pattern of raster

– Solution: special memory to buffer image with scan-Solution: special memory to buffer image with scan-out synchronous to the raster. We call this the out synchronous to the raster. We call this the framebufferframebuffer..

Raster DisplaysRaster Displays• Black and white television: an oscilloscope with a fixed Black and white television: an oscilloscope with a fixed

scan pattern: left to right, top to bottomscan pattern: left to right, top to bottom

• To paint the screen, computer needs to synchronize To paint the screen, computer needs to synchronize with the scanning pattern of rasterwith the scanning pattern of raster

– Solution: special memory to buffer image with scan-Solution: special memory to buffer image with scan-out synchronous to the raster. We call this the out synchronous to the raster. We call this the framebufferframebuffer..

Display Technologies: CRTs

PhosphersPhosphers• Flourescence: Light emitted while the phospher is Flourescence: Light emitted while the phospher is

being struck by electronsbeing struck by electrons

• Phospherescence: Light emitted once the electron Phospherescence: Light emitted once the electron beam is removedbeam is removed

• Persistence: The time from the removal of the Persistence: The time from the removal of the excitation to the moment when phospherescence has excitation to the moment when phospherescence has decayed to 10% of the initial light outputdecayed to 10% of the initial light output

PhosphersPhosphers• Flourescence: Light emitted while the phospher is Flourescence: Light emitted while the phospher is

being struck by electronsbeing struck by electrons

• Phospherescence: Light emitted once the electron Phospherescence: Light emitted once the electron beam is removedbeam is removed

• Persistence: The time from the removal of the Persistence: The time from the removal of the excitation to the moment when phospherescence has excitation to the moment when phospherescence has decayed to 10% of the initial light outputdecayed to 10% of the initial light output

Display Technologies: CRTs

Raster DisplaysRaster Displays

• Frame must be “refreshed” to draw new imagesFrame must be “refreshed” to draw new images

• As new pixels are struck by electron beam, others are decayingAs new pixels are struck by electron beam, others are decaying

• Electron beam must hit all pixels frequently to eliminate flickerElectron beam must hit all pixels frequently to eliminate flicker

• Critical fusion frequencyCritical fusion frequency

– Typically 60 times/secTypically 60 times/sec

– Varies with intensity, individuals, phospher persistence, Varies with intensity, individuals, phospher persistence, lighting...lighting...

Raster DisplaysRaster Displays

• Frame must be “refreshed” to draw new imagesFrame must be “refreshed” to draw new images

• As new pixels are struck by electron beam, others are decayingAs new pixels are struck by electron beam, others are decaying

• Electron beam must hit all pixels frequently to eliminate flickerElectron beam must hit all pixels frequently to eliminate flicker

• Critical fusion frequencyCritical fusion frequency

– Typically 60 times/secTypically 60 times/sec

– Varies with intensity, individuals, phospher persistence, Varies with intensity, individuals, phospher persistence, lighting...lighting...

Display Technologies: CRTs

Raster DisplaysRaster Displays

• Interlaced ScanningInterlaced Scanning

• Assume can only scan 30 times / secondAssume can only scan 30 times / second

• To reduce flicker, divide frame into two “fields” of odd To reduce flicker, divide frame into two “fields” of odd and even linesand even lines

Raster DisplaysRaster Displays

• Interlaced ScanningInterlaced Scanning

• Assume can only scan 30 times / secondAssume can only scan 30 times / second

• To reduce flicker, divide frame into two “fields” of odd To reduce flicker, divide frame into two “fields” of odd and even linesand even lines

1/30 Sec 1/30 Sec1/60 Sec 1/60 Sec 1/60 Sec 1/60 SecField 1 Field 1Field 2 Field 2

Frame Frame

Display Technologies: CRTs

Raster DisplaysRaster Displays

• Scanning (left to right, top to bottom)Scanning (left to right, top to bottom)

– Vertical Sync Pulse: Signals the start of the next fieldVertical Sync Pulse: Signals the start of the next field

– Vertical Retrace: Time needed to get from the bottom of the Vertical Retrace: Time needed to get from the bottom of the current field to the top of the next fieldcurrent field to the top of the next field

– Horizontal Sync Pulse: Signals the start of the new scan lineHorizontal Sync Pulse: Signals the start of the new scan line

– Horizontal Retrace: The time needed to get from the end of Horizontal Retrace: The time needed to get from the end of the current scan line to the start of the next scan linethe current scan line to the start of the next scan line

Raster DisplaysRaster Displays

• Scanning (left to right, top to bottom)Scanning (left to right, top to bottom)

– Vertical Sync Pulse: Signals the start of the next fieldVertical Sync Pulse: Signals the start of the next field

– Vertical Retrace: Time needed to get from the bottom of the Vertical Retrace: Time needed to get from the bottom of the current field to the top of the next fieldcurrent field to the top of the next field

– Horizontal Sync Pulse: Signals the start of the new scan lineHorizontal Sync Pulse: Signals the start of the new scan line

– Horizontal Retrace: The time needed to get from the end of Horizontal Retrace: The time needed to get from the end of the current scan line to the start of the next scan linethe current scan line to the start of the next scan line

Display Technology: Color CRTs

Color CRTs are Color CRTs are muchmuch more complicated more complicated

• Requires manufacturing very precise geometryRequires manufacturing very precise geometry

• Uses a pattern of color phosphors on the screen:Uses a pattern of color phosphors on the screen:

• Why red, green, and blue phosphors?Why red, green, and blue phosphors?

Color CRTs are Color CRTs are muchmuch more complicated more complicated

• Requires manufacturing very precise geometryRequires manufacturing very precise geometry

• Uses a pattern of color phosphors on the screen:Uses a pattern of color phosphors on the screen:

• Why red, green, and blue phosphors?Why red, green, and blue phosphors?

Delta electron gun arrangement In-line electron gun arrangement

Display Technology: Color CRTs

Color CRTs haveColor CRTs have

• Three electron gunsThree electron guns

• A metal A metal shadow maskshadow mask to differentiate the beamsto differentiate the beams

Color CRTs haveColor CRTs have

• Three electron gunsThree electron guns

• A metal A metal shadow maskshadow mask to differentiate the beamsto differentiate the beams

Display Technology: Raster

Raster CRT pros:Raster CRT pros:

• Allows solids, not just wireframesAllows solids, not just wireframes

• Leverages low-cost CRT technology (i.e., TVs)Leverages low-cost CRT technology (i.e., TVs)

• Bright! Display Bright! Display emitsemits light light

Cons:Cons:

• Requires screen-size memory arrayRequires screen-size memory array

• Discreet sampling (pixels)Discreet sampling (pixels)

• Practical limit on size (call it 40 inches)Practical limit on size (call it 40 inches)

• BulkyBulky

• Finicky (convergence, warp, etc)Finicky (convergence, warp, etc)

Raster CRT pros:Raster CRT pros:

• Allows solids, not just wireframesAllows solids, not just wireframes

• Leverages low-cost CRT technology (i.e., TVs)Leverages low-cost CRT technology (i.e., TVs)

• Bright! Display Bright! Display emitsemits light light

Cons:Cons:

• Requires screen-size memory arrayRequires screen-size memory array

• Discreet sampling (pixels)Discreet sampling (pixels)

• Practical limit on size (call it 40 inches)Practical limit on size (call it 40 inches)

• BulkyBulky

• Finicky (convergence, warp, etc)Finicky (convergence, warp, etc)