|
544 | 544 |
|
545 | 545 | <div class='together'>
|
546 | 546 | There are some caveats that make this less pretty than it first appears. First, suppose the ray is
|
547 |
| -travelling in the negative $x$ direction. The interval $(t_{x0}, t_{x1})$ as computed above might be |
548 |
| -reversed, _e.g._ something like $(7, 3)$. Second, the divide in there could give us infinities. And |
549 |
| -if the ray origin is on one of the slab boundaries, we can get a `NaN`. There are many ways these |
550 |
| -issues are dealt with in various ray tracers’ AABB. (There are also vectorization issues like SIMD |
551 |
| -which we will not discuss here. Ingo Wald’s papers are a great place to start if you want to go the |
552 |
| -extra mile in vectorization for speed.) For our purposes, this is unlikely to be a major bottleneck |
553 |
| -as long as we make it reasonably fast, so let’s go for simplest, which is often fastest anyway! |
554 |
| -First let’s look at computing the intervals: |
| 547 | +travelling in the negative $\mathbf{x}$ direction. The interval $(t_{x0}, t_{x1})$ as computed above |
| 548 | +might be reversed, _e.g._ something like $(7, 3)$. Second, the divide in there could give us |
| 549 | +infinities. And if the ray origin is on one of the slab boundaries, we can get a `NaN`. There are |
| 550 | +many ways these issues are dealt with in various ray tracers’ AABB. (There are also vectorization |
| 551 | +issues like SIMD which we will not discuss here. Ingo Wald’s papers are a great place to start if |
| 552 | +you want to go the extra mile in vectorization for speed.) For our purposes, this is unlikely to be |
| 553 | +a major bottleneck as long as we make it reasonably fast, so let’s go for simplest, which is often |
| 554 | +fastest anyway! First let’s look at computing the intervals: |
555 | 555 |
|
556 | 556 | $$ t_{x0} = \frac{x_0 - A_x}{b_x} $$
|
557 | 557 | $$ t_{x1} = \frac{x_1 - A_x}{b_x} $$
|
|
2440 | 2440 | ------------------------------------------------------
|
2441 | 2441 | We've solved step two above: solving the ray-plane intersection, assuming we have the plane
|
2442 | 2442 | equation. To do this, we need to tackle step one above: finding the equation for the plane that
|
2443 |
| -contains the quad. We have quadrilateral parameters $\mathbf{Q}$, $u$, and $v$, and want the |
2444 |
| -corresponding equation of the plane containing the quad defined by these three values. |
| 2443 | +contains the quad. We have quadrilateral parameters $\mathbf{Q}$, $\mathbf{u}$, and $\mathbf{v}$, |
| 2444 | +and want the corresponding equation of the plane containing the quad defined by these three values. |
2445 | 2445 |
|
2446 | 2446 | Fortunately, this is very simple. Recall that in the equation $Ax + By + Cz = D$, $(A,B,C)$
|
2447 | 2447 | represents the normal vector. To get this, we just use the cross product of the two side vectors
|
|
0 commit comments