computer graphics - computer science

32
Computer Graphics 3D graphics, raster and colors CS312 – Fall 2010

Upload: others

Post on 28-Nov-2021

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Graphics - Computer Science

Computer Graphics 3D graphics, raster and colors

CS312 – Fall 2010

Page 2: Computer Graphics - Computer Science

Shift in CG Application Markets 1989-2000

1989

2000

Page 3: Computer Graphics - Computer Science

3D Graphics

Object description

3D graphics model Visualization

2D projection that simulates the appearance of a real object

Page 4: Computer Graphics - Computer Science

Graphics System

Applications program

Geometric processing Frame Buffer

Video controller

Display

Model databases

Processor Display hardware

Interaction

Page 5: Computer Graphics - Computer Science

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 6: Computer Graphics - Computer Science

Ray Tracing

One way to form an image is to follow rays of light from a point source and determine which rays enter the lens of the camera.

Page 7: Computer Graphics - Computer Science

Luminance and Color Images

•  Luminance Image – Monochromatic – Values are gray levels – Analogous to working with black and white

film or television •  Color Image

– Has perceptional attributes of hue, saturation, and lightness

– Do we have to match every frequency in visible spectrum?

Page 8: Computer Graphics - Computer Science

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 9: Computer Graphics - Computer Science

Shadow Mask CRT

Page 10: Computer Graphics - Computer Science

Additive and Subtractive Color

•  Additive color – Form a color by adding amounts of three

primaries •  CRTs, projection systems, positive film

– Primaries are Red (R), Green (G), Blue (B) •  Subtractive color

– Form a color by filtering white light with cyan (C), Magenta (M), and Yellow (Y) filters •  Light-material interactions •  Printing •  Negative film

Page 11: Computer Graphics - Computer Science

Pinhole Camera

xp= -x/z/d yp= -y/z/d

Use trigonometry to find projection of point at (x,y,z)

These are equations of simple perspective

zp= d

Page 12: Computer Graphics - Computer Science

Synthetic Camera Model

center of projection

image plane

projector

p

projection of p

Page 13: Computer Graphics - Computer Science

Practical Approach

•  Process objects one at a time in the order they are generated by the application – Can consider only local lighting

•  Pipeline architecture

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

application program display

Page 14: Computer Graphics - Computer Science

The Programmer’s Interface

•  Programmer sees the graphics system through a software interface: the Application Programmer Interface (API)

Page 15: Computer Graphics - Computer Science

Following the Pipeline: Transformations

•  Much of the work in the pipeline is in converting object representations from one coordinate system to another – World coordinates – Camera coordinates – Screen coordinates

•  Every change of coordinates is equivalent to a matrix transformation

Page 16: Computer Graphics - Computer Science

Clipping

•  Objects that are not within the viewing volume are said to be clipped out of the scene

Page 17: Computer Graphics - Computer Science

Projection

•  Must carry out 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 18: Computer Graphics - Computer Science

Rasterization •  If an object is visible in the image, the

appropriate pixels in the frame buffer must be assigned colors – Vertices assembled into objects – Effects of lights and materials must be

determined – Polygons filled with interior colors/shades – Must have also determined which objects are

in front (hidden surface removal)

Page 19: Computer Graphics - Computer Science

Rasterization The process of transforming geometric

shapes into discrete raster grids.

Page 20: Computer Graphics - Computer Science

Raster Graphics

•  Spatial resolution= elements×scan lines e.g. 5 × 5 (below)

•  Intensity or color resolution = 2Depth

Element / pixel

Scan line

Depth

here, each pixel can have any of 2^3 = 8 possible values.

Page 21: Computer Graphics - Computer Science

Color

C = rR + gG + bB

•  Minimum number of levels for just noticeable intensity difference is 100, or about 7 bits.

•  Thus, use at least 8 bits per color (R, G, B) (10-24 for photographic quality)

Page 22: Computer Graphics - Computer Science

Frame Buffer Architectures

•  The raster image is stored in a “frame buffer” memory.

•  The frame buffer is built from one or more “bit planes” --two-dimensional arrays of bits.

•  This memory is usually peripheral to the host on a video card.

Page 23: Computer Graphics - Computer Science

Black and White Frame Buffer with 1 Bit Plane

1

1 bit 2 levels

1

Page 24: Computer Graphics - Computer Science

Frame Buffer Configurations

•  Can drive a digital-to-analog converter directly, or use these values as an index into a “lookup table” (“color map”, etc.)

N: number of bit planes

=> 2N intensity levels

Page 25: Computer Graphics - Computer Science

Grey Scale Frame Buffer with N Bit Planes

101 (for example)

N bits levels

3 bit DAC

N

Page 26: Computer Graphics - Computer Science

Grey Scale Frame Buffer with Look-Up Table

101

N

Look-up value stored in address 101 (=5), e.g. 110101 (53 from range 0-63)

110101

6 bit DAC (64 levels)

Page 27: Computer Graphics - Computer Science

8 Color Frame Buffer (3 Bit Planes)

101

3

Page 28: Computer Graphics - Computer Science

3 Bit Planes = 8 Colors

0 0 0 == BLACK 1 0 0 == RED 0 1 0 == GREEN 0 0 1 == BLUE 1 1 0 == YELLOW 0 1 1 == CYAN 1 0 1 == MAGENTA 1 1 1 == WHITE

Page 29: Computer Graphics - Computer Science

N

N

N

3N

6

3

7

Color Frame Buffer with 3N Bit Planes

Page 30: Computer Graphics - Computer Science

CFB with 3N Bit Planes and LUT

18

N

N

N 3N

6

3

7

25

54

Page 31: Computer Graphics - Computer Science

Newer Architectures

•  Additional memory planes per pixel: – Z (depth) – Alpha blending – Stencils (to select areas for

operations) •  Separate texture memory

Page 32: Computer Graphics - Computer Science

Raster Graphics “Primitives”

• Points

• Lines

• Rectangles

• Circles or Conics

• Disks

• Polygons

• Characters or Special symbols

• Bit maps, sprites, or patterns

G