Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive...
Transcript of Overview: Interactive Computer Graphics...Overview: Interactive Computer Graphics Interactive...
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
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
The Viewing Pipeline
ITCS 6010/8010 3 Review: Computer Graphics
Coordinate Systems
� Model Coordinates
� World Coordinates
� Viewing (Camera, Eye) Coordinates
� Perspective/Image Coordinates
� Screen/Display Coordinates
ITCS 6010/8010 4 Review: Computer Graphics
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
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
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
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
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
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
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
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
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
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
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
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
Planar Projections
Parallel Projection
◦ Projectors are parallel to each other.
Perspective
◦ Projectors converge to a point.
ITCS 6010/8010 17 Review: Computer Graphics
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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