CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image...

33
Introduction to Computer Graphics Dongguk University Jeong-Mo Hong CSE4030

Transcript of CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image...

Page 1: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Introduction to Computer Graphics

Dongguk University

Jeong-Mo Hong

CSE4030

Page 2: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Timetable

00:00~00:10 Introduction (English)

00:10~00:50 Topic 1 (English)

00:50~00:60 Q&A (English, Korean)

01:00~01:40 Topic 2 (English)

01:40~01:50 Quiz (English, Korean)

01:50~01:60 Q&A (English, Korean)

Page 3: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Week 2 • Let’s get drawing!

– How does your computer draw?

– A review on 2D graphics

Page 4: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Michelangelo and You

[Koller et al. 2004] [Michelangelo 1504]

Page 5: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Basic Graphics System

Input devices

Output device

Image formed in FB

Page 6: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Raster Graphics

• Image produced as an array (the raster) of picture elements (pixels) in the frame buffer

http://www.youtube.com/watch?v=Jwd5ya56wBI

Page 7: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Depth of Frame Buffer • Depth or precision of the frame buffer

– Determines how many colors can be represented on a give system

– 1-bit-deep frame buffer 2 colors

– 8-bit-deep frame buffer 2^8(256) colors

Page 8: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

CPU vs GPU

http://www.youtube.com/watch?v=fKK933KK6Gg (short version) http://www.youtube.com/watch?v=ZrJeYFxpUyQ&annotation_id=annotation_764898&feature=iv (full version)

• NVIDIA – Adam & Jamie draw a MONA LISA in 80 milliseconds!

– Parallel processing on GPU's

Page 9: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Object Seen by Different Viewers

FIGURE 1.6 Image seen by three different viewers. (a) A’s view. (b) B’s view. (c) C’s view.

Page 10: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Image Formation

3D 2D

Page 11: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

See the Difference?

Page 12: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Elements of Image Formation

• Objects

• Viewer

• 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)

Page 13: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Ray Interactions

FIGURE 1.11 Ray interactions. Ray A enters camera directly. Ray B goes off to infinity. Ray C is reflected by a mirror. Ray D goes trough a transparent sphere.

Page 14: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Ray Tracing and Geometric Optics

One way to form an image is to

follow rays of light from a

point source finding which

rays enter the lens of the

camera. However, each

ray of light may have

multiple interactions with objects

before being absorbed or going to infinity.

Page 15: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Three-Color Theory

• Human visual system has two types of sensors

– Rods: monochromatic, night vision

– Cones

• Color sensitive

• Three types of cones

• Only three values (the tristimulus

values) are sent to the brain

• Need only match these three values

– Need only three primary colors

Page 16: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Object

• Where did this image come from?

Page 17: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Wireframe Graphics

wireframe representation of sun object

Page 18: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Raster Graphics

• Allows us to go from lines and wire frame images to filled polygons

Page 19: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Recently

• Realism comes to computer graphics

smooth shading environment mapping

bump mapping

Page 20: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Break and Q&A

CSE4030

Page 21: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

The Programmer’s Interface • Programmer sees the graphics system through

a software interface: the Application Programmer Interface (API)

• OpenGL

• Open Graphics Library – API for 2D and 3D graphics programming

– GLUT – The OpenGL Utility Toolkit

Page 22: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

First Example

glBegin(GL_POLYGON)

glVertex3f(0.0, 0.0, 0.0);

glVertex3f(0.0, 1.0, 0.0);

glVertex3f(1.0, 0.0, 0.0);

glEnd( );

type of object

location of vertex

end of object definition

Page 23: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Simplified Pipeline

Page 24: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Geometric Pipeline

• Pipeline architecture

• All steps can be implemented in hardware on the graphics card

application program

display

Page 25: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

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

Page 26: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

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

Page 27: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Clipping

• Just as a real camera cannot “see” the whole world, the virtual camera can only see part of the world or object space – Objects that are not within this volume are said to be

clipped out of the scene

Page 28: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Primitive Assembly

• Vertices must be collected into geometric objects before clipping and rasterization can take place

– Line segments

– Polygons

– Curves and surfaces

Page 29: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Rasterization

• The primitives that emerge from the clipper are still in terms of their vertices

• They must be further processed to generate pixels in the frame buffer

• The output of rasterizer is a set of fragments for each primitive

• Fragments are “potential pixels” – Have a location in frame buffer

– Color and depth attributes

Page 30: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

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

• Fragments may be blocked by other fragments closer to the camera – Hidden-surface removal

Page 31: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Lab 2

• How to Start Graphics Programming

– GLUT setup

– Visual Studio environment setting

– GLUT API

• Preparing for a canvas (window)

• Input devices (keyboard, mouse)

Page 32: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Reading Assignment

• Appendix B Spaces

• Appendix C Matrices

Page 33: CSE4030 Introduction to Computer Graphics · 2011-12-28 · See the Difference? Elements of Image Formation ... Perspective projections: all projectors meet at the center of projection

Quiz

CSE4030