Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.

Similar presentations


Presentation on theme: "Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology."— Presentation transcript:

1 Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

2 2 Triangle/Triangle Intersection (ERIT’s Method)  Compute п 2 :n 2  x + d 2, the plane in which T 2 lies.  Trivially reject if all points of T 1 are on the same side of п 2.  If the triangles are coplanar, use the coplanar triangle- triangle test used in the interval overlap method.  Compute the intersection between п 2 and T 1, which clearly is a line segment that is coplanar with п 2.  If this line segment intersects or is totally contained in T 2, then T 1 and T 2 intersect; otherwise, they do not.

3 3 Triangle/Triangle Intersection (ERIT’s Method) Steps 1 and 2 are the same as for the interval overlap method. Step 4 requires computation of two points, p and q, in п 2 representing the line of intersection.  We have the signed distances from the points of T 1 and п 2 from step 2, p and q can be computed by First finding points of T 1 that lie on different sides of п 2. When such a pair, say with index i 1 and i 2, has been found, the intersection point p is

4 4 Triangle/Triangle Intersection (ERIT’s Method) Step 4 requires computation of two points, p and q, in п 2 representing the line of intersection.  The point q is computed similarly, with another pair of indices found in the same manner. Step 5 is accomplished by  First projecting T 2, p and q onto the coordinate plane (x=0, y=0, z=0) where the area of T 2 is maximized.  Both points of the projected line must be tested against each half-plane formed by each triangle edge of T 2.  The line formed by the edge of the triangle divides the plane into two sides.

5 5 Triangle/Triangle Intersection (ERIT’s Method)  If both points are outside any triangle edge of T 2, the triangles do not intersect.  If either endpoint is inside all three triangle edges of T 2, the triangles must intersect.  It is possible that neither endpoint is inside T 2, nor both fully outside any half plane. For this case, each edge of T 2 must be tested for intersection with the line segment pq.  Finding an intersection at any time implies that the triangles intersect.  Otherwise the triangles are disjoint.

6 6 Triangle/Box Overlap An algorithm for determining whether a triangle intersects an axis-aligned box.  Can be used to build voxel-spaces, test triangles against boxes in collision detection, and test polygons against canonical view volumes, etc. Consider an axis-aligned bounding box (AABB), defined by a center c, and a vector of half lengths, h, and a triangle Δu 0 u 1 u 2.

7 7 Triangle/Box Overlap To simplify the tests, we first move the box and the triangle.  The box is centered around the origin, i.e. v i = u i – c, i ∈ {0,1,2}.

8 8 Triangle/Box Overlap To test against an oriented box, we would first rotate the triangle vertices by the inverse box transform, then use the test. Based on the separating axis theorem, we test the following 13 axes:  [3 tests] e 0 =(1,0,0), e 1 =(0,1,0), e 2 =(0,0,1). Namely, test the AABB against the minimal AABB around the triangle.  [1 test] n, the normal of Δu 0 u 1 u 2. We use a plane/AABB overlap test.  [9 tests] a ij =e i ⅹ f i, i,j ∈ {0,1,2}, where f 0 = v 1 – v 0, f 1 = v 2 - v 1, and f 2 = v 0 –v 2, the edge vectors.

9 9 Triangle/Box Overlap Derivation of one of the nine tests in Step 3.  When i = 0 and j = 0 -> a 00 = e 0 ⅹ f 0 = (0,-f 0z,f 0y )  We project the triangle vertices onto a 00. p 0 = a 00 ᆞ v 0 = v 0z v 1y – v 0y v 1z. p 1 = a 00 ᆞ v 1 = v 0z v 1y – v 0y v 1z = p 0. p 2 = a 00 ᆞ v 2 = (v 1y -v 0y )v 2z – (v 1z -v 0z )v 2y.  Find min(p 0,p 2 ) (=min(p 0,p 1,p 2 )) and max(p 0,p 2 ) (=max(p 0,p 1,p 2 ))  After the projection of the triangle onto a, we need to project the box onto a as well. We compute a “radius”, called r, of the box projected on a as

10 10 Triangle/Box Overlap Derivation of one of the nine tests in Step 3. We compute a “radius”, called r, of the box projected on a as  r = h x |a x | + h y |a y | + h z |a z | = h y |a y | + h z |a z |  a x = 0 for this particular axis. Therefore, this axis test becomes  if (min(p 0,p 2 ) > r or max(p 0,p 2 ) < -r) return false.

11 11 Triangle/Box Overlap As soon as a separating axis is found, the algorithm terminates and returns “no overlap”. If all tests pass, i.e. there is no separating axis, then the triangle overlaps the box.

12 12 BV/BV Intersection Tests A closed volume that totally contains a set of objects is called a bounding volume (BV) for the set.  The purpose of a BV is to provide simpler intersection tests and make more efficient rejections. Bounding volumes that are commonly used  Sphere, AABB, k-DOP and OBB. A fundamental operation is to test whether or not two bounding volumes overlap. More complex BVs could have a tighter fit.

13 13 Sphere/Sphere Intersection For spheres, the intersection test is simple and quick.  Compute the distance between the two spheres’ centers and then reject if this distance is greater than the sum of the two spheres’ radii.  Otherwise, they intersect.  In implementation of this algorithm, the squared distances of the various quantities are used.

14 14 Sphere/Box Intersection A sphere and an AABB  Find the point on the AABB that is closest to the sphere’s center, c.  One dimensional tests are used. One for each of the three axes of the AABB. The sphere’s center coordinate for an axis is tested against the bounds of the AABB. If it is outside the bounds, the distance between the sphere center and the box along this axis is computed and squared. After we have done this along the three axes, the sum of these squared distances is compared to the squared radius, r 2, of the sphere. If the sum is less than the squared radius, the closest point is inside the sphere and the box overlaps.

15 15 Sphere/Box Intersection A sphere and an AABB  For sphere/OBB intersection, first transform the sphere’s center into the OBB’s space.  Now this center point is expressed in terms of the OBB’s axes. So the OBB can be treated as an AABB.

16 16 BV/BV Intersection AABB/AABB Intersection  The test for intersection between two AABBs is trivial.

17 17 BV/BV Intersection k-DOP/k-DOP Intersection  If two k-DOPs, A and B, are to be tested for intersection, then test all pairs of slabs (S A i,S B i ) for overlap. s i = S A i ∩S B i is a one-dimensional interval overlap test. If at any time s i = Φ (the empty set), then the BVs are disjoint and the test is terminated. Otherwise, the slab overlap tests continues. If and only if all s i ≠ Φ, 1≤ i ≤ k/2, then the BVs are considered to be overlapping.

18 18 BV/BV Intersection OBB/OBB Intersection  Use the separating axis theorem.  Given two OBBs, A and B, the test is done in the coordinate system formed by A’s center and axes. This means that the origin is a c = (0,0,0) and that the main axes in this coordinate system are a u =(1,0,0), a v =(0,1,0) and a w =(0,0,1).  B is assumed to be located relative to A, with a translation t and a rotation (matrix) R.  The separating axis theorem says that it is sufficient to find one axis that separates A and B to be sure that they are disjoint (do not overlap).

19 19 BV/BV Intersection OBB/OBB Intersection  Fifteen axes have to be tested. Three from the faces of A Three from the faces of B 9 from combinations of edges from A and B

20 20 BV/BV Intersection OBB/OBB Intersection

21 21 BV/BV Intersection OBB/OBB Intersection  A potential separating axis is denoted as l and adopt the notation from the figure.  The “radii,” d A and d B, of the OBBs on the axis, l, are obtained by simple projections.  If and only if, l is a separating axis, then the intervals on the axis should be disjoint. That is the condition should hold

22 22 BV/BV Intersection OBB/OBB Intersection  If any of these 15 tests is positive, the OBBs are disjoint (A ∩ B = Φ)  Testing the axes in different orders has an impact on performance.

23 23 View Frustum Intersection One of the few operations called during bounding-volume-hierarchy (scene-graph) cull traversal is the intersection test between the view frustum and a bounding volume.  These operations are thus critical to fast execution.  They should determine whether the BV is totally inside (inclusion), totally outside (exclusion), or whether it intersects the frustum.

24 24 View Frustum Intersection

25 25 View Frustum Intersection We need the three returns outside / inside / intersect.  If a BV is found to be totally outside the view frustum, then that BV’s subtree will not be traversed further and none of its geometry will be rendered.  If the BV is totally inside, then no more frustum/BV tests need to be computed for that subtree and every renderable leaf will be drawn.  For a partially visible BV, the BV’s subtree is tested recursively against the frustum. The complete test is called an exclusion / inclusion / intersection test.  The intersection could be too costly to compute. -> the BV is classified as “probably-inside”.

26 26 View Frustum Intersection The complete test is called an exclusion / inclusion / intersection test.  If a BV cannot be excluded successfully, there are two choices. Treat the probably inside state as an inclusion. -> everything inside the BV is rendered. Test each node in the subtree in turn for exclusion.  Neither choice is particularly good, some attempt at quickly differentiating between intersection and inclusion is often worthwhile, even if the test is imperfect.

27 27 View Frustum Intersection The quick classification tests do not have to be perfect for scene-graph culling.  For differentiating exclusion from inclusion, all that is required is that the test err on the side of inclusion. Objects which should actually be excluded can erroneously be included. -> cost extra time Object that should be included should never be quickly classified as excluded by the tests. -> rendering errors will occur.

28 28 View Frustum Intersection An intersection test method between a frustum and a general object. The idea is to transform the test from a BV/frustum test to a point/volume test.

29 29 View Frustum Intersection The creation of the new volumes is independent of the position of the actual BV.  It is dependent solely on the position of the point relative to the BV.  A BV with an arbitrary position can be tested against the same volumes.

30 30 View Frustum Intersection (Frustum/Sphere Intersection) A frustum for an orthographic view is a box, so the overlap test in this case becomes a sphere/OBB intersection and can be solved using the algorithm (Sphere/box intersection algorithm). To further test whether the sphere is entirely inside the box, we treat the box as hollow when we are finding the closest point.

31 31 View Frustum Intersection (Frustum/Sphere Intersection) We select the origin of the sphere as the point p to trace. If the sphere, with radius r, is moved along the inside and along the outside of the frustum and as close to the frustum as possible, then the trace of p gives us the volumes that are needed to reformulate the frustum / sphere test. The actual volumes are shown in the middle figure.

32 32 View Frustum Intersection (Frustum/Sphere Intersection) Using the volume, the exact test can be done.  If p is outside the dark gray volume, then the sphere is outside the frustum.  If p is inside the dark gray area, then the sphere is inside the frustum. For the sake of efficiency, we use the approximation that appears on the right side of the figure.  The dark gray volume has been extended so as to avoid the more complicated computations that the rounded corners would require.

33 33 View Frustum Intersection (Frustum/Sphere Intersection) The outer volume consists of the planes of the frustum moved r distance units outwards in the direction of the frustum plane normal, and that the inner volume can be created by moving the planes of the frustum r distance units inwards in the direction of the frustum plane normals.  Assume that the plane equations of the frustum are such that the positive half-space is located outside of the frustum.  An actual implementation would loop over the six planes of the frustum and for each frustum plane, compute the signed distance from the sphere’s center to the plane.

34 34 View Frustum Intersection (Frustum/Sphere Intersection) To reduce the number of planes that must be tested for a symmetric frustum, an octant test can be added to the view frustum test.  The frustum is divided into eight octants, much as an octree is subdivided.

35 35 View Frustum Intersection (Frustum/Sphere Intersection)  We only need to test against the three outer planes of the octant that the sphere center is in.  This test can be used to speed up the frustum tests for AABBs and OBBs.

36 36 View Frustum Intersection (Frustum/Cylinder Intersection) The cylinder is treated as a line segment and the frustum is increased in size by the sphere’s radius. Instead of increasing the frustum by a uniform radius in all directions, the axis of the cylinder is used to determine how the radius affects each frustum plane.  The absolute value of the dot product of the cylinder’s axis direction and the frustum plane’s normal is multiplied by the cylinder radius. This result is how much the frustum plane is moved outward. Given the expanded frustum and the line segment representing the cylinder, it is simply a matter of intersecting the line segment with the frustum to determine whether the cylinder overlaps the frustum.

37 37 View Frustum Intersection (Frustum/Box Intersection) If the view’s projection is orthographic, testing can be done using OBB/OBB intersection testing. For general frustum/box intersection testing  The test is similar to the frustum/sphere test in that the OBB or AABB bounding box is checked against the six view frustum planes.  If all corner points of the bounding box are outside of one such plane, then the bounding box is guaranteed to be outside the frustum.  We can test two bounding box corners against a particular plane to find out on which side of the plane the box is, or whether it is intersecting the plane.

38 38 View Frustum Intersection (Frustum/Box Intersection) The algorithm tests the box against each of the six frustum planes in turn.  If the box is outside one such plane, the box is outside the frustum and the test is terminated.  If the box is inside all six planes then the box is inside the frustum.  Else it is considered as intersecting the frustum. Since the plane/box test is more expensive than the plane/sphere test, there is often a gain in using the octant test.  This test would immediately discard three of the six frustum planes.

39 39 View Frustum Intersection (Frustum Plane Extraction) In order to do view frustum culling, the plane equations for the six different sides of the frustum are needed. Assume that the view matrix is V and that the projection matrix is P. The composite transform is then M = PV. A point s (s w =1) is transformed into t as t=Ms.  t may have t w ≠ 1 due to perspective projection.  All components in t are divided by t w in order to obtain a point u with u w = 1.

40 40 View Frustum Intersection (Frustum Plane Extraction) For points inside the view frustum, it holds that -1≤u i ≤1 for i ∈ x,y,z, i.e. the point u is inside a unit cube. For the right side of the left plane of the unit- cube, for which -1 ≤ u x.  -1 ≤ u x -1 ≤ t x /t w t x + t w ≥ 0 (m 0, ᆞ s) + (m 3 ᆞ s) ≥ 0 (m 0, + m 3,) ᆞ s ≥ 0.  The last equation denotes a plane equation of the left plane of the view frustum. The left plane in the unit-cube has been transformed back to world coordinates.

41 41 View Frustum Intersection (Frustum Plane Extraction) All the planes are


Download ppt "Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology."

Similar presentations


Ads by Google