## Addendum to Tracing Ray Differentials

Homan Igehy
Stanford University

The purpose of this addendum is to prove that equation (12) in  is correct for an arbitrary surface.

Equation (9) states that for a ray that intersects a surface at `t`, the new ray is given by:

``` P' = P + t D D' = D ```
Its ray differential is given by (10):
``` dP'/dx = dP/dx + t dD/dx + dt/dx D dD'/dx = dD/dx ```
In the paper, the value of `dt/dx` is derived for a plane in (12), and it is stated without proof that the expression is valid for all surfaces. Here, we give a simple proof of this fact.

Suppose we have a surface `S` that is parameterized by surface coordinates `u` and `v`:

``` S(u,v) ```

It's unit surface normal `N` is given by the normalized cross product of its two partial derivatives:

``` n = (dS/du) x (dS/dv) N = n / ||n|| ```
The intersection of this surface with the ray defined by `P` and `D` is given by the system of equations:
``` S = P + t D ```
Implictly differentiating with respect to image space coordinate `x`, we get:
``` dS/dx = dP/dx + t dD/dx + dt/dx D ```
All of the terms in the above equation are known for an intersected surface except for `dt/dx` (which is what we are solving for) and ` dS/dx`. A novel application of the surface normal will get rid of this `dS/dx` term. Now, the Chain Rule for multivariate functions tells us that `dS/dx` is a surface tangent vector given by a linear combination of the two basis tangent vectors `dS/du` and `dS/dv`:
``` dS/dx = dS/du du/dx + dS/dv dv/dx ```
The `du/dx` and `dv/dx` tell us the rate of change in the local surface parameterizations `u` and `v` with respect to the image space coordinate `x`, but as we shall see, these values are irrelevant. The dot product of the surface tangent vector `dS/dx` with the surface normal `N` is of course zero:
``` (dS/dx . N) = (dS/du du/dx + dS/dv dv/dx) . N (dS/dx . N) = (dS/du . N) du/dx + (dS/dv . N) dv/dx (dS/dx . N) = (0) du/dx + (0) dv/dx (dS/dx . N) = 0 ```
Thus, we can take our original equation:
``` dS/dx = dP/dx + t dD/dx + dt/dx D ```
And take its dot product with `N` to get:
``` 0 = (dP/dx + t dD/dx + dt/dx D) . N ```
Rearranging, we are left with:
``` dt/dx = - [ (dP/dx + t dD/dx) . N ] / (D . N) ```

### References

H. Igehy. Tracing Ray Differentials. Computer Graphics (SIGGRAPH 99 Proceedings), 33, 179-186, 1999.

homan@graphics.stanford.edu