Blender Studio
  • Films
  • Projects
  • Training
  • Characters
  • Tools
  • Blog
  • Join
  • BLENDER.ORG

    • Download

      Get the latest Blender, older versions, or experimental builds.

    • What's New

      Stay up-to-date with the new features in the latest Blender releases.

    LEARNING & RESOURCES

    • Blender Studio

      Access production assets and knowledge from the open movies.

    • Manual

      Documentation on the usage and features in Blender.

    DEVELOPMENT

    • Developers Blog

      Latest development updates, by Blender developers.

    • Documentation

      Guidelines, release notes and development docs.

    • Benchmark

      A platform to collect and share results of the Blender Benchmark.

    • Blender Conference

      The yearly event that brings the community together.

    DONATE

    • Development Fund

      Support core development with a monthly contribution.

    • One-time Donations

      Perform a single donation with more payment options available.

Training Highlights
Stylized Rendering with Brushstrokes
Geometry Nodes from Scratch
Procedural Shading Fundamentals
Stylized Character Workflow

Training types
Course Documentation Production Lesson Workshop

Training categories
Animation Geometry Nodes Lighting Rendering Rigging Shading
Film Highlights
Wing It!
2023
Charge
2022
Sprite Fright
2021
Spring
2019
Project Highlights
Project DogWalk
Interactive
Gold
Showcase
BCON24 Identity
Showcase
Fighting with Grease Pencil
Article

Simulating Physical Camera Lenses with Caustics

Andy explains how he simulated a physical camera lens using caustics rendering in Cycles.
  • 3 Feb 2023
  • 2 min read
  • 2 min watch time
Andy Goralczyk
Andy Goralczyk Author
Report Problem

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
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:

caustics_lens_example.blend
Blender File · 22.0 MB · CC-BY caustics_lens_example.blend
Download File

Enjoy!

Join to leave a comment.

4 comments
Giuliano D'Angelo
Giuliano D'Angelo
May 6th, 2023

Wow it's so impressive you can emulate and make it work a camera obscura in blender.

De Etta L Ewing
De Etta L Ewing
Feb. 19th, 2023

I expanded the video file above to watch and get a full screen view, your final scene has the same airiness of some of Seurat impressionist work-

KNAO
KNAO
Feb. 4th, 2023

It would be great if camera shaders could be used in Blender as they are in Arnold. http://www.lentil.xyz/

Jesús Odremán
Jesús Odremán
Feb. 3rd, 2023

Dear Andy Goralczyk. It is great news for me this experiment you have conducted. And that you expose in the article, I am a devoted worshipper of Vintage optics, which I use years ago with my Canon DSLR and now with my BMPCC6k. In Blender a few years ago there was an addon for version 2.98 that did awesome things: it was called "Real Camera" and allowed to simulate with Bokeh and color aberrations in Blender, I loved it.... I'm going to take advantage of the blend you share to play around with the beautiful camera obscura you made. Thank you very much!!!!!

Films Projects Training Blog Blender Studio for Teams
Pipeline and Tools
  • CloudRig
  • Blender Kitsu
  • Brushstroke Tools Add-on
  • Blender Studio Extensions
Characters
  • Mikassa
  • Whale
  • Ballan Wrasse
  • Snow
Studio
  • Terms & Conditions
  • Privacy Policy
  • Contact
  • Remixing Music
Blender Studio

The creators who share.

Artistic freedom starts with Blender The Free and Open Source 3D Creation Suite