35
Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras and Viewing Transform Lighting and Shading Color Rendering Visible Surface Algorithms Rasterization Hardware ITCS 6010/8010 1 Review: Computer Graphics

Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

  • Upload
    others

  • View
    78

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Overview: Interactive Computer Graphics

� Interactive Graphics System Model

� Graphics Pipeline

� Coordinate Systems

� Modeling Transforms

� Cameras and Viewing Transform

� Lighting and Shading

� Color

� Rendering

� Visible Surface Algorithms

� Rasterization

� Hardware

ITCS 6010/8010 1 Review: Computer Graphics

Page 2: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

The Viewing Pipeline

3D Model 3D World Viewing Transform

CameraSpecification

3DClipping

Projectionto 2D

RenderingDisplay

LightingSpecification

Model coords World Coords�

Camera coords

Clippingcoords

Screen coords

ITCS 6010/8010 2 Review: Computer Graphics

Page 3: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

The Viewing Pipeline

ITCS 6010/8010 3 Review: Computer Graphics

Page 4: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Coordinate Systems

� Model Coordinates

� World Coordinates

� Viewing (Camera, Eye) Coordinates

� Perspective/Image Coordinates

� Screen/Display Coordinates

ITCS 6010/8010 4 Review: Computer Graphics

Page 5: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Graphics Primitives/Attributes

Primitives

� Point, Line, Polyline, Polygon, Rectangle, Circle

� Cubic Curves and Surfaces (Bezier, B-Spline, NURBS)

� Marker, Polymarker, Text

� Texture (2D, 3D)

Attributes

� Lines/Markers: style, width

� Color (R,G,B or index into lookup table)

� Filled Primitives: style, pattern

� Text: style (font), size, origin

ITCS 6010/8010 5 Review: Computer Graphics

Page 6: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Affine Transforms

� Most common in computer graphics.

� Permits a simple matrix representation

� Can be composed

Definition

[Qx Qy Qz

]=

a d gb e hc f k

Px

Py

Pz

+

Tx

Ty

Tz

~Q = ~M ~P + ~T

Primitive Affine Transforms:Scale, Rotate, Translate

ITCS 6010/8010 6 Review: Computer Graphics

Page 7: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Homogeneous Coordinates

� Allows all 3 primitive transforms to use a matrix representation.

� Add a fourth coordinate, w; additional column and row to matrix.

� To convert PH to P2D, divide each coordinate by the w and discardthe 3rd coordinate.

� w = 0 represents points at infinity.

PH = (Px, Py, Pz, Pw)

P3d = (Px/Pw, Py/Pw, Pz/Pw)

ITCS 6010/8010 7 Review: Computer Graphics

Page 8: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Modeling Transformations

Translation

T (tx, ty, tz) =

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

Scale

S(sx, sy, sz) =

sx 0 0 00 sy 0 00 0 sz 00 0 0 1

ITCS 6010/8010 8 Review: Computer Graphics

Page 9: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Modeling Transformations

Rotation

Rz(θ) =

cosθ −sinθ 0 0sinθ cosθ 0 0

0 0 1 00 0 0 1

Rx(θ) =

1 0 0 00 cosθ −sinθ 00 sinθ cosθ 00 0 0 1

Ry(θ) =

cosθ 0 sinθ 00 1 0 0

−sinθ 0 cosθ 00 0 0 1

ITCS 6010/8010 9 Review: Computer Graphics

Page 10: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Cameras and 3D Viewing

� A mechanism for specifying the the viewer location, orientation andvolume of the world that is of interest.

� A pin-hole camera model is assumed.

X�

Y�

Z�

VIEWER�

(CAMERA)

U

V�

N

ITCS 6010/8010 10 Review: Computer Graphics

Page 11: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Camera Parameters

� View Reference Point, ~V RP .

� Look At vector, ~N .

� Up Vector, ~V .

� Vector ~U = ~N × ~V

� Window

� Camera (viewer) position.

� Near and Far clipping planes.

These parameters specify a view volume (frustum) that is a truncatedpyramid .

ITCS 6010/8010 11 Review: Computer Graphics

Page 12: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

View Volume

ProjectionPlanet

Back

Frontt

Viewer�

N

� The volume of 3D space that is projected and displayed.

� Volume defined by a 2D window on the projection plane and frontand back clipping planes (hither/yon, near/far).

� View volume is specified in camera coordinates.

� View volume is a truncated frustum .

ITCS 6010/8010 12 Review: Computer Graphics

Page 13: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Viewing Transform

X

Y�

Z�

U

V�

N(0, 0, 0)

P (x, y, z)

Q (a, b, c)

World Coordinates Camera Coordinates(Right Handed) (Left Handed)

(rx, ry, rz)

� Object points in world coordinates are transformed into the cameracoordinate system with

� The viewer at the origin.

� Look-at vector along the negative Z axis.

� The Up vector along the Y axis.

ITCS 6010/8010 13 Review: Computer Graphics

Page 14: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Viewing Transform

The viewing transform is an affine transform, consisting of a rotation andtranslation, as follows:

Mwv =

ux uy uz rx

vx vy vz ry′

nx ny nz rz′

0 0 0 1

with ~r′ = (−~r.~U,−~r.~V ,−~r. ~N)

ITCS 6010/8010 14 Review: Computer Graphics

Page 15: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Geometric Projections

Projection

“An operation that transforms points in N-dimensional space to anotherof dimensionality less than n”

Geometric Projection

Application to geometric coordinate systems (Cartesian, Polar, Sphericaland Cylindric systems)

Types of Projections

� Planar

� Non-Planar

Application to Computer Graphics

1. Viewing 3D environments on a 2D screen.

2. Visualization of multi-variate data from scientific applications.ITCS 6010/8010 15 Review: Computer Graphics

Page 16: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Planar Projections

PLANAR

PARALLEL PERSPECTIVE

OBLIQUE ORTHOGRAPHIC

AXONOMETRIC� MULTI−VIEW

1−pt 2−pt�

3−pt�

ISOMETRIC DIMETRIC TRIMETRIC�

ITCS 6010/8010 16 Review: Computer Graphics

Page 17: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Planar Projections

Parallel Projection

◦ Projectors are parallel to each other.

Perspective

◦ Projectors converge to a point.

ITCS 6010/8010 17 Review: Computer Graphics

Page 18: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Perspective Projection

� Projectors converge to a point.

� All points on the same projector project to the same point, destroyingdepth information.

� Depth information must be carried along the pipeline for use in visi-ble surface calculations.

� Perspective transformation effectively involves a division of the 3Dpoint coordinates by its depth (from the view point).

Projection Plane at n = 0

t’P1

P2

P’

P(pu, pv, pn)

E(eu, ev, en)

ITCS 6010/8010 18 Review: Computer Graphics

Page 19: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Perspective Transformation

Projection Plane at n = 0

t’P1

P2

P’

P(pu, pv, pn)

E(eu, ev, en)

If ~P = (pu, pv, pn) is an object point, ~E = (eu, ev, en) is the cameraposition and ~P ′ = (p′u, p

′v, p

′n) is the projection point, assuming the

projection plane contains the origin of the camera coordinate system, itcan be shown that

p′u =pu

1− pn/en

p′v =pv

1− pn/en

ITCS 6010/8010 19 Review: Computer Graphics

Page 20: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Assuming p′n = pn

1−pn/enas a pseudo-depth, we can write

P ′ = (pu, pv, pn, 1− pn/en)

= [pu, pv, pn, 1] ~Mp

with

Mp =

1 0 0 00 1 0 00 0 1 −1/en

0 0 0 1

ITCS 6010/8010 20 Review: Computer Graphics

Page 21: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Lighting and Shading

The Rendering Equation

I(x, x′) = g(x, x′)

[ε(x, x′) +

∫S

ρ(x, x′, x′′)I(x′, x′′)dx′′]

whereI(x, x′) = Intensity of light passsing from x′ to x.g(x, x′) = “Geometry term”ε(x, x′) = Emitted light intensity from x′ to x.ρ(x, x′, x′′) = Light intensity scattered from x′′ to x by

a patch of surface at x′.

ITCS 6010/8010 21 Review: Computer Graphics

Page 22: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Local Lighting Model

� Consists of 3 components, ambient, diffuse and specular

Ambient Reflection

Ia = kaIa

� Ia is the ambient intensity, constant for all objects, and ka, the ambi-ent reflection coefficient.

� Use to model illumination that arrive at object points through indi-rect sources, such as nearby objects through multiple reflections orscattering.

ITCS 6010/8010 22 Review: Computer Graphics

Page 23: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Diffuse Reflection

Id = Ipkdcosθ

= Ipkd( ~N • ~L)

where ~N is the unit normal to the surface and ~L, the vector (of unitlength) to the light source, Ip the light source intensity.

� We approximate diffuse reflection using Lambert’s law.

� Intensity of light reflected is a constant, and independent of viewerposition.

ITCS 6010/8010 23 Review: Computer Graphics

Page 24: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Specular Reflection (Phong Model)

θ

L N

θ α

R

V Cos ( )�

α

α α α90 90 90

α4

64

Cos αCos

Is = kscosnα

= ks(~R • ~V )n

ITCS 6010/8010 24 Review: Computer Graphics

Page 25: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Local Illumination Model

Including ambient and diffuse reflections, the local lighting model be-comes

I = Ia + Id + Is

I = kaIa + Ip[kd( ~N • ~L) + ks(~R • ~V )n]

Assuming a wavelength based distribution of light and l light sources,

Iλ = Iaλka +

l∑1

fattiIpλi[kdλcos( ~N • ~Li) + ksλ( ~Ri • ~V )n]

ITCS 6010/8010 25 Review: Computer Graphics

Page 26: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Rendering Algorithms: Gouraud Shading

N1

N2

N3

N4

N v

I

I

I

1

2

3

I a I bI p

y

y

y

1

s

2

� Face Normals are averaged to obtain vertex normals.

� Vertex Intensities (I1, I2, I3) are obtained by application of a lightingmodel.

ITCS 6010/8010 26 Review: Computer Graphics

Page 27: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Rendering Algorithms: Phong Shading

A�

B

C

N

NN c

b

a

� Compute Normals at vertices of polygon.

� Interpolate each component of normal at any interior point of poly-gon

� Apply illumination model.

� Can easily be incorporated into a scanline algorithm.

ITCS 6010/8010 27 Review: Computer Graphics

Page 28: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Visible Surface Algorithms

Z (Depth) Buffer Algorithm (Catmull ’74)

� A buffer of Z or depth values is maintained, one for each pixel.

� During scan conversion, if primitive’s depth is less (closer) than theexisting value in the Z buffer, replace it and corresponding color (in-tensity) in the frame buffer.

� Each primitive is scanconverted once, independent of any otherprimitive and in any order.

� Z (depth) can be calculated from the polygon plane equation, orinterpolated from depth at polygon vertices

ITCS 6010/8010 28 Review: Computer Graphics

Page 29: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Z-Buffer Algorithm

For each object primitive{

For each pixel in projection{

Z = primitive’s depth value at pixel(x,y).if Z < Z BUF[x][y]{

Write ZBUF (x, y, Z)Write Pixel (x, y, pixel color)

}}

}

ITCS 6010/8010 29 Review: Computer Graphics

Page 30: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Rasterization

Scanline Polygon Fill Algorithm

With some modifications and additional parameters, is used to scancon-vert polygons along with the Z buffer algorithm

Approach

� Exploit the geometry of the polygon.

� Use scanline and edge coherence for efficient filling.

I0� I1 I2

�I3

A�

B

C

D

E

j�

ITCS 6010/8010 30 Review: Computer Graphics

Page 31: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Color Models

RGB Color Model

Red

Green

Blue

Yellow�

Cyan

Magenta White�

(1, 1, 1)

Black(0,0,0)

Application

– Color CRT Monitors.ITCS 6010/8010 31 Review: Computer Graphics

Page 32: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

CMY Color Model

� Complement of the RGB model.

� Uses subtractive primaries, Cyan, Magenta, Yellow. CMY

=

111

RGB

Application

� HardCopy Devices, such as ink jet color printers.

ITCS 6010/8010 32 Review: Computer Graphics

Page 33: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

HSV Color Model

HS

V�

whitered

yellowgreen

cyan

blue magenta

black

� Model defined in a cylindrical coordinate system.

� Colors are defined in a hexcone or six-sided pyramid.

� Based on the artist’s model of tints, shades and tones.

⇒ Hue is measured around the vertical axis.

⇒ Saturation ranges from 0 on the centerline to 1 on the triangularsides.

⇒ Value ranges from 0.0 (black) at the apex of the pyramid to 1.0(white) at the base.

ITCS 6010/8010 33 Review: Computer Graphics

Page 34: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Display Architecture

PeripheralDevicesCPU

System Memory

VideoController

Display

System Bus

Display Processor

FrameBuffer

� Video Controller reads the frame buffer through a special port.

� A single address space system.

� Memory contention is still a problem, but the flexibility of a singleaddress space (for raster ops, for instance) outweighs this factor.

ITCS 6010/8010 34 Review: Computer Graphics

Page 35: Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive Graphics System Model Graphics Pipeline Coordinate Systems Modeling Transforms Cameras

Graphics Processing Units (GPU)

� Modern graphics cards (Nvidia GEForce, ATI Radeon etc) are ex-tremely powerful computing platforms for processing/shading largeamounts of geometry

� Pipelined architecture

� Support for 3D textures (multitexturing, dependent texturing)

� May be used for general purpose computing

� Examples: Accelerated ray tracing, solving linear systems, fluid flow.

ITCS 6010/8010 35 Review: Computer Graphics