Upload
sheila-dixon
View
231
Download
0
Embed Size (px)
Citation preview
Chapter 4 Chapter 4 Vector GraphicsVector Graphics
Multimedia SystemsMultimedia Systems
Key PointsKey Points
Points can be identified by Points can be identified by coordinatescoordinates..Lines and shapes can be described by Lines and shapes can be described by equationsequations. .
Approximating abstract shapes on a grid of finite Approximating abstract shapes on a grid of finite pixels leads to `jaggies'.pixels leads to `jaggies'.Anti-aliasingAnti-aliasing can offset this effect. can offset this effect.
Bezier curvesBezier curves are drawn using four are drawn using four control control pointspoints. .
Bezier curves can be made to join together Bezier curves can be made to join together smoothly into smoothly into pathspaths. .
Paths and shapes can be Paths and shapes can be strokedstroked and and filledfilled. . Geometrical Geometrical transformationstransformations — translation, — translation,
scaling, rotation, reflection and shearing — can scaling, rotation, reflection and shearing — can be applied easily to vector shapes. be applied easily to vector shapes.
Key PointsKey Points Three approaches to 3-D modelling are: Three approaches to 3-D modelling are:
constructive solid geometryconstructive solid geometry, , free-form free-form modellingmodelling and and procedural modellingprocedural modelling. .
3-D 3-D renderingrendering models the effect of light and models the effect of light and texture, as well as displaying the modelled texture, as well as displaying the modelled objects in space. objects in space.
Ray tracingRay tracing and and radiosityradiosity are computationally are computationally expensive rendering algorithms that can produce expensive rendering algorithms that can produce photo-realistic results. photo-realistic results.
Specialized 3-D applications, such as Bryce and Specialized 3-D applications, such as Bryce and Poser, are easier to use, and may be more Poser, are easier to use, and may be more efficient, than more general 3-D modelling and efficient, than more general 3-D modelling and rendering systems. rendering systems.
IntroductionIntroduction Vector GraphicsVector Graphics
– CompactCompact– ScaleableScaleable– Resolution independent Resolution independent – Easy to editEasy to edit– Attractive for networked multimediaAttractive for networked multimedia
IntroductionIntroduction The compactness of vector graphics The compactness of vector graphics
makes them particular attractive for makes them particular attractive for network multimedia, since the large network multimedia, since the large sizes of the images files lend to sizes of the images files lend to excessive download times.excessive download times.
Absence of any standard format for Absence of any standard format for vector graphics prevents it from vector graphics prevents it from popularization.popularization.– As SVG and SWF standards are adopted, As SVG and SWF standards are adopted,
this will change.this will change.
IntroductionIntroduction In vector graphics, images are built In vector graphics, images are built
up using shapes that can easily be up using shapes that can easily be described mathematically.described mathematically.
Vector graphics has been eclipsed Vector graphics has been eclipsed (( 衰退衰退 ) in recent years by bitmap ) in recent years by bitmap graphics for 2D images.graphics for 2D images.
Vector graphics is mandatory (Vector graphics is mandatory ( 強制強制性性 ) in 3D graphics, since processing ) in 3D graphics, since processing voxels is still impractical in modern voxels is still impractical in modern machines.machines.
Coordinates and VectorsCoordinates and Vectors Image stored as a rectangular array of Image stored as a rectangular array of
pixels.pixels. Coordinates (x,y), Fig. 4.1Coordinates (x,y), Fig. 4.1
– IntegerInteger Real coordinate, (2.35, 2.9), Fig. 4.2Real coordinate, (2.35, 2.9), Fig. 4.2 Drawing programs allow to display axes Drawing programs allow to display axes
(ruler) along edges of your drawing(ruler) along edges of your drawing VectorsVectors Approximating a straight line, Fig. 4.4Approximating a straight line, Fig. 4.4
Coordinates and VectorsCoordinates and Vectors
AA
BB
OO
A(3,7)B(7,3)O(0,0)
Points Points
Coordinates and VectorsCoordinates and Vectors LinesLines
Anti-aliasingAnti-aliasing Approximating a straight lineApproximating a straight line Using intermediate grey values Using intermediate grey values Brightness is proportional to area of Brightness is proportional to area of
intersectionintersection At the expense of At the expense of
fuzzinessfuzziness
ShapesShapes A simple mathematical A simple mathematical
representationrepresentation– Stored compactly and rendered Stored compactly and rendered
efficientlyefficiently Rectangles, squares, ellipses and Rectangles, squares, ellipses and
circles, straight lines, polygons, circles, straight lines, polygons, Bezier curvesBezier curves– Spirals and stars, sometimesSpirals and stars, sometimes
Fills with color, pattern or gradientsFills with color, pattern or gradients
PolylinesPolylines
RectanglesRectangles
EllipsesEllipses
CurvesCurves
Hermite parametric cubic curvesC = C(t) = a0 + a1 t+ a2 t2 + a3 t3
– Four vectors a0 , a1 , a2 , a3 (12 coefficients, 3D) are required to define the curve.
– Usually these vectors can be specified by curve’s behavior at end points t=0 and t=1
Assume endpoints C(0), C(1) tangent vectors, C’(0), C’(1) are given, then
a0 = C(0)
a0 + a1 + a2 + a3 = C(1)
a1 = C’(0)
a1 +2 a2 + 3 a3 = C’(1)
Hermite CurvesHermite Curves
Hermite CurvesHermite Curves• a0 = C(0)
a1 = C’(0)a2 = 3( C(1) - C(0)) - 2C’(0) - C’(1)a3 = 2 ( C(0) - C(1)) + C’(0) + C’(1)
• C(t) = (1-3t2 + 2t3) C(0) + (3t2 -2t3) C(1) + (t - 2t2 + t3) C’(0) + (-t2 + t3) C’(1))
C(t) = [1 t t2 t3 ] 1 0 0 0 C (0) 0 0 1 0 C (1) -3 3 3 -2 C’(0) 2 -2 1 1 C’(1)
T0T1
Bezier CurvesBezier CurvesGiven four control points b0 , b1 , b2 , b3 , then
the corresponding Bezier curve is given byC(t) = (1-t)3b0 + 3t(1-t)2b1 + 3t2(1-t)b2 + t3b3
C’(t) = -3(1-t)2b0 + 3(1-4t+3t2)b1 + 3(2t-3t2)b2 + 3t2b3
C(0)=b0
C(1)=b3
C’(0)=3(b1-b0)C’(1)=3(b3-b2)
Bezier CurvesBezier CurvesC(t) = [1 t t2 t3 ] 1 0 0 0 b0
-3 3 0 0 b1
3 -6 3 0 b2
-1 3 -3 1 b3
b0
b1 b2
b3
Bezier CurvesBezier Curves Four control pointsFour control points
– Two endpoints, two direction pointsTwo endpoints, two direction points– Length of lines from each endpoint to its Length of lines from each endpoint to its
direction point representing the speed with direction point representing the speed with which the curve sets off towards the direction which the curve sets off towards the direction pointpoint
– Fig. 4.8, 4.9Fig. 4.8, 4.9
Bezier CurvesBezier Curves– Constructing a Bezier curveConstructing a Bezier curve
Fig. 4.10-13Fig. 4.10-13 Finding mid-points of linesFinding mid-points of lines
Bezier CurvesBezier Curves– Figs. 4.14-18Figs. 4.14-18
Same control points but in different ordersSame control points but in different orders
Bezier CurvesBezier Curves
b0
b1 b2
b3
b01
b11
b21b02 b12b03
Bezier Cubic CurvesBezier Cubic Curves
x(t) = ax t3 + bx t2 + cx t + x1
y(t) = ay t3 + by t2 + cy t + y1
p1 = (x1, y1)
p2 =(x1 + cx/3, y1 + cy/3)
p3 =(x2 + (cx + bx )/3, y2 + (cy + by )/3)
p4 =(x1 + cx + bx + ax, y1 + cy + by + ay)
Smooth Joins between Curves Smooth Joins between Curves Fig. 20Fig. 20
– Length of direction linesLength of direction linesis the same on each sideis the same on each side
Smoothness of joins when control points Smoothness of joins when control points line up and direction lines are the same line up and direction lines are the same lengthlength
Corner pointCorner point– Direction lines of adjacent segments ate not Direction lines of adjacent segments ate not
lines up, Fig. 4.21lines up, Fig. 4.21
Changing a smooth curve to a corner and vice versaChanging a smooth curve to a corner and vice versa
convert-anchor-point tool
PathsPaths Joined curves and lines Joined curves and lines
Open pathOpen path
Closed pathClosed path
Each line or curve is called a segment of the Each line or curve is called a segment of the pathpath
Anchor points: where segments joinAnchor points: where segments join Pencil tool: freehandPencil tool: freehand
– Bezier curve segments and straight lines are being Bezier curve segments and straight lines are being created to approximate the path your cursors follows created to approximate the path your cursors follows
– A higher tolerance leads to a more efficient path with A higher tolerance leads to a more efficient path with fewer anchor points which may smooth out of the fewer anchor points which may smooth out of the smaller movements you made with pencil toolsmaller movements you made with pencil tool
Stroke and FillStroke and Fill Apply stroke to pathApply stroke to path
– Drawing program have characteristics Drawing program have characteristics such as weight and color, which such as weight and color, which determine their appearance.determine their appearance.
– Weight= width of strokeWeight= width of stroke– Dashed effectsDashed effects
Length of dashesLength of dashesGaps between themGaps between them
Line Caps & JoinsLine Caps & Joins Line capLine cap
– Butt capButt cap– Round capRound cap– Projecting capProjecting cap
Line JoinsLine Joins– MiterMiter– RoundedRounded– BevelBevel
FillFill Most drawing programs also allow to fill an Most drawing programs also allow to fill an
open pathopen path– Close the path with straight line between its Close the path with straight line between its
endpointsendpoints
– Flat color, pattern or gradientsFlat color, pattern or gradients– Gradient: linear, radialGradient: linear, radial– Texture Texture
FillFill PatternPattern
– Tiles: a small piece of artworkTiles: a small piece of artwork– Use pattern to stroke paths, a textured outlineUse pattern to stroke paths, a textured outline
Arrange perpendicular to path, not horizontallyArrange perpendicular to path, not horizontally Include special corner tilesInclude special corner tiles
If you want to fill a path, you need to know which If you want to fill a path, you need to know which areas are inside it. (Fig. 4.27)areas are inside it. (Fig. 4.27)– Non-zero winding number ruleNon-zero winding number rule
Draw a line from the point in any directionDraw a line from the point in any direction Every time the path crosses it from left to right, add one to Every time the path crosses it from left to right, add one to
winding number; every time the path crosses from right to winding number; every time the path crosses from right to left, subtract one from winding numberleft, subtract one from winding number
If winding number is zero, the point is outside the path, If winding number is zero, the point is outside the path, otherwise it is inside.otherwise it is inside.
Depends on the path’s having a directionDepends on the path’s having a direction
Transformations and FiltersTransformations and Filters TransformationsTransformations
– Translations: linear Translations: linear movementmovement
– Scaling, rotation Scaling, rotation about a pointabout a point
– Reflective about a Reflective about a lineline
– Shearing: a Shearing: a distortion of angles distortion of angles of axes of an of axes of an objectsobjects
FiltersFilters Free manipulation of control pointsFree manipulation of control points RougheningRoughening
– moves anchor points in a jagged array moves anchor points in a jagged array from the original object, creating a rough from the original object, creating a rough edge on the object edge on the object
Scribbling filterScribbling filter– randomly distorts objects by moving anchor randomly distorts objects by moving anchor
points away from the original object points away from the original object
RoundingRounding– converts the corner points of an object to converts the corner points of an object to
smooth curvessmooth curves– Filter > Stylize > Round CornersFilter > Stylize > Round Corners
Only relatively few points need to be re-Only relatively few points need to be re-computedcomputed
3-D Graphics3-D Graphics Axes in 3D: Fig. 4.35Axes in 3D: Fig. 4.35 Rotations in 3D: Fig. 4.36Rotations in 3D: Fig. 4.36
3-D Graphics3-D Graphics Right-handed coordinate system, Fig. 4.37Right-handed coordinate system, Fig. 4.37 2D: define shapes by paths2D: define shapes by paths
3D: define objects by surfaces3D: define objects by surfaces Hierarchical modelingHierarchical modeling
– A bicycle consists of a frame, two wheels, …A bicycle consists of a frame, two wheels, …
RenderingRendering In 3D, we have a mathematical model of In 3D, we have a mathematical model of
objects in space, but we need a flat objects in space, but we need a flat picture.picture.– ViewpointViewpoint– Position of cameraPosition of camera– Scaling with distanceScaling with distance– Lighting: position, intensity, typeLighting: position, intensity, type
Interaction of light: underwater, smoke-filled roomInteraction of light: underwater, smoke-filled room
– TextureTexture– Physical impossibilities: negative spotlights, Physical impossibilities: negative spotlights,
absorbing unwanted lightabsorbing unwanted light
3D Models3D Models
Constructive solid geometryConstructive solid geometry– A few primitive geometric solids such as cube, A few primitive geometric solids such as cube,
cylinder, sphere and pyramid as elements from cylinder, sphere and pyramid as elements from which to construct more complex objectswhich to construct more complex objects
– Operators: union, intersection, and difference, Operators: union, intersection, and difference, Figs. 38-40Figs. 38-40
– Physical impossibility Physical impossibility
Free Form ModelingFree Form Modeling Mesh of polygonsMesh of polygons A certain regular structure or symmetry A certain regular structure or symmetry
from 2D shapesfrom 2D shapes– Treat a 2D shape as cross section and define a Treat a 2D shape as cross section and define a
volume by sweeping the cross section along a volume by sweeping the cross section along a pathpath
ExtrusionExtrusion
– To produce more elaborate objectsTo produce more elaborate objects Curved path can be usedCurved path can be used Size of cross section can be alteredSize of cross section can be altered LathingLathing
Procedural ModelingProcedural Modeling Models described by equationsModels described by equations Fractals, Fig. 4.42Fractals, Fig. 4.42
– CoastlinesCoastlines– MountainsMountains– Edges of cloudy Edges of cloudy – Fig. 4.43, snowflakeFig. 4.43, snowflake– Fractal mountainside, Fig. 4.44Fractal mountainside, Fig. 4.44
Procedural ModelingProcedural Modeling 3D Fractals3D Fractals
– Fig. 4.45Fig. 4.45– Fractal terrain, Fig. 4.46Fractal terrain, Fig. 4.46
Procedural ModelingProcedural Modeling MetaballsMetaballs
– Model soft objectsModel soft objects– Fig. 4.47Fig. 4.47– Complex objects can be built by Complex objects can be built by
sticking metaballs togethersticking metaballs together Particle systemsParticle systems
– Features made out of many particlesFeatures made out of many particles– Rains, fountains, fireworks, grass Rains, fountains, fireworks, grass
MetaballsMetaballs Metaballs are also included and make a Metaballs are also included and make a
great addition to helping create base great addition to helping create base models for further editing.models for further editing.A Metaball can be used in either a A Metaball can be used in either a positive or negative way in trueSpace 5. positive or negative way in trueSpace 5.
LightwaveLightwave Particle explosionParticle explosion Particle Storm 2.0 Particle Storm 2.0
Particle Storm 2.0Particle Storm 2.0
RenderingRendering Wire frame, Fig. 4.48Wire frame, Fig. 4.48 Hidden surface removalHidden surface removal Surface propertiesSurface properties
– Color and reflectivityColor and reflectivity LightsLights
– ShadingShading A color for each polygonA color for each polygon Interpolate colorInterpolate color
– Gouraud shadingGouraud shading– Phong shading: specular reflectionPhong shading: specular reflection
WireframeWireframe
Backface removal Backface removal
Flat shadingFlat shading
Gouraud shading Gouraud shading
Phong Shading Phong Shading with different with different material settings material settings and shininessand shininess
Ray tracingRay tracing– Tracing the path of a ray of light back from Tracing the path of a ray of light back from
each pixel , Plate 8each pixel , Plate 8– Photo-realistic graphicsPhoto-realistic graphics– High-performance workstationsHigh-performance workstations
RadiosityRadiosity– Interactions between objectsInteractions between objects– Model complex reflections that occur between Model complex reflections that occur between
surfaces that are close togethersurfaces that are close together
POV-Ray POV-Ray Persistence of Vision Ray Tracer Persistence of Vision Ray Tracer http://www.povray.org/, Freehttp://www.povray.org/, Free
RadiosityRadiosity (a) Actual photo (b) Radiosity image(a) Actual photo (b) Radiosity image
More accurately based on physics of light More accurately based on physics of light than other shading algorithmsthan other shading algorithms
Texture MappingTexture Mapping Adding surface detailsAdding surface details
– Mathematically wrapped over surface of Mathematically wrapped over surface of objectobject
– Produce appearance of objectProduce appearance of object Bump mappingBump mapping
– Apply bumpiness or roughness and Apply bumpiness or roughness and transparency mapping and reflection transparency mapping and reflection mapping, which modify the mapping, which modify the corresponding optical characteristics on corresponding optical characteristics on the basis of a 2D mapthe basis of a 2D map
Planar Mapping Planar Mapping
Mapping To A Cube Mapping To A Cube
Cylindrical MappingCylindrical Mapping
Spherical Mapping Spherical Mapping
Bump MappingBump Mapping St.Mattew head model is first simplified, St.Mattew head model is first simplified,
reducing its geometry from 4 millions of faces reducing its geometry from 4 millions of faces (left) to just 5 hundreds (middle).(left) to just 5 hundreds (middle).The detail lost is then reproduced with an ad-The detail lost is then reproduced with an ad-hoc bumpmap (right).hoc bumpmap (right).The resulting model is dynamically shaded, The resulting model is dynamically shaded, very similar to the original, but rendered very similar to the original, but rendered incomparably faster. incomparably faster.
Bump Mapping with Light Model Bump Mapping with Light Model
Specialized Types of 3D GraphicsSpecialized Types of 3D Graphics
Build a body out of arms and legsBuild a body out of arms and legs Rendering engine can use algorithms Rendering engine can use algorithms
that are optimized for the that are optimized for the characteristic models produced characteristic models produced within limits set by the modellerwithin limits set by the modeller– MetaCreations Bryce for landscapes andMetaCreations Bryce for landscapes and
Poser for human and animal figuresPoser for human and animal figures
BryceBryce CorelCorel Constructed from a grayscale image whose Constructed from a grayscale image whose
brightness represents height of 3D terrain modelbrightness represents height of 3D terrain model Terrains can be based on an imported image, or Terrains can be based on an imported image, or
one painted by hand; they can be generated one painted by hand; they can be generated using fractals or built from satellite data.using fractals or built from satellite data.
Sky, atmosphere, clouds, fog, haze, sun, moon, Sky, atmosphere, clouds, fog, haze, sun, moon, stars, rainbowsstars, rainbows
PoserPoser Curious Labs Curious Labs Manikins (Manikins (人體模型人體模型 )) Physically realizable: hand on a figure of Physically realizable: hand on a figure of
a person cannot turn 360a person cannot turn 360