Date post: | 14-Jan-2016 |
Category: |
Documents |
Upload: | allan-james |
View: | 217 times |
Download: | 1 times |
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Lecture 35 of 42
Wednesday, 23 April 2008
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course pages: http://snipurl.com/1y5gc
Course web site: http://www.kddresearch.org/Courses/CIS636
Instructor home page: http://www.cis.ksu.edu/~bhsu
Readings:
Chapter 6, Eberly 2e – see http://snurl.com/1ye72
Animation 3: Character Modeling, IKSpatial Sorting Concluded
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Depth Comparison using a Z-Buffer – Image PrecisionDepth Comparison using a Z-Buffer – Image Precision
The Z-buffer algorithm The Z-buffer is initialized to the background value (furthest plane of view
volume = 1.0) As each object is traversed, the z-values of all its sample points are compared
to the z-value in the same (x, y) location in the Z-buffer z could be determined by plugging x and y into the plane equation for the polygon
(ax + by + cz + d = 0) in reality, we calculate the z at vertices and interpolate the rest
If the new point has z value less than the previous one (i.e., closer to the eye), its z-value is placed in the z-buffer and its color placed in the frame buffer at the same (x, y); otherwise the previous z-value and frame buffer color are unchanged
Can store depth as integers or floats or fixed points i.e.for 8-bit (1 byte) integer z-buffer, set 0.0 ->0 and 1.0 ->255 each representation has its advantages in terms of precision
avd November 4, 2003 VSD 30/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Z-Buffer Algorithm (1/3)Z-Buffer Algorithm (1/3)
Requires two “buffers”Intensity Buffer —our familiar RGB pixel buffer
—initialized to background color
Depth (“Z”) Buffer —depth of scene at each pixel
—initialized to far depth = 255
Polygons are scan-converted in arbitrary order. When pixels overlap, use Z-buffer to decide which polygon “gets” that pixel
Above: example using integer Z-buffer with near = 0, far = 255
avd November 4, 2003 VSD 31/46
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255255 255 255 255 255 255 255 255
127 127 127 127 127 127 127 255
127 127 127 127 127 127 255 255127 127 127 127 127 255 255 255127 127 127 127 255 255 255 255127 127 127 255 255 255 255 255127 127 255 255 255 255 255 255127 255 255 255 255 255 255 255255 255 255 255 255 255 255 255
127 127 127 127 127 127 127
127 127 127 127 127 127127 127 127 127 127127 127 127 127127 127 127127 127127
127 127 127 127 127 127 127 255
127 127 127 127 127 127 255 255127 127 127 127 127 255 255 255127 127 127 127 255 255 255 255127 127 127 255 255 255 255 255127 127 255 255 255 255 255 255127 255 255 255 255 255 255 255255 255 255 255 255 255 255 255
+ =
127 127 127 127 127 127 127 255
127 127 127 127 127 127 255 255127 127 127 127 127 255 255 25563 127 127 127 255 255 255 25563 63 127 255 255 255 255 25563 63 63 255 255 255 255 25563 63 63 63 255 255 255 25563 63 63 63 63 255 255 255
6363 6363 63 6363 63 63 6363 63 63 63 63
+ =
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Z-Buffer Algorithm (2/3)Z-Buffer Algorithm (2/3)
We draw every polygon that we can’t reject trivially If we find a piece (one or more pixels) of a polygon that is closer to the front, we paint
over whatever was behind itvoid zBuffer(){ int x, y;
for ( y = 0; y < YMAX; y++)for ( x = 0; x < XMAX; x++) {
WritePixel (x, y, BACKGROUND_VALUE);WriteZ (x, y, 1);
}for each polygon
for each pixel in polygon’s projection {double pz = polygon’s Z-value at pixel (x, y);if ( pz < ReadZ (x, y) ) { /* New point is closer to front of view */ WritePixel (x, y, polygon’s color at pixel (x, y)); WriteZ (x, y, pz);}
}}
Z-Buffer Applet:http://www.cs.technion.ac.il/~cs234325/Homepage/Applets/applets/zbuffer/GermanApplet.html
avd November 4, 2003 VSD 32/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Z-Buffer Algorithm (3/3)Z-Buffer Algorithm (3/3)
So how do we compute this efficiently? The answer is simple: do it incrementally! Remember scan conversion/polygon filling? As we moved along the Y-axis, we
tracked an x position where each edge intersected the current scan-line We can do the same thing for the z coordinate using simple “remainder”
calculations with the y-z slope
Once we have za and zb for each edge, we can incrementally calculate zp as we scan across
We did something similar with calculating color per pixel... (Gouraud shading)
avd November 4, 2003 VSD 33/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Z-Buffer ProsZ-Buffer Pros
Simplicity lends itself well to hardware implementations: FASTused by most 3-D workstations and inexpensive PC graphics cards
Polygons do not have to be compared in any particular order: no presorting in z is necessary, a big gain!
Only consider one polygon at a time ...even though occlusion is a global problem!brute force, but it is fast!
Z-buffer can be stored w/ an image; allows you to correctly composite multiple images (easy!) w/o having to merge the models (hard!)
great for incremental addition to a complex sceneall VSD algorithms could produce a Z-buffer for this
Can be used for non-polygonal surfaces, CSGs (intersect, union, difference), any z = f(x,y)
avd November 4, 2003 VSD 34/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Z-Buffer ConsZ-Buffer Cons
Precision problem: perspective foreshortening this is a compression in the z axis caused by perspective foreshortening, which maps z to
objects that were originally far away from the camera end up having smaller Z-values that are very close to each other
depth information loses precision rapidly, which gives Z-ordering bugs (artifacts) for distant objs
co-planar polygons (e.g., Quake III shadows, reflections) exhibit “z-fighting” - offset back polygon
floating-point values won’t completely cure this problem Can’t do anti-aliasing
requires knowing all polygons involved in a given pixel related A-buffer algorithm used for anti-aliasing
Must scan-convert all unclipped objects hierarchical Z-buffering (Greene & Kass SIGGRAPH ‘94) addresses this
zkz
kz
avd November 4, 2003 VSD 35/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Painter’s Algorithm – Image Precision
Painter’s Algorithm – Image Precision
A better way to resolve visibility exactly
Create drawing order, each poly overwriting the previous ones, that guarantees correct visibility at any pixel resolution
Strategy is to work back to front; find a way to sort polygons by depth (z), then draw them in that order
do a rough sort of the polygons by the smallest (farthest) z-coordinate in each polygon
scan-convert the most distant polygon first, then work forward towards the viewpoint (“painters’ algorithm”)
We can either do a complete sort and then scan-convert, or we can paint as we go – see 3D depth-sort algorithm by Newell, Newell, and Sancha
Any problems?
avd November 4, 2003 VSD 36/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Scan-Line Algorithm – Image Precision (1/2)Scan-Line Algorithm – Image Precision (1/2)
(Wylie, Romney, Evans and Erdahl)
For each horizontal scan line:find all intersections with edges of all polygons (ignore horizontal boundaries);sort intersections by increasing X and store in Edge Table;for each intersection on scan-line do
if edge intersected is left edge then {entering polygon}set in-code of polygondetermine if polygon is visible, and if so use its
color (from Polygon Table) up to next intersection;else edge is a right edge then {leaving polygon}
determine which polygon is visible to right of edge,and use its color up to next intersection;
avd November 4, 2003 VSD 37/46
Active Edge Table Contents
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Scan-Line Algorithm (2/2)Scan-Line Algorithm (2/2)
Generalization of single polygon scan conversion, with IN flags for polygons
Handles transparency and anti-aliasing well Hybrid algorithm: use single scan-line z-buffer to determine visibility
sort polygons by scan line like this algorithm. draw each scan line to a single-line Z-buffer; output colors, then clear the
buffer and re-use for the next scan line saves space, but loses good transparency, anti-aliasing qualities
Pretty much old school
avd November 4, 2003 VSD 38/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Object-Precision AlgorithmsObject-Precision Algorithms
Historically first approaches
Roberts ’63 - hidden line removalcompare each edge with every object - eliminate invisible edges or parts
of edges.
Complexity: worse than O(n2) since each object must be compared with all edges
A similar approach for hidden surfaces:each polygon is clipped by the projections of all other polygons in front of
it invisible surfaces are eliminated and visible sub-polygons are createdSLOW, ugly special cases, polygons only
avd November 4, 2003 VSD 39/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
3-D Depth-Sort Algorithm3-D Depth-Sort Algorithm
(Newell, Newell, and Sancha, based on work by Schumacher)
Handles errors/ambiguities of Z-sort:
Summary of algorithm
1. Initially, sort by smallest Z
2. Resolve ambiguities:
(a) Compare X extents
(b) Compare Y extents
(c) Is P entirely on one side of Q?
(d) Is Q entirely on one side of P?
(e) Compare X-Y projections (Polygon Intersection)
(f) Swap or split polygons
3. Scan convert back to front
avd November 4, 2003 VSD 40/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
3-D Depth-Sort Algorithm3-D Depth-Sort Algorithm
Advantages Fast enough for simple scenes Fairly intuitive
Disadvantages Slow for even moderately complex scenes Hard to implement and debug Lots of special cases
avd November 4, 2003 VSD 41/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Binary Space Partitioning (1/5)Binary Space Partitioning (1/5)
(Fuchs, Kedem, and Naylor, based on work by Schumacher) Provides spatial subdivision and draw order
Divide and conquer: to display any polygon correctly, display all polygons on “far” (relative to
viewpoint) side of polygon, then that polygon, then all polygons on polygon’s “near” side.
but how to display polygons on one side correctly? Choose one polygon and process it recursively!
Trades off view-independent preprocessing step (extra time and space) for low run-time overhead each time view changes
avd November 4, 2003 VSD 42/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Binary Space Partitioning (BSP) Trees (2/5)
Binary Space Partitioning (BSP) Trees (2/5)
Perform view-independent step once each time scene changes: recursively subdivide environment into a hierarchy of half-spaces by
dividing polygons in a half-space by the plane of a selected polygonbuild a BSP tree representing this hierarchyeach selected polygon is the root of a sub-tree
An example:
BSP-0: Initial Sceneavd November 4, 2003 VSD 43/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Binary Space Partitioning (BSP) Trees (3/5)
Binary Space Partitioning (BSP) Trees (3/5)
BSP-1: Choose any polygon (e.g., polygon 3) and subdivide othersby its plane, splitting polygons when necessary
BSP-2: Process front sub-tree recursivelyavd November 4, 2003 VSD 44/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Binary Space Partitioning (BSP) Trees (4/5)
Binary Space Partitioning (BSP) Trees (4/5)
BSP-3: Process back sub-tree recursively
BSP-4: An alternative BSP tree with polygon 5 at the root
avd November 4, 2003 VSD 45/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Binary Space Partitioning (BSP) Trees (5/5)
Binary Space Partitioning (BSP) Trees (5/5)
Perform BSP tree view-dependent step once each time viewpoint changes: the nodes can be visited in back-to-front order using a modified in-order walk of the tree. at any node, the far side of a node’s polygon is the side that the viewpoint is not in very fast! Quake III uses this for occlusion culling and to speed up intersection testing
void BSP_displayTree(BSP_tree* tree){if ( tree is not empty )
if ( viewer is in front of root ) {BSP_displayTree(tree->backChild);displayPolygon(tree->root);BSP_displayTree(tree->frontChild)
}else {
BSP_displayTree(tree->frontChild);/* ignore next line if back-face culling desired */displayPolygon(tree->root);BSP_displayTree(tree->backChild)
}}
BSP applet : http://symbolcraft.com/graphics/bsp/index.html
avd November 4, 2003 VSD 46/46
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
CS 352: Computer GraphicsCS 352: Computer Graphics
HierarchicalGraphics,Modeling,
And Animation
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
OverviewOverview
Modeling Animation Data structures
for interactive graphics CSG-tree BSP-tree Quadtrees and Octrees Visibility precomputation
Many figures and examples in this set of lectures are from The Art of 3D Computer Animation and Imaging, by I. Kerlow
Slides © 2004 Perkowski, M., Penn State UniversityECE 579/579/679 Intelligent Robotics II
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
ModelingModeling
The modeling problem Modeling primitives
Polygon Sphere, ellipsoid, torus, superquadric NURBS, surfaces of revolutions, smoothed polygons Particles Skin & bones
Approaches to modeling complex shapes Tools such as extrude, revolve, loft, split, stitch, blend Constructive solid geometry (CSG) Hierarchy; kinematic joints Inverse kinematics Keyframes
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Representing objectsRepresenting objects
Objects represented as symbols Defined in model coordinates; transformed into world coordinates
(M = TRS)glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glTranslatef(…);
glRotatef(…); glScalef(…);
glutSolidCylinder(…);
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
PrimitivesPrimitives
The basic sort of primitive is the polygon
Number of polygons: tradeoff between render time and model accuracy
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
SplineCurvesSplineCurves
Linear spline Cardinal spline B-spline Bezier curve NURBS (non-uniform
rational b-spline)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
MeshMesh
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Mesh deformationsMesh deformations
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
SweepSweep
Sweep a shape over a path to form a generalized cylinder
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
RevolutionRevolution
Revolve a shape around an axis to create an object with rotational symmetry
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
ExtrusionExtrusion
Extrude: grow a 2D shape in the third dimension
Shape is created with a (1D)b-spline curves
Hole was created by subtracting a cylinder
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Joining Primitives Joining Primitives
Stitching, blending
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Modifying Primitives Modifying Primitives
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Subdivision SurfacesSubdivision Surfaces
Can set level of polygon subdivision
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Skin and BonesSkin and Bones
Skeleton with joined “bones” Can add “skin” on top of bones Automatic or
hand-tunedskinning
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
ParticlesParticles
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Algorithmic Primitives
Algorithmic Primitives
Algorithms for trees, mountains, grass, fur, lightning, fire, …
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Geometric model file formatsGeometric model file formats
.obj: Alias Wavefront .dxf: Autocad .vrml: Inventor Dozens more Can convert
between formats Converting to a
common format may lose info…
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Hierarchical modelsHierarchical models
When animation is desired, objects may have parts that move with respect to each other Object represented as hierarchy Often there are joints with motion constraints E.g. represent wheels of car as sub-objects with rotational motion
(car moves 2 pi r per rotation)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
DAG modelsDAG models
Could use tree torepresent object
Actually, a DAG (directed acyclicgraph) is better: can re-use objects
Note that each arrow needs aseparate modeling transform
In object-oriented graphics, alsoneed motion constraints with eacharrow
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Example: RobotExample: Robot
Traverse DAG using DFS (or BFS) Push and pop matrices along the way
(e.g. left-child right-sibling)(joint position parameters?)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Modeling ProgramsModeling Programs
Moray Shareware Limited functionality Easy
Lightwave, Maya NOT shareware Very full-featured Difficult to learn and use
Moray, Maya demos; Lightwave video
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
AnimationAnimation
Suppose you want the robot to pick up a can of oil to drink. How?
You could set the joint positions at each moment in the animation (kinematics)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Inverse KinematicsInverse Kinematics
You can’t just invert the joint transformations
Joint settings aren’t even necessarily unique for a hand position!
Inverse kinematics: figure out from the hand position where the joints should be set.
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Using Inverse KinematicsUsing Inverse Kinematics
Specify joint constraintsand priorities
Move end effector(or object pose)
Let the system figureout joint positions
[IK demo]
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Keyframe AnimationKeyframe Animation
In traditional key frame animation the animator draws several important frames, and helpers do the “inbetweening” or “tweening”
Computer animation is also key-frame based At key frames, animator positions objects and lights, sets parameters,
etc. The system interpolates parameter values linearly or along a curve To get from one object pose to the next, inverse kinematics determine
joint motions [Keyframe animation demo]
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Motion CaptureMotion Capture
More realistic motion sequences can be generated by Motion Capture
Attach joint position indicatorsto real actors
Record live action
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
MorphingMorphing
Morphing: smoothly shifting from one image to another First popularized in a Michael Jackson video Method: a combination of
Warping both images, gradually moving control points from location in first image to location in the second
Cross-fading from first image sequence to second
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
3D Morphing3D Morphing
Define 3D before andafter shapes as e.g. NURBS surfaces with same number ofcontrol points
Gradually move control points fromfirst setting to second
Specify key poses: e.g. smile, frown, 12 frames of walking motion
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Combined approachesCombined approaches
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Example: virtual puppetryExample: virtual puppetry
Suppose you want to display virtual puppet shows How could you animate puppet movements? How could you control the animations externally?
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Character AnimationCharacter Animation
To make computer graphics(or cartoon drawings) come alive…
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Personality through Pose, Expression, Motion, Timing
Personality through Pose, Expression, Motion, Timing
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Object-oriented GraphicsObject-oriented Graphics
Higher in the programming hierarchy: control models with object-oriented programs
robot robbie;
robbie.smile();
robbie.walk(270, 5, 3);
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Data Structures for Modeling Data Structures for Modeling
This part of chapter: how some example applications be done efficiently (i.e. topics without a better home…)
Tree-based subdivisions of space Example 1: how to represent complex objects made up of union,
intersection, difference of other objects
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
CSG TreeCSG Tree
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Application 2: HSRApplication 2: HSR
How to render in 3D with hidden surface removal when you don’t have a hardware depth-buffer?
Can you think of any other ways of removing hidden surfaces quickly?
Principle: a polygon can’t be occluded by another polygon that is behind it.
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
BSP-treeBSP-tree
The painter’s algorithm for hidden surface removal works by drawing all faces, from back to front
How to get a listing of the faces in back-to-front order? Put them into a binary tree and traverse the tree (but in what
order?)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
BSP Tree FiguresBSP Tree Figures
Right is “front” of polygon; left is “back” In and Out nodes show regions of space inside or outside the
object (Or, just store split pieces of polygons at leaves)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Traversing a BSP treeTraversing a BSP tree
Binary Space Partition tree: a binary tree with a polygon at each node Children in left subtree are behind polygon Children in right subtree are in front of polygon
Traversing a BSP-tree: If null pointer, do nothing Else, draw far subtree, then polygon at current node, then near
subtree Far and near are determined by location of viewer
Runtime of traversal? Drawbacks?
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Building a BSP treeBuilding a BSP tree
Inserting a polygon: If tree is empty make it the root If polygon to be inserted intersects plane of polygon of current node,
split and insert half on each side recursively. Else insert on appropriate side recursively
Problem: the number of faces could grow dramatically Worst case (O(n2))…but usually it doesn’t grow too badly in practice…
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
BSP-tree SummaryBSP-tree Summary
Returns polygons not necessarily in sorted order, but in an order that is correct for back-to-front rendering
Widely used when Z-buffer hardware may not be available (e.g. game engines)
Guarantees back-to-front rendering for alpha blending Works well (linear-time traversals) in the number of split polygons [And we hope the number of polygons doesn’t grow too much
through splitting]
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Application 3: Handling Large Spatial Data Sets
Application 3: Handling Large Spatial Data Sets
Example application: image-based rendering Suppose you have many digital images of a scene, with depth
information for pixels How to find efficiently the points that are in front?
Other applications: Speeding up ray-tracing with many objects Rendering contours of 3D
volumetric data such as MRI scans
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
QuadtreeQuadtree
Quadtree: divide space into four quadrants. Mark as Empty, Full, or Partially full.
Recursively subdivide partially full regions Saves much time, space over 2D pixel data!
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Quadtree StructureQuadtree Structure
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
OctreesOctrees
Generalize to cutting up a cube into 8 sub-cubes, each of which may be E, F, or P (and subdivided)
Much more efficientthan a 3D array ofcells for 3Dvolumetric data
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Quadtree AlgorithmsQuadtree Algorithms
How would you render a quadtree shape? find the intersection of a ray with a quadtree shape? Take the union of two quadtrees? Intersection? Find the neighbors of a cell?
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Applications of OctreesApplications of Octrees
Contour finding in MRI data 3D scanning and rendering Efficient ray tracing Intersection, collision testing
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Research in VisibilityResearch in Visibility
Can we figure out in advance what will be visible from each viewpoint?
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Viewer-centered representationViewer-centered representation
Viewer-centered object representations: representation not of volume of space filled but appearance from all viewpoints
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Occlusion in view spaceOcclusion in view space
Occlusion in view space is subtraction
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
EventsEvents
Events: boundaries in viewpoint space where faces appear or disappear
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Aspect GraphAspect Graph
Aspect graph: a graph with a node for every topologically distinct view of an object, with edges connecting adjacent views
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Aspect graph varietiesAspect graph varieties
Aspect graphs can be constructed for 3D: space 2D: multiple axis rotations or planar motions 1D: single-axis rotations
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
1D Aspect Graph for Rotation1D Aspect Graph for Rotation
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
1D Aspect Graph Results1D Aspect Graph Results
Useful for rotations without Z-buffer hardware! Not so useful for more viewer freedom, modern graphics
hardware
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Conservative Visibility PreprocessingConservative Visibility Preprocessing
Q. can we take advantage of z-buffer? Definition: weak visibility. A polygon is weakly visible from a
region if any part of the polygon is visible from any viewpoint in the region
Conservative visibility preprocessing: computing in advance a (super-)set of the polygons that are weakly visible from some region
Rendering with Z-buffer yields correct image, but it’s faster since fewer polygons are drawn
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Weak Visibility SubdivisionWeak Visibility Subdivision
Given an object and a wall, find the region of space from which the wall occludes the object
Divide space into regions, where each edge represents some object appearing or disappearing
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Conservative Visibility Preprocessing on a Grid
Conservative Visibility Preprocessing on a Grid
Divide viewing space into a 3D (or 2D) grid
Compute a conservative display list for each cell
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
Conservative visibility algorithmConservative visibility algorithm
Initialize a display list for each grid cell Algorithm: for each object, wall, and cell
If the object is not weakly visible from the cell, remove from cell’s display list
You can churn away at this computation as long as you like, increasing runtimes, but you can stop at any time with usable results. (Results improve over time!)
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
PerspectivePerspective
What good did this visibility research do for the world? It wasn’t enough for me
I left graphics research and went into digital libraries Left University of Pittsburgh and went to Wheaton College
Computing & Information SciencesKansas State University
Lecture 35 of 42CIS 636/736: (Introduction to) Computer Graphics
SummarySummary
3D modeling uses advanced primitives and ways of cutting, joining them
Inverse kinematics determines joint position from end effector motions
Keyframe animation involves important poses and inbetweening 3D morphing animates surface control points 3D spatial subdivision trees include CSG-trees, BSP-trees,
Quadtrees, and Octrees Visibility preprocessing speeds walkthrough