... ribed above, this falls apart for clipping against perspective projections because intersections on opposing
planes may be both lower or both upper bounds on $t$. What is needed is a test for the side of the plane the line hits.
Continuing the example above for a line $\mathbf{o} + \mathbf{d} t$.
In the general case, a line hits the front of a plane if its direction vector $\mathbf{d}$ is opposite the plane's normal vector $\mathbf{n}$. The normal vectors for clipping planes are simply:
$$(1, 0, 0, 1) \text{left}$$
$$(-1, 0, 0, 1) \text{right}$$
$$(0, 1, 0, 1) \text{bottom}$$
$$(0, -1, 0, 1) \text{top}$$
$$(0, 0, 1, 1) \text{near}$$
$$(0, 0, -1, 1) \text{far}$$
If $\mathbf{d} \cdot (1, 0, 0, 1) < 0$, i.e. $\mathbf{d}_x + \mathbf{d}_w < 0$, then the line will hit the left clipping plane coming from the right hand side, meaning the time of intersection $t$ (see the section above) becomes an upper limit
to clip the line's $t_1$ to. If the inequality is false then the line hits the left clipping plane coming from the left and $t$
should instead be a lower limit on the line's $t_0$.
For an example of this in use, see [this frustum clipping shadertoy](https://www.shadertoy.com/view/ctV3zc).
[1]: https://img.heuristic42.com/img/675ebe68cd3a.svge same does not work for clipping against perspective projections.
![perspective clipping][2]
As seen in the figure above, intersections on opposing planes may be both lower (in this case, shown in green) or both upper bounds on $t$. What is needed is a test for the side of the plane the line hits.
Continuing the example above for a line $\mathbf{o} + \mathbf{d} t$.
In the general case, a line hits the front of a plane if its direction vector $\mathbf{d}$ is opposite the plane's normal vector $\mathbf{n}$. The normal vectors for clipping planes are simply:
$$(1, 0, 0, 1) \text{left}$$
$$(-1, 0, 0, 1) \text{right}$$
$$(0, 1, 0, 1) \text{bottom}$$
$$(0, -1, 0, 1) \text{top}$$
$$(0, 0, 1, 1) \text{near}$$
$$(0, 0, -1, 1) \text{far}$$
If $\mathbf{d} \cdot (1, 0, 0, 1) < 0$, i.e. $\mathbf{d}_x + \mathbf{d}_w < 0$, then the line will hit the left clipping plane coming from the right hand side, meaning the time of intersection $t$ (see the section above) becomes an upper limit
to clip the line's $t_1$ to. If the inequality is false then the line hits the left clipping plane coming from the left and $t$
should instead be a lower limit on the line's $t_0$.
For an example of this in use, see [this frustum clipping shadertoy](https://www.shadertoy.com/view/ctV3zc).
[1]: https://img.heuristic42.com/img/675ebe68cd3a.svg
[2]: https://img.heuristic42.com/img/4ec909adeb9d.svg
... ribed above, this falls apart for clipping against perspective projections because intersections on opposing
planes may be both lower or both upper bounds on $t$. What is needed is a test for the side of the plane the line hits.
Continuing the example above for a line $\mathbf{o} + \mathbf{d} t$.
In the general case, a line hits the front of a plane if its direction vector $\mathbf{d}$ is opposite the plane's normal vector $\mathbf{n}$. The normal vectors for clipping planes are simply:
$$(1, 0, 0, 1) \text{left}$$
$$(-1, 0, 0, 1) \text{right}$$
$$(0, 1, 0, 1) \text{bottom}$$
$$(0, -1, 0, 1) \text{top}$$
$$(0, 0, 1, 1) \text{near}$$
$$(0, 0, -1, 1) \text{far}$$
If $\mathbf{d} \cdot (1, 0, 0, 1) < 0$, i.e. $\mathbf{d}_x + \mathbf{d}_w < 0$, then the line will hit the left clipping plane coming from the right hand side, meaning the time of intersection $t$ (see the section above) becomes an upper limit
to clip the line's $t_1$ to. If the inequality is false then the line hits the left clipping plane coming from the left and $t$
should instead be a lower limit on the line's $t_0$.
For an example of this in use, see [this frustum clipping shadertoy](https://www.shadertoy.com/view/ctV3zc).
[1]: https://img.heuristic42.com/img/675ebe68cd3a.svge same does not work for clipping against perspective projections.
![perspective clipping][2]
As seen in the figure above, intersections on opposing planes may be both lower (in this case, shown in green) or both upper bounds on $t$. What is needed is a test for the side of the plane the line hits.
Continuing the example above for a line $\mathbf{o} + \mathbf{d} t$.
In the general case, a line hits the front of a plane if its direction vector $\mathbf{d}$ is opposite the plane's normal vector $\mathbf{n}$. The normal vectors for clipping planes are simply:
$$(1, 0, 0, 1) \text{left}$$
$$(-1, 0, 0, 1) \text{right}$$
$$(0, 1, 0, 1) \text{bottom}$$
$$(0, -1, 0, 1) \text{top}$$
$$(0, 0, 1, 1) \text{near}$$
$$(0, 0, -1, 1) \text{far}$$
If $\mathbf{d} \cdot (1, 0, 0, 1) < 0$, i.e. $\mathbf{d}_x + \mathbf{d}_w < 0$, then the line will hit the left clipping plane coming from the right hand side, meaning the time of intersection $t$ (see the section above) becomes an upper limit
to clip the line's $t_1$ to. If the inequality is false then the line hits the left clipping plane coming from the left and $t$
should instead be a lower limit on the line's $t_0$.
For an example of this in use, see [this frustum clipping shadertoy](https://www.shadertoy.com/view/ctV3zc).
[1]: https://img.heuristic42.com/img/675ebe68cd3a.svg
[2]: https://img.heuristic42.com/img/4ec909adeb9d.svg