Tilt-Shift Rendering Using a Thin Lens Model
Presented by Kenneth Lamar
Hello everyone. My name is Kenneth Lamar, and today I will be talking about tilt-shift rendering using the thin lens model. Simulating a tilt-shift lens in ray tracing enables us to accurately simulate several advanced real-world photography techniques.
You can see this showcased in this image of a model train. Even though the depth of field is quite strong, the entire train remains in focus, as the focal plane has been tilted.
How it Works
So we have talked about what we are trying to do. Now, let's talk broadly about how to do it.
Every ray starts by being fired out from some point on the image sensor. We call this point P'. It starts at some point on the sensor relative to the associated pixel, just like in our assignments throughout the semester. We then shoot it in a direction toward the origin, the center point of the thing lens, O. To simulate the imperfect angle of the way light hits the lens, we apply a random offset to where it actually hits the lens. That's why O here isn't in the center. Finally, that ray gets redirected by the lens and shoots off toward the associated point on the focal plane, P.
P is calculated using the below equation. It relates to the location on the image sensor, the focal length, and the distance to the sensor.
A more intuitive way for me to calculate P is by getting the direction vector between the starting point, P', and the origin of the lens. This is the direction the light would travel if it didn't need any correction. We can use this direction to find the intersection point at the focal plane, which is P. To make our ray go toward P, our final ray's origin is set to O and its final direction is set to go from O toward P. In this way, every ray is perfectly directed when it hits objects on the focal plane, but anything in front of or behind that plane could be directed imperfectly, causing blur.
To add support for shifting is quite simple. You merely take whatever point P you would normally get and offset it by some amount on the X and Y axes.
Handling tilt is more involved. The distance between the lens plane and the focal plane remains unchanged in the center, but finding O and P becomes more complex. In this case, we calculate basis vectors, u and v, which indicate the angle of the lens. u points right relative to the lens and v points up. Now to compute O, we find some random offset along the rotated lens plane using those basis vectors.
Computing P uses a slightly more complex version of the equation used before. Unlike before, now we compute P' dot t-hat instead of s. T-hat is the direction the lens has tilted to face. This takes P' and redirects it according to the lens rotation.
## In Closing
- The tilt-shift camera model simulates advanced, real-world photography techniques
- The thin lens model simplifies the needed computations
- Once rays are redirected, they are traced as per normal
Thank You!
Interactive Demo
I have an interactive version of my 2D visualization available to mess around with. Most combinations of values and effects are properly handled. I encourage anyone who is interested give it a try. It has control of several parameters I didn't need for this presentation.