computer graphics
play

Computer Graphics MTAT.03.015 Raimond Tunnel The Road So Far... - PowerPoint PPT Presentation

Computer Graphics MTAT.03.015 Raimond Tunnel The Road So Far... Bounding Box With bounding boxes you can detect collisions between boxes. Our hangar just happens to be a box. The chopper is not a box, but the collision


  1. Computer Graphics MTAT.03.015 Raimond Tunnel

  2. The Road So Far...

  3. Bounding Box ● With bounding boxes you can detect collisions between boxes. ● Our hangar just happens to be a box. ● The chopper is not a box, but the collision approximation with a bounding box seems ok. ● The bounding box is axis-aligned. ● Some of you wrote 4 if-statements. That is a (kind of) bounding box collision detection for those specific boxes (around chopper, the hangar).

  4. Collision Detection ● What if the hangar walls were rotated? Can not assume that all walls are always axis-aligned. ● What if the chopper rotated? ● The rotating blades actually would need a cylinder to minimally bound them. ● Bounding objects provide a fast and rough approximation.

  5. Ray Casting ● Cast rays out of some vertices, following the vertex normal.

  6. Ray Casting ● Detect the first hit of ray and scene geometry. ● Measure the distance from the vertex to the hit. ● If the distance is too small, change the chopper's position, speed, acceleation, in order to avoid a collision. ● Intersection testing: ● Intersection testing between a variety of objects: http://www.realtimerendering.com/intersections.html

  7. Möller-Trumbore Ray Triangle Ray ( t )= Start + t ⋅ Direction ● Triangle ( u ,v )= v 0 + u ⋅ e 0 + v ⋅ e 1 ● ● The and are actually u v Barycentric coordinates of v 1 v 2 vertices and . ● What is the coordinate of ? v 0 ● Goal is to find a solution to the following equation: Ray ( t )= Start + t ⋅ Direction = v 0 + u ⋅ e 0 + v ⋅ e 1 = Triangle ( u ,v )

  8. Möller-Trumbore Ray Triangle ● Let us call the and the . S Start D Direction ● We can rearrange the terms to see better. S + t ⋅ D =( 1 − u − v ) v 0 + u ⋅ v 1 + v ⋅ v 2 g n i h t . e h m t i a w s d e e S − v 0 = u ⋅ ( v 1 − v 0 )+ v ⋅ ( v 2 − v 0 )− t ⋅ D h t t r a s i t s s i e h w T t a h ⋅ ( t ) t u ( ( v 1 − v 0 ) − D ) ( v 2 − v 0 ) = S − v 0 v ● We are looking for the unknown vector ( t ) u v

  9. Möller-Trumbore Ray Triangle ● We are in 3D, so we have 3 equations for each dimension. ⋅ ( t ) u ( e 0 − D ) = S − v 0 e 1 v x = ∣ A x ∣ y = ∣ A y ∣ z = ∣ A z ∣ ● Cramer's rule ∣ A ∣ ∣ A ∣ ∣ A ∣ a 0,0 ⋅ x + a 0,1 ⋅ y + a 0,2 ⋅ z = b 0 a 1,0 ⋅ x + a 1,1 ⋅ y + a 2,2 ⋅ z = b 1 A x - first column replaced by b a 2,0 ⋅ x + a 2,1 ⋅ y + a 2,2 ⋅ z = b 2 A y - second column replaced by b A z - third column replaced by b

  10. Möller-Trumbore Ray Triangle u = ∣ − D z ∣ ● With Cramer's rule S x − v 0x e 1x − D x ⋅ ( t ) S y − v 0y − D y e 1y u S z − v 0z e 1z ( e 0 − D ) = S − v 0 e 1 v ∣ − D z ∣ − D x e 0x e 1x e 0y e 1y − D y ● Denote columns e 0z e 1z b = S − v 0 u = ∣ b − D ∣ v = ∣ e 0 − D ∣ t = ∣ e 0 b ∣ e 1 b e 1 ∣ e 0 − D ∣ ∣ e 0 − D ∣ ∣ e 0 − D ∣ e 1 e 1 e 1 How to find those determinants?

  11. Möller-Trumbore Ray Triangle ( b × c )= ∣ a c ∣ ● Scalar triple product: a ⋅ b t = e 0 ⋅ ( e 1 × b ) u = b ⋅ ( e 1 ×− D ) v = e 0 ⋅ ( b ×− D ) e 0 ⋅ ( e 1 ×− D ) e 0 ⋅ ( e 1 ×− D ) e 0 ⋅ ( e 1 ×− D ) ● Anticommutativity of the cross product: t = e 0 ⋅ ( e 1 × b ) u = b ⋅ ( D × e 1 ) v = e 0 ⋅ ( D × b ) e 0 ⋅ ( D × e 1 ) e 0 ⋅ ( D × e 1 ) e 0 ⋅ ( D × e 1 ) ● Circular shift invariance of scalar triple product t = e 1 ⋅ ( b × e 0 ) v = D ⋅ ( b × e 0 ) e 0 ⋅ ( D × e 1 ) e 0 ⋅ ( D × e 1 )

  12. Möller-Trumbore Ray Triangle ● We can calculate only two cross products t = e 1 ⋅ ( b × e 0 ) u = b ⋅ ( D × e 1 ) v = D ⋅ ( b × e 0 ) e 0 ⋅ ( D × e 1 ) e 0 ⋅ ( D × e 1 ) ⋅ ( D × e 1 ) e 0 Q =( b × e 0 ) t = e 1 ⋅ Q u = b ⋅ P v = D ⋅ Q ̂ ̂ ̂ P P =( D × e 1 ) P P ̂ P = e 0 ⋅ P ̂ ● What happens if: P = e 0 ⋅ ( D × e 1 )∼ 0 ̂ ̂ P = e 0 ⋅ ( D × e 1 )< 0 P = e 0 ⋅ ( D × e 1 )> 0 Circular shift can help to visualize this better...

  13. Möller-Trumbore Ray Triangle ● Can it happen, and what does it mean? v > 1 u > 1 v < 0 u + v > 1 t ≤ 0 u < 0

  14. Ray Trace Rendering ● What is the origin of a ray? ● What about the direction?

  15. Ray Trace Rendering ● Accurate way to model reflective / refractive surfaces. ● Quite expensive, we need to test each ray against our geometry. 800 ⋅ 600 ⋅ 3 ⋅ 700 = 1008000000 screen width, height bounces triangles (quite few) number of rays That is over a billion intersection tests each frame!

  16. Space Partitioning ● We can keep our objects in a structure, that lessens the number of intersections we need to test. ● Imagine in 2D a ray and a some line segments. Any ideas, how to lessen the number of tests?

  17. First Idea: Axis-Aligned Grid ● We can limit the number of grid cells to check, by accounting for the ray's direction.

  18. First Idea: Axis-Aligned Grid ● Most of the cells are empty...

  19. Second Idea: Quadtree / Octree ● Make the cells divide, if there are more objects inside them. Start with one cell for the entire scene.

  20. Third Idea: K-D Tree ● Split according to the geometry. Traditionally by the median value. No node will be empty.

  21. Third Idea: K-D Tree ● Split with a rule to maximize the occurance of empty nodes. Why is this good?

  22. Fourth Idea: BSP Tree ● Binary Space Partitioning divides the space with existing polygons. Not that useful for ray tracing. Works well for geometry ordering (front to back).

  23. Fifth Idea: BVH ● Bounding Volume Hierarchy – create a tree of bounding polygons around objects. Bounding objects also useful for collision detection. Axis-aligned bounding boxes. Bounding spheres.

  24. Space Partitioning ● Possible to combine different methods. ● Create structures, based on your own rules. ● Some better for dynamic, some for static scene. ● Ray Tracing Acceleration Data Structures : http://www.cse.iitb.ac.in/~paragc/teaching/2009/cs 475/notes/accelerating_raytracing_sumair.pdf ● Octree vs BVH : http://thomasdiewald.com/blog/?p=1488

  25. What did you found out today? What more would you like to know? Next time Global Illumination

Recommend


More recommend