Virtual Lens from scratch with Grasshopper and Blender (LuxCore)

You might ask yourself what this is and why it is in the gallery, but bear with me:

The images you see are Luxcore renders done with bidir caustics. The photographic chart you see is only a caustic effect, the plane itself is white diffuse with no texture.

Before I go into details: Watch the video below - it shows the whole process and will make everything much clearer.

after the video - here are some more details:

This is a ‘real’ photographic lens, more specifically a so called ‘cooke-triplet’ that I built from scratch - so no reference values were used beyond copying the rough layout of the three lenses.

The first part of the process happens in Rhino / Grasshopper where I built a parametric lens template and a whole evaluation system for light rays (in 2d).

Running the parameters through a genetic optimization algorithm (Galapagos) it found a ‘good’ solution - meaning a lens configuration that produces a sharp image at a given distance.

After that I exported the lenses as objs to blender and gave them a glass shader, build a housing, film plate and placed a emitter with a texture (the chart) in front of it at the right distance.

Additionally, here is a big screenshot from the Grasshopper setup. I would wish that Grasshopper gets a bit more attention in the discussion on everything nodes. Because it is being worked on for about 10 years and it does many things very well (conceptually)

Full setup (aperture and lens body are hidden)


caustic result with small aperture:

caustic result with large aperture:

20 Likes

Yes but right now only by eyeballing the right distance…
I could run a second algorithm with fixed lens shapes but variable lens positions to find out where different focal planes are (in grasshopper).
Maybe i will do that soon - lots of free time these days

I’m curious - are you doing this as part of an optical design project, or are you just trying to see what you can do with the software? Pretty amazing in any case.

just filling the time during quarantine… :wink:

2 Likes

Pretty awesome stuff! Love the genetic optimizer.
Might make a nice example scene for LuxCore, if you are willing to share it.

1 Like

sure! - here the scene: dropbox link

1 Like

Which LuxCore version did you use to render this?

2.2 release… why?

I was loading it in v2.3 and it seemed way too bright, this explains it. There were some changes in v2.3 that break backwards compatibility.
Fortunately I wrote an automatic converter script to port it with one click (in LuxCore tools panel in the render properties).

As a Rhino/Grasshopper user here I would like to study your definition if you are willing to share. I want to learn as much as possible on how to use Grasshopper as it is a very powerful tool.

Thats so nerdy … i love it!

Maybe you will be interested in this. work is done in C4D ( modeling part ), but more important is choice of render engine. Video for nerds :smiley:


second part

very interesting even if you do not want to make something like that

WOW , Unbelievable … :smiley:

I’m not super familiar with LuxCore or optics in general, but I really enjoyed experimenting with this setup! I tried turning on dispersion with the glass material for some chromatic aberration (slightly different camera position accounts for the cropping):

I also got some lens flares with the bright light source off-camera (pretty low sample count):

For on-camera lights, it can’t generate the diffraction from the aperture, so I put a small rounded glass material (1.0 IOR with 0.00354 dispersion) along the edge of the aperture to try to simulate it:

The diffraction has too much dispersion when compared to actual starbursts in lens flares - maybe there’s a better way to simulate this?

Here’s the dropbox link to my experiments!

1 Like

Really neat stuff!