It all started with me wanting to learn more about how physical camera lenses work. I browsed for some diagrams online to see how to construct a simple lens. Next, I started modeling some lens elements and minutes later I found myself in a rather strange rabbit hole.
A first test with a moving camera and shifting focus. It shows very interesting flaring and light leaking.
After some initial noodling around with the render settings in cycles, I had a working setup. I enclosed my "physically based" lens in a camera body and added a translucent plane as a sensor to focus the rays. This in turn gets rendered by an upside-down orthographic blender camera to capture the final image. A circular opening in the middle of the lens (with a shape-key to vary its size) serves as aperture.
The idea itself is nothing new, and quite a few people managed to get mind-blowing results. But the recent improvements to Cycles left me wondering if this is feasible for rendering animations.

The lenses are enclosed in a black box to only let in rays pass through the lens onto the sensor plane
This setup only works when refractive caustics are enabled in rendering, and it needs around 20 transmission bounces to work correctly. You need quite a lot of samples to render a clear image, 3000 - 8000. But even then, I was extremely excited to see lens flaring, light leaking and other physical imperfections show up in the renders!
Since I'm not that knowledgeable in optics and mathematics, this is all very unscientific. I am sure the lenses are a little out of proportion. I picked the values that seemed right, which sometimes made me feel like a caveman holding shards of volcanic glass into the sun and burning myself in the process!
There are quite some limitations of this crude camera: For example, the lens has a fixed angle of view. The focus range isn't that great, either. In an earlier test I tried to simulate chromatic aberration by combining the R, G and B channels of different glass materials with diverging indices of refraction together, but it was a little bit cumbersome to get it physically correct (ie. Sergey certified!). All in all, this is not entirely practical for use in production. But I learnt a lot about optics and most importantly it shows how far the development has come in cycles to make this remotely possible!
A tour of the camera controls in the example file. This file uses the Asset Demo by Simon and Julien.
I bundled up my explorations in a single file. The camera is rigged and ready to play around with: There is a bone for focus control and the main root bone has two properties to control lens aperture and sensor gain. You'll need Blender 3.5 Alpha
Download the file here:
Blender File - 22.0 MB - CC-BYcaustics_lens_example.blend
Enjoy!
Join to leave a comment.