We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byKaley Kinsey
Modified about 1 year ago
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology
Tomas Akenine-Mőller © 2003 What for? A tool needed for the graphics people all the time… Very important components: – Need to make them fast! Finding if (and where) a ray hits an object – Picking – Ray tracing and global illumination For speed-up techniques Collision detection (treated in a later lecture)
Tomas Akenine-Mőller © 2003 Some basic geometrical primitives Ray: Sphere: Box – Axis-aligned (AABB) – Oriented (OBB) k-DOP
Tomas Akenine-Mőller © 2003 Four different techniques Analytical Geometrical Separating axis theorem (SAT) Dynamic tests Given these, one can derive many tests quite easily – However, often tricks are needed to make them fast
Tomas Akenine-Mőller © 2003 Analytical: Ray/sphere test Sphere center: c, and radius r Ray: r(t)=o+td Sphere formula: ||p-c||=r Replace p by r(t), and square it: o d c r
Tomas Akenine-Mőller © 2003 Analytical, continued Be a little smart… c o d Such tests are called ”rejection tests” Other shapes:
Tomas Akenine-Mőller © 2003 Geometrical: Ray/Box Intersection Boxes and spheres often used as bounding volumes A slab is the volume between two parallell planes: A box is the logical intersection of three slabs (2 in 2D): BOX
Tomas Akenine-Mőller © 2003 Geometrical: Ray/Box Intersection (2) Intersect the 2 planes of each slab with the ray Keep max of t min and min of t max If t min < t max then we got an intersection Special case when ray parallell to slab
Tomas Akenine-Mőller © 2003 Separating Axis Theorem (SAT) Page 563 in book Two convex polyhedrons, A and B, are disjoint if any of the following axes separate the objects: – An axis orthogonal to a face of A – An axis orthogonal to a face of B – An axis formed from the cross product of one edge from each of A and B A and B overlaps on this axis axis
Tomas Akenine-Mőller © 2003 SAT example: Triangle/Box Box is axis-aligned 1) test the axes that are orthogonal to the faces of the box That is, x,y, and z
Tomas Akenine-Mőller © 2003 Triangle/Box with SAT (2) Assume that they overlapped on x,y,z Must continue testing 2) Axis orthogonal to face of triangle Triangle seen from side axis
Tomas Akenine-Mőller © 2003 Triangle/Box with SAT (3) If still no separating axis has been found… 3) Test axis: t=e box x e triangle Example: – x-axis from box: e box =(1,0,0) – e triangle = v 1 -v 0 Test all such combinations If there is at least one separating axis, then the objects do not collide Else they do overlap
Tomas Akenine-Mőller © 2003 Rules of Thumb for Intersection Testing Acceptance and rejection test – Try them early on to make a fast exit Postpone expensive calculations if possible Use dimension reduction – E.g. 3 one-dimensional tests instead of one complex 3D test, or 2D instead of 3D Share computations between objects if possible Timing!!!
Tomas Akenine-Mőller © 2003 Another analytical example: Ray/Triangle in detail Ray: r(t)=o+td Triangle vertices: v 0, v 1, v 2 A point in the triangle: t(u,v)=v 0 +u(v 1 - v 0 ) +v(v 2 - v 0 )= =(1-u-v)v 0 +uv 1 +vv 2 [u,v>=0, u+v<=1] Set t(u,v)=r(t), and solve! v2v2 v1v1 v0v0 v 1 -v 0 v 2 -v 0
Tomas Akenine-Mőller © 2003 Ray/Triangle (2) Solve with Cramer’s rule: Share factors to speed up computations
Tomas Akenine-Mőller © 2003 Ray/Triangle (3) Implementation Be smart! – Compute as little as possible then test Examples: Compute Then test valid bounds if (v 1) exit;
Tomas Akenine-Mőller © 2003 Point/Plane Insert a point x into plane equation: origin Positive half space Negative half space
Tomas Akenine-Mőller © 2003 Sphere/Plane AABB/Plane Sphere: compute f (c) is the signed distance ( n normalized) Box: insert all 8 corners If all f ’s have the same sign, then all points are on the same side, and no collision abs( f (c)) > r no collision abs( f (c)) = r sphere touches the plane abs( f (c)) < r sphere intersects plane
Tomas Akenine-Mőller © 2003 AABB/plane The smart way (shown in 2D) Find diagonal that is most closely aligned with plane normal More details in book Need only test the red points
Tomas Akenine-Mőller © 2003 Ray/Polygon: very briefly Intersect ray with polygon plane Project from 3D to 2D How? Find max(|n x |,|n y |,|n z |) Skip that coordinate! Then, count crossing in 2D
Tomas Akenine-Mőller © 2003 Volume/Volume tests Used in collision detection Sphere/sphere – Compute squared distance between sphere centers, and compare to (r 1 +r 2 ) 2 Axis-Aligned Bounding Box/AABB – Test in 1D for x,y, and z Oriented Bounding boxes Use SAT [details in book]
Tomas Akenine-Mőller © 2003 View frustum testing View frustum is 6 planes: Near, far, right, left, top, bottom Create planes from projection matrix – Let all positive half spaces be outside frustum – Not dealt with here -- p Sphere/frustum common approach: – Test sphere against 6 frustum planes – If in positive half space and r distances from plane => no intersection – If intersecting plane or in negative half space, continue – If not outside after all six planes, then inside or intersecting Example follows…
Tomas Akenine-Mőller © 2003 View frustum testing example Not exact test, but not incorrect – A sphere that is reported to be inside, can be outside – Not vice versa Similarly for boxes outside frustum intersecting frustum
Tomas Akenine-Mőller © 2003 Dynamic Intersection Testing [In book: ] Testing is often done every rendered frame, i.e., at discrete time intervals Therefore, you can get ”quantum effects” Frame n Frame n+1 Dynamic testing deals with this Is more expensive Deals with a time interval: time between two frames
Tomas Akenine-Mőller © 2003 Dynamic intersection testing Sphere/Plane No collision occur: – If they are on the same side of the plane ( s c s e >0 ) – Plus | s c | >r and | s e | >r Otherwise, sphere can move |s c |-r Time of collision: e r scsc sese s c & s e are signed distances t=nt=n t=n+1 Response: reflect v around n, and move (1-t cd )r r v c n
Tomas Akenine-Mőller © 2003 Dynamic Separating Axis Theorem SAT: tests one axis at a time for overlap Same with DSAT, but: – Need to adjust the projection on the axis so that the interval moves on the axis as well Need to test same axes as with SAT Same criteria for overlap/disjoint: – If no overlap on axis => disjoint – If overlap on all axes => objects overlap
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,
Week 13 - Wednesday. What did we talk about last time? Intersection testing Bounding volumes Sphere AABB OBB k-DOP SharpDX tools.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Collision Detection CSCE /60 What is Collision Detection? Given two geometric objects, determine if they overlap. Typically, at least one of.
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Advanced Computer Graphics Spring 2009 K. H. Ko Department of Mechatronics Gwangju Institute of Science and Technology.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
Week 14 - Monday. What did we talk about last time? Bounding volume/bounding volume intersections.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Computer graphics & visualization Collision Detection – Narrow Phase.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Vectors, Dot Product, Cross Product, Basic Collision Detection George Georgiev Telerik Corporation
Computer Graphics - Rasterization - Hanyang University Jong-Il Park.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
By: Andrew Shatz & Michael Baker Chapter 15. Chapter 15 section 1 Key Terms: Skew Lines, Oblique Two lines are skew iff they are not parallel and do not.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
Computer Graphics I, Fall 2010 Implementation II.
Collision handling: detection and response CSE 3541 Matt Boggus.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Implementation II. 2 Objectives Introduce clipping algorithms for polygons Survey hidden-surface algorithms.
2.4. P RIMITIVE T ESTS - C LOSEST POINT Closest point forms of intersection detection.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
CONFIDENTIAL 1 Geometry Formulas in Three Dimensions.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45 250 Viewport in Device coords 250 x 250 Pixels.
Everything you ever wanted to know about collision detection (and as much about collision response as I can figure out by Wednesday) By Ryan Schmidt,
Collision/Acceleration University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
Chapter 15: Geometric Solids Brian BarrDan Logan.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Christian Lauterbach COMP 770, 2/16/2009. Overview Acceleration structures Spatial hierarchies Object hierarchies Interactive Ray Tracing techniques.
© 2017 SlidePlayer.com Inc. All rights reserved.