appleseedhq / appleseed

A modern open source rendering engine for animation and visual effects
https://appleseedhq.net/
MIT License
2.19k stars 329 forks source link

Add multilens cameras #2914

Closed JaanWilli closed 2 years ago

JaanWilli commented 3 years ago

Summary

This PR contains the implementation of a physically-based multi-lens camera created as a bachelor thesis supervised by @LZaw. It partially covers the topics of the issue "Physically-based camera" #1740 and consists of the complete code as well as test scenes.

TODOs

It is currently a draft pull request, as there are some open tasks that will be completed once I submit the thesis:

Problem Description

All cameras currently available in appleseed are approximations of real models and sacrifice realistic camera phenomena for performance. There are however scenarios, where images as if shot on a real camera are desired, for example when combining real images with computer-generated footage.

Solution Description

To achieve photorealistic images, a simulation of a real lens with many lens elements is required. In literature, there are mainly two approaches for that, which I like to call "ray simulation" and "polynomial optics". Below, I list some characteristics of the two.

Ray simulation

Polynomial Optics

In the end, my choice fell on ray simulation, more precisely the model described in "Realistic rendering of bokeh effect based on optical aberrations" with elements from "An Accurate and Practical Camera Lens Model for Rendering Realistic Lens Effects" and Physically Based Rendering: From Theory to Implementation. For more details on the the comparison and the choice, please see Chapter 3 of my thesis.

Implementation

As discussed, this PR extends the cameras by another one and is located in src/appleseed/renderer/modeling/camera. This PR contains the following changes:

Results

The implemented model can achieve the following:

It cannot produce:

Performance

I spent quite some time analyzing the performance of the implementation in relation to pinhole and thin lens camera. For details, see Chapter 6.2 of my thesis. The main takeaways were:

Conclusion

The implemented model is not a thin lens replacement, but offers advantages in some scenarios, especially when bokeh or vignetting is important. Although performance is a bit worse than pinhole and thin lens, the overhead is constant and therefore too significant in complex scenes. With simple scenes though, the multi-lens camera is probably not worthwhile to use.

JaanWilli commented 2 years ago

Thanks for the first look! Completed are all the syntax and style issues. Still left are things that require a bit more thought and testing (memory/speed improvements, function locations, exception handling, ...)