Lens Sim
Contents
• Foreword
• Installation, Usage, Tutorials and Data
• Forum
• Render times
• Technical details
• Ray-Guiding
• Auto Focus
• Chromatic Aberration
• Ray Portal Node
• Limitations
• Known bugs
• Credits
Foreword
When using Lens Sim I want you to treat each lens and the camera as a real physical object. Just like real lenses, they are not designed to work at all distances. Every lens has its designed working range that the optics are carefully built for. If you try to use a telephoto lens as a macro lens, it will break. Same with standard lenses, they are not necessary designed for macro photography. As all lenses are modeled to real measurements, be aware of your scene scale when using a Lens Sim Camera.
Understanding these boundaries is essential for not breaking the ray guiding- and automatic focus system. I have tried to not set any hard limits on the lenses, so if you want you can easily break them. If you really want to push the lens to it limits I suggest turning off the ray guiding system and enable manual focusing, or tailor the ray guiding system to a specific distance, because the integrated systems will not work outside the working distance of the lens.
Although Lens Sim is designed to be user-friendly, mastering its advanced features and settings may require some time and experimentation, especially when implementing your own lenses and calibrating the ray guiding system.
Installation
1: Save the .zip file of the addon to your computer.
2: Open Blender and go to Edit > Preferences > Add-ons.
3: Click "Install from Disk..." from the "Extension Settings" dropdown menu(top right side), select the downloaded .zip file and press "Install From Disk".
4: If not enabled, find the Lens Sim Add-on in the "Add-ons" panel and enable the addon by checking the box next to its name.
When upgrading from Lite to Full version I recommend uninstalling the Lite version before installing the full version.
Usage
Tutorials
Data
The addon data content can be found in the "AppData\Roaming\Blender Foundation\Blender\4.2(current blender version)\extensions\user_default\lens_sim" folder.
Lenses are found in the "lens_sim\LensSim_Data\lenses" folder. To share lenses simply copy or paste the lens.txt file into this folder and the lens will pop up in the addon.
Some included bokeh images are found in the "lens_sim\LensSim_Data\textures\bokeh" folder. You can use them for the "Aperture Image".
Forum
I wanted a place where people can discuss the addon, suggest features, lenses and post renders. So, I opened this thread on blenderartist.
Render times
For a lot of you looking into this the render times will be a deal breaker for getting this product. Therefore, I want to address this part first before diving into the technical part of how the system works.
Please be aware that it will render slower than Blender’s native camera system. This is due to the per ray calculations involved in simulating lenses and the fact that it is happening in a ray portal material. A key element for performance is the amount of lens elements and of course the sharpness of the lens. Cylindrical lenses used in anamorphic lenses is slower to render than standard spherical lenses making larger anamorphic lenses the slowest.
Enabling chromatic aberration will introduce a lot of noise into your render. This happens because each light ray samples a random color value from the color spectrum to simulate that specific wavelength. In order to end up with an average of white light we need a substantially amount of samples. Fireflies can be reduced by clamping max intensity of light rays(recommended when rendering with chromatic aberration). The color sampling will also make it harder for denoising algorithms to clean up the noise since it is present in the Albedo Pass.
From my experience tracing the lens seems to add a constant amount of extra render time per sample. On simple scenes the render time will be quite slow compared to the standard camera, since the extra time tracing the lens might be greater than the time it takes to trace the scene. On larger scenes with thousands of objects the slowest part will be traversing the scene, so the performance hit will be relative small. When doing animations you will in general get more noise with Lens Sim cameras, so the render might require more samples to get the same results as the standard camera. If I should take a guess I think a render time multiplier of 1.2-3.0 is realistic, but it is hard to say due to the amount of render factors we have to consider. Additionally, bigger and brighter bokeh shapes are hard to get noise free since the bokeh sample distribution might be uneven on some lenses, especially in animations, so keeping it as a subtle effect is recommended.
Render comparisons
System specs: Windows 10, AMD Ryzen 9 3900X 12-Core Processor, NVIDIA GeForce RTX 3080
Here you can see the noise levels of different modes:
This is a quite heavy scene, so most of the time spent is tracing the scene, hence not that much extra render time:
This lens might have some issues with rays being discarded, the image looks a bit darker. The render time is quite similar to the standard camera, but because some % of rays might get discarded here we need more samples to reach the same noise quality. If you look at the top left corner of the Lens Sim renders, you will see that the image is significantly noisier. So even though the render time is equal with the same amount of samples, we will need more samples to clean up the Lens Sim render.
Here you can see the impact between lens complexity and render speed:
Here the scene tracing is quite fast due to the simple background, Lens Sim is approximately 2.96 slower than the standard camera. Also noticed that Lens Sim still needs more sampling due to the hard to render bokeh shape, while the standar cameras bokeh is evenly sampled and therefore less noisy.
The main issue I have had with rendering animations is with shallow depth of field on hard to render places, like large bokehs that comes from specular highlights. Sometimes, those bokeh shapes never seem to get clean no matter how many samples I throw at the render. The rendered scenes where optimized to render with bokeh. If I would add more depth of field to the star wars scene and at the same time increase the light intensity, the bokeh highlights would be quite hard to render for animations without noticeable noise. Moreover, the noise amount varies from lens to lens, some softer lenses would require more samples than sharper lenses.
For projects where render time is a critical factor, I would consider using simplified lens profiles with a deep depth of field to balance performance and quality, or just do lens effects in post instead :(
Technical details
Ray-Guiding
Most existing simulations struggle when rendering images with small apertures, leading to excessively long render times. This happens because many light rays miss the tiny aperture opening, resulting in wasted samples and inefficient processing.Lens Sim’s ray-guiding system tackles this problem by directing light rays toward the aperture opening. This ensures that each ray contributes to the final image, maximizing the use of available samples. As a result, you can render at a wide variety of f-stop values, whether it is wide open or stopped down without suffering from the usual performance bottlenecks. This approach allows fast, efficient rendering across the full aperture range, giving you the flexibility to achieve the exact depth of field you need.
Auto Focus
By sending a single ray from the requested focus distance towards the lens aimed at a point vertically on the first lens surface, we can calculate the optimal sensor position based on the converged ray. This works native for all cylindrical lenses, the only factor we have to adjust is the position where we want the ray to hit the first lens surface. For cylindrical lenses (used in anamorphic lenses) we have to build a lookup table for the rack focus by sampling various distances and its optimal rack focus shift, luckily this can be calculated by the addon automatically (by also sending a ray aimed horizontally we can check whether or not they line up, if their not lined up we shift the rack focus a tiny amount and try again until the subject is in focus).
Chromatic Aberration
By utilizing the Abbe value of each lens element, we can approximate the wavelength-dependent behavior of light within the lens. To simulate chromatic aberration, we randomly sample a wavelength from the visible color spectrum and calculate the corresponding index of refraction (IOR) for each lens element based on the abbe value of the lens. The ray is then refracted based on this wavelength-specific IOR, allowing for proper wavelength folding through the whole lens.
Ray Portal Node
Instead of using physical geometry to shape or direct light, the Ray Portal Node acts as a virtual window, calculating the lens geometry with math functions without needing physical geometry. This gives us full control over each ray, resulting in no unwanted noise or light leaks. We can avoid most of the floating point issues that happens compared to using complicated geometry setups. This ensures that the lens will work at any rotation and at large distances without compromising render quality.
By using a data table structure for storing and creating lenses we remove the need for tedious manual tweaking and allows you to switch between complex lenses without the hassle of creating or adjusting physical geometry, the material is altered via automated python scripts that only loads the required lens elements for the selected lens. Once a lens is created and calibrated it can easily be loaded in the system.
Limitations
• All AOV passes and the image alpha will be affected by the optical vignetting. Passes like depth, position and the motion vector will be quite useless due to its sampling method, I believe they are set from the first sample so if that sample hitts the inside of the lens boundary it will be black. The Mist pass for example(that takes the depth average) will be darkened towards the edges since some of the rays hits the edges of the lens, making it quite useless for adding mist. AOV passes that is an average of all accumulated samples is less useless but still affected by the optical vignetting. This means that you will be able to reconstruct the whole render via combining passes like (DiffDir + DiffInd) * DiffCol etc, but the passes will be darkened towoards the edges of the circle of illumination. There is currently not a way to tell cycles to discard a ray completely inside a material shader, so there is not much I can do about these issues. I experimented with switching to a holdout shader when the ray hits the inside of the lens, it improved some of the passes but also made some of them worse.
• Lens Sim works with Blender 4.2+, Cycles Render engine only. The ray portal plane is a requirement for it to work so older blender versions is not supported. Certain features or advanced settings may have limitations when used with other plugins. The blender camera is setup to work as the lens sensor, so changing camera parameters outside of the Lens Sim panel might break the system. Always verify compatibility with your specific rendering setup to avoid potential issues.
• The max number of lens elements is set to 15. This is due to being close at reaching the max number of nodes allowed in a material. Also, larger lenses tend to have less lens artifacts and being slower to render, so I think it is a reasonable choice to have that limit and not implement larger lenses.
• Lens types supported is spherical and cylindrical lenses. I tried implementing aspherical lenses but I ran into some issues with the calculations, also they were quite slow to render so I quickly gave up on them.
• There is only support for a single aperture. It shouldn't be hard to implement but its not something I've seen necessary to have.
• This is a general system for rendering lenses, so some lenses might not work, especially with the ray guiding system. I have had some issues with smaller lenses where the curvature of the lens was quite large, like the 15mm f8.0 Zeiss Hologon. That lens is tiny with very curved lenses, it ran into some floating point issues. Most normal looking lenses should work.
Known bugs
• If you experience viewport performance issues, try disabling the addon and restart blender. Then, reinstall the addon and restart blender one more time before using it. Not sure what causing this performance issue, but a user has reported that doing this fixed it.
• If the camera lens parameters are changed outside of the Lens Sim panel, the lens setup may break. Try pressing "Disable Lenses" and then "Enable Lenses", this will reset the camera parameters back to the Lens Sim setup.
• When sampling the Bump Node blender seems to take the camera scale into the equation. Since the camera scale in Lens Sim is independent of the actual lens scale that were rendering with, having the "Camera Scale" parameter too high on tiny close-ups shots will result in the bump map being shifted too far. To fix this simply adjust the "Camera Scale" to a lower value. This issue is only visible when using bump maps on tiny objects(the "ROT" text in the example below is 2.7 mm wide), normal maps works as intended.
• Due to the amount of nodes in the lens material, the ray visualization in schematic mode might trigger the max amount of nodes allowed on some of the larger lenses.
• The ray visualization in schematic mode might not display correctly when racking anamorphic lenses. This happens because the rack focus is calculated in the material while the rays are calculated in python.
Credits
• This work is based on "Tattoine Buildings Kitbash" (https://sketchfab.com/3d-models/tattoine-buildings-kitbash-b5a2140fa2264bac8a4b6de3693272b6) by chuckcg (https://sketchfab.com/chuckcg) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
• This work is based on "Free Droide De Seguridad K-2SO By Oscar Creativo" (https://sketchfab.com/3d-models/free-droide-de-seguridad-k-2so-by-oscar-creativo-e4c65688ae1b47ec9e1dd6acec2dcadd) by OSCAR CREATIVO (https://sketchfab.com/oscar_creativo) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
• This work is based on "Spaceship Corridor" (https://sketchfab.com/3d-models/spaceship-corridor-1cdd1db557b8428892af4773bdada913) by the_table (https://sketchfab.com/the_table) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
Choose a product version:
-
$40$28 Lens Sim
(Full version: all features and lenses)
-
$15$10.50 Lens Sim Lite
(Basic features and limited lenses)
Sales | 500+ |
Customer Ratings | 7 |
Average Rating | |
Dev Fund Contributor | |
Published | 1 day ago |
Blender Version | 4.3, 4.2 |
Extension Type | Add-on |
License | GPL |
Have questions before purchasing?
Contact the Creator with your questions right now.
Login to Message