Week 15 - Friday CS361.

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Extended Gaussian Images
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Collision Detection David Johnson Cs6360 – Virtual Reality.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
Week 14 - Wednesday.  What did we talk about last time?  Collision handling  Collision detection  Collision determination  Collision response  BSPs.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Week 13 - Wednesday CS361.
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Week 15 - Friday CS361.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Non-Photorealistic Rendering: Toon Shading David Luebke University of Virginia.
Realtime NPR Toon and Pencil Shading Joel Jorgensen May 4, 2010.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Implementation II.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Computer Graphics I, Fall 2010 Implementation II.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
1 Geometry for Game. Geometry Geometry –Position / vertex normals / vertex colors / texture coordinates Topology Topology –Primitive »Lines / triangles.
Week 13 - Wednesday CS361.

Rendering Pipeline Fall, 2015.
Computer Graphics Implementation II
Bounding Volume Hierarchies and Spatial Partitioning
Week 14 - Wednesday CS361.
Week 12 - Thursday CS361.
Week 7 - Monday CS361.
Week 2 - Friday CS361.
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
In this section, we will learn about: Using integration to find out
3D Graphics Rendering PPT By Ricardo Veguilla.
Parts of these slides are based on
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
CSCE 441: Computer Graphics Hidden Surface Removal
Collision handling: detection and response
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
2.5. Basic Primitive Intersection
Lecture 13 Clipping & Scan Conversion
Three-Dimensional Object Representation
CS679 - Fall Copyright Univ. of Wisconsin
Computer Animation Algorithms and Techniques
Introduction to Computer Graphics with WebGL
Collision Detection.
CO Games Concepts Week 12 Collision Detection
David Johnson Cs6360 – Virtual Reality
Implementation II Ed Angel Professor Emeritus of Computer Science
GPAT – Chapter 7 Physics.
Presentation transcript:

Week 15 - Friday CS361

Last time What did we talk about last time? Review up to Exam 2

Questions?

Project 4

Review

Polygonal Techniques

Tessellation Surfaces often need to be tessellated, broken down into polygons The surfaces can be Convex polygons More complicated polygons 3D surfaces made out of complicated polygons

Triangulation For most graphics hardware, polygons must be triangulated into component triangles "Bowties" have to be converted into triangles, perhaps making a guess about what the modeler meant The literature contains many triangulation algorithms including the O(n2) ear clipping algorithm

Edge cracking and T-vertices Splines are often used to generate curved surfaces Turning the splines into polygons can cause two surfaces to have cracks between them, called edge cracking Edge stitching makes sure all vertices on a shared edge between surfaces are shared as well Shading is also an issue for T-vertices Triangles that share edges should share all the same vertices too

Triangle fans, strips, and meshes In order to reuse data, we can break groups of triangles into fans, strips, and meshes A triangle fan has a center vertex shared by all triangles A triangle strip is similar to a triangle fan except that the triangles do not all share a common vertex For a closed surface, a triangle mesh can be more efficient than either fans or strips

Vertex buffers Meshes are generally sent as a vertex buffer and an index buffer They are a generic way to store model data in a contiguous chunk of memory The memory could be: A list of points A list of line segments A polyline A triangle list A triangle fan A triangle strip The size of a vertex is called the stride If you do not want to repeat information in the vertex buffer, you can use an index buffer to specify which vertices from the vertex buffer to use

Simplification Mesh simplification is a way of reducing polygon count while preserving appearance Three common kinds: Static – make several models of different complexity and choose the right one Dynamic – generate models on the fly, allowing for a continuous spectrum of level of detail (LOD) View-dependent – change based on the particular view

Dynamic simplification Use edge collapses Merge two vertices into one There are different strategies for determining which edge to collapse, but we usually look for a "low cost" edge There are different strategies for determining cost… Some edges should not be collapsed If it causes a surface's normal to flip If it causes edges to cross

Intersection Test Methods

Ray A ray r(t) is defined by an origin point o and a direction vector d d is usually normalized Negative t values are behind the starting point of the ray and don't count Since d is normalized, positive t values give the distance of the point from o It is also common to store l, the maximum distance along the ray we want to look

Surface An implicit surface is one described by a vector equation where any point on the surface has a value of 0 f(p) = f(px, py, pz) = 0 Implicit sphere: f(p) = px2 + py2 + pz2 - r2 = 0 An explicit surface is one parameterized by two parameters Explicit sphere:

Axis-aligned bounding box An axis-aligned bounding box (AABB) (also known as a rectangular box) is a box whose faces have normals pointing the same way as the x, y, and z axes It's just a non-rotated box in 3 space It can be defined with two points (lower corner and upper corner)

Oriented bounding box An oriented bounding box (OBB) is an AABB that has been arbitrarily rotated It can be described by A center point bc Three normalized vectors bu, bv, and bw giving the side directions of the box And half-lengths (from center to wall) huB, hvB, and hwB

k-DOP A k discrete oriented polytope (k-DOP) has k/2 normalized normals ni For each ni, there are two values dimin and dimax which defines a slab Si that is the volume between the two planes The k-DOP is the intersections of all the slabs

Separating axis test For two arbitary, convex, disjoint polyhedra A and B, there exists a separating axis where the projections of the polyhedra are also disjoint Furthermore, there is an axis that is orthogonal to (making the separating plane parallel to) A face of A or A face of B or An edge from each polyhedron (take the cross product) This definition of polyhedra is general enough to include triangles and line segments

Creating Bounding Volumes

AABB and k-DOPs An AABB is the easiest A k-DOP is not much harder Take the minimum and maximum points in each axis and, BOOM, you've got an AABB A k-DOP is not much harder Take the minimum and maximum values in each of the k/2 axes and use those to define the slabs You have to have axes in mind ahead of time

Bounding spheres Not as simple as you might think One approach: Or: Make an AABB and use the center and diagonal of the corners to make your sphere Or: Make the AABB and do another pass through the vertices, taking the one furthest from the center as the radius There are other more complicated ideas

Geometric probability The relative probability that a random point is inside an object is proportional to the object's volume However, the relative probability that a random ray intersects an object is proportional to its surface area

Intersection Methods

Ray/sphere intersection We can write the implicit sphere equation as f(p) = ||p – c|| – r = 0 p is any point on the surface c is the center r is the radius By substituting in r(t) for p, we can eventually get the equation t2 + 2tb + c = 0, where b = d • (o – c) and c = (o – c) •(o – c) – r2 If the discriminant is negative, the ray does not hit the sphere, otherwise, we can compute the location(s) where it does

Optimized ray/sphere Looking at it geometrically, we can optimize the test Find the vector from the ray origin to the center of the sphere l = c – 0 Find the squared length l2 = l • l If l2 < r2, then o is in the sphere, intersect! If not, project l onto d: s = l • d If s < 0, then the ray points away from the sphere, reject Otherwise, use the Pythagorean theorem to find the squared distance from the sphere center to the projection: m2 = l2 – s2 If m2 > r2, the ray will miss, otherwise it hits

Slabs method for ray/box First find the t value where the ray intersects each plane The box is made up of 3 slabs Find the min t and max t for each slab The final tmin is the max of all the tmin values The final tmax is the min of all the tmax values If tmin ≤ tmax, the ray intersects the box, otherwise it does not The idea can be extended to frustums and k-DOPs

Line segment/box overlap test This method uses the separating axis test and only works for AABBs and line segments The AABB has its center at (0,0,0) and size half vector h The line segment is defined by center c and half vector w If |ci| > wi + hi for any i x,y,z then disjoint There is another test for each axis that is the cross product of the x, y, and z axis and w If any test passes, then disjoint Only if all tests fail, then overlap

Triangle representation One way to represent a triangle is with barycentric coordinates For triangles, barycentric coordinates are weights that describe where in the triangle you are, relative to the three vertices These weights are commonly labeled u, v, and w and have the following properties u ≥ 0, v ≥ 0, w ≥ 0 and u + v + w ≤ 1

Ray triangle intersection We represent a point f(u,v) on a triangle with the following explicit formula f(u,v) = (1 – u – v)p0 + up1 + vp2 Then, setting the ray equal to this equation gives o + td = (1 – u – v)p0 + up1 + vp2 This is simply a vector representation of three equations with three unknowns If the solution has a positive t, and u and v between 0 and 1, it's an intersection

Plane/box intersection Simplest idea: Plug all the vertices of the box into the plane equation n • x + d = 0 If you get positive and negative values, then the box is above and below the plane, intersection! There are more efficient ways that can be done by projecting the box onto the plane

Sphere/sphere intersection Sphere/sphere is the easiest Is the distance between their centers bigger than the sum of their radii? If yes, they are disjoint If no, they overlap r2 r1 c2 c1

AABB/AABB intersection We test each dimension to see if the min of one box is greater than the max of other or vice versa If that's ever true, they're disjoint If it's never true, they overlap intersect(A, B ) { for i in x,y,z if(aimin > bimax or bimin > aimax ) return DISJOINT return OVERLAP }

Line/line intersection We will only look at the 2D problem, but the book has discussion of 3D lines as well For a 2D vector (x, y), we define its perp dot product (x, y) = (-y, x) Thus, we can work through the equations of a line (only the path to the value of s is shown) r1(s) = r2(t) o1 + sd1 = o2 + td2 sd1 • d2 = (o2 – o1) • d2 s = ((o2 – o1) • d2) / d1 • d2

Collision Detection

Collision detection There are three important pieces to collision handling: Collision detection Did these objects collide? Collision determination When and where did these objects collide exactly? Collision response What happens as a result of the collision?

Collision detection with rays Rather than try to test complex models for collision with an environment, we can use representative rays instead Perhaps one ray for each wheel of a car A positive ray distance means space between the objects A negative ray distance means collision A zero ray distance means the objects are merely touching It's essentially a ray tracing problem

BSP trees Binary space partitioning trees (BSP trees) are a common way of dividing space hierarchically For axis-aligned BSPs, one axis is chosen and a perpendicular plane is generated to divide the box This process is repeatedly recursively until some criteria (like 3 or fewer objects per division) is reached BSPs can also be split by choosing polygons to divide the world (usually done so to make a perfectly balanced tree) BSPs are good for static scenes (moving objects can cause huge portions of the tree to be recreated)

Multiple objects CD Hierarchies are generally made for static scenes Then we test against them for collisions with dynamic objects What about when there are multiple moving objects that might interact with each other? We work in two phases Broad phase collision detection Exact collision detection among candidates

Sweep-and-prune Assume everything has an AABB or a bounding sphere Assume temporal coherence (stuff doesn't move that much over a small amount of time) On one dimension, we can sort the endpoints of the AABBs We can quickly throw out objects that cannot possibly intersect Bubble sort to the rescue! We could sort everything in O(n log n) every time Because of temporal coherence, not many end points change order and adaptive sorts work in around O(n)

Grids Another possibility is keeping large grid cells that keep track of which objects or BVs are inside them Objects that do not share grid cells do not need to be checked for collision Finding the right grid cell size can be difficult Spatial hashing can be used as well (mapping to a hash table based on location)

Putting it together Here is an outline of a frame in a typical two-phase CD system

Non-photorealistic rendering Most of the work we've focused on all semester is doing rendering that in some way mirrors the natural world However, a wide area of rendering is non-photorealistic rendering (NPR) Goals: Simplified technical drawings Simulating artistic styles

Toon shading The most common form of NPR in video games is toon shading Also called cel shading The goal is to render 3D models as if they were cartoons Shading is often done with either a single color or a two tone (color and shading) approach Then a thick black silhouette is added around edges

Coloring The color is often determined by the dot product n · l (surface normal dot light vector) If negative, the surface should be darkened Otherwise, it's some flat color Or a threshold other than 0 can be used A more complex system uses a one dimensional texture indexed into with the dot product Highlight Normal Shadow

Silhouette edge rendering The more complicated problem is properly rendering edges with a thick dark line A number of different edges are of interest Boundary or border edges are edges where one polygon is not adjacent to any other Not found in 3D solid objects A crease, hard, or feature edge is an edge between two polygons that is sharper than some threshold angle A material edge is an edge between two polygons with different materials A silhouette edge is when two neighboring polygons face different directions, relative to the eye

Procedural geometry silhouetting Cel shading focuses on rendering silhouette edges Many of these techniques rely on manipulating back facing polygons The crossover between front facing and back facing polygons is the silhouette It's easy to determine which is which After some manipulation of the backfaces, they are rendered in black

z-biased backfaces If the backfaces are rendered in black without any change, they will be hidden Before rendering, all backfaces can be translated to be closer to the viewer Translation can be by A fixed amount An amount that takes into account non-linear z-depths An amount based on the angle of the polygon normal None of these techniques give uniform thickness lines

Triangle fattening Another approach is to fatten each backface triangle The slope of the triangle and the distance from the viewer determine the expansion of each edge It doesn't work well for thin traingles

Expanding shell technique A similar approach is to expand backface vertices along their normals The expansion amount is proportional to their z-distance This technique fails for situations like a cube, in which faces with very different normals share vertices

Silhouetting by image processing Rather than using geometry, there is an image processing approach Render all the normal values or depth values to a buffer and use edge detection algorithms to draw lines where the values change abruptly Using normal values can find crease edges This technique works for many cases that failed before Even GPU generated surfaces are not a problem

Other styles NPR techniques are very broad Many approaches try to recreate hand-drawn or hand-painted styles Silhouette lines can be drawn as paintbrush strokes of varying thickness Tonal art maps (TAMs) use palettes of hand-drawn textures to do black and white crosshatch-style shading

Line rendering For CAD programs and other 3D tools, we may want to highlight certain lines or all polygon edges Rendering polygon edges on top of existing polygons can be a pain Z-buffer algorithms might hide the lines In practice, a small bias is usually added to the polygons

Hidden lines For drawing simplified models, we may want to include or exclude the hidden lines Wireframe is the easiest, since it is just the lines Hidden-line uses the z-buffer directly Obscured-line renders twice, rendering z-fail lines in a lighter color Haloed lines also use the z-buffer, drawing thick white lines first and then black lines on top Problems happen when lines get too close

Upcoming

Next time… There is no next time!

Reminders Finish Project 4 Study for the final Due tonight by 11:59pm 11:00am - 2:00pm, Monday, 5/08/2017