# Virtual Lens from scratch with Grasshopper and Blender (LuxCore)

**URL:** <https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126>\
**Category:** Finished Projects\
**Created:** [March 15, 2020, 8:18pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126 "2020-03-15T20:18:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [March 15, 2020, 8:18pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/1 "2020-03-15T20:18:03Z")

</div>

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.

[![](https://blenderartists.org/uploads/default/original/4X/8/7/9/8796e4d5aad8dd86dc95c4853901c1c14dfb144f.jpeg "Virtual Lens from scratch with Grasshopper and Blender (LuxCore)") ](https://www.youtube.com/watch?v=8FpaBYwG8D0)

**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)**

 ![result03](https://blenderartists.org/uploads/default/original/4X/f/f/b/ffbc1a968ad9f85fc8b8d3c27fdcef597df76230.jpeg)  
**caustic result with small aperture:**  
 ![result01](https://blenderartists.org/uploads/default/original/4X/7/5/c/75cd542cca03fac7d5fe1b3e6758ca52cb2a4b8d.jpeg)  
**caustic result with large aperture:**  
 ![result02](https://blenderartists.org/uploads/default/original/4X/4/a/0/4a0f3db842efcd64d9134fc23a5d3c8159d0d151.jpeg)

 ![result04](https://blenderartists.org/uploads/default/original/4X/c/6/7/c67d83915ca048e2b302238a9702e6784bef3b9f.jpeg)

 ![result05](https://blenderartists.org/uploads/default/original/4X/f/3/e/f3eeb2e0cf9afd9ed3bd19a756cc1e06f5a4f533.jpeg)

 ![Grasshopper](https://blenderartists.org/uploads/default/original/4X/d/8/d/d8d73538d3588347c6a5d486f19ed320987749dc.png)

---

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [March 17, 2020, 10:27am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/3 "2020-03-17T10:27:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![scyg](https://blenderartists.org/user_avatar/blenderartists.org/scyg/32/14040_2.png) [@scyg](https://blenderartists.org/u/scyg)\
**Post date:** [March 17, 2020, 5:21pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/4 "2020-03-17T17:21:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [March 17, 2020, 5:55pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/5 "2020-03-17T17:55:58Z")

</div>

just filling the time during quarantine… 😉

---

<div class="post-metadata">

**Author:** ![B.Y.O.B](https://blenderartists.org/user_avatar/blenderartists.org/b.y.o.b/32/1066063_2.png) [@B.Y.O.B](https://blenderartists.org/u/B.Y.O.B)\
**Post date:** [March 18, 2020, 12:52am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/6 "2020-03-18T00:52:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [March 18, 2020, 11:47am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/7 "2020-03-18T11:47:31Z")

</div>

sure! - here the scene: [dropbox link](https://www.dropbox.com/s/tb72igc5micxtiq/lensCookeB01_publish.blend?dl=1)

---

<div class="post-metadata">

**Author:** ![B.Y.O.B](https://blenderartists.org/user_avatar/blenderartists.org/b.y.o.b/32/1066063_2.png) [@B.Y.O.B](https://blenderartists.org/u/B.Y.O.B)\
**Post date:** [March 18, 2020, 12:21pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/8 "2020-03-18T12:21:07Z")

</div>

Which LuxCore version did you use to render this?

---

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [March 18, 2020, 12:24pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/9 "2020-03-18T12:24:39Z")

</div>

2.2 release… why?

---

<div class="post-metadata">

**Author:** ![B.Y.O.B](https://blenderartists.org/user_avatar/blenderartists.org/b.y.o.b/32/1066063_2.png) [@B.Y.O.B](https://blenderartists.org/u/B.Y.O.B)\
**Post date:** [March 18, 2020, 12:30pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/10 "2020-03-18T12:30:16Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![zohozer](https://blenderartists.org/user_avatar/blenderartists.org/zohozer/32/36537_2.png) [@zohozer](https://blenderartists.org/u/zohozer)\
**Post date:** [March 21, 2020, 9:42am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/11 "2020-03-21T09:42:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ManuelGrad](https://blenderartists.org/user_avatar/blenderartists.org/manuelgrad/32/979343_2.png) [@ManuelGrad](https://blenderartists.org/u/ManuelGrad)\
**Post date:** [March 21, 2020, 6:24pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/12 "2020-03-21T18:24:59Z")

</div>

Thats so nerdy … i love it!

---

<div class="post-metadata">

**Author:** ![alekba](https://blenderartists.org/user_avatar/blenderartists.org/alekba/32/1091976_2.png) [@alekba](https://blenderartists.org/u/alekba)\
**Post date:** [July 7, 2020, 7:05am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/13 "2020-07-07T07:05:09Z")

</div>

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 😃

[![](https://blenderartists.org/uploads/default/original/4X/8/b/1/8b15406ca02b9b0f2c41039ff7f4ddf9169e91b2.jpeg "Jeremy Cox @ SuperMeet 2018 | Down the Rabbit Hole - Adventures in C4D | Maxon Cinema 4D") ](https://www.youtube.com/watch?v=y8mKtNCq5CI)

second part

[![](https://blenderartists.org/uploads/default/original/4X/3/0/c/30c7a6869850422d8050a2c369c9af78fc874f7d.jpeg "Jeremy Cox @ NAB Show New York 2019 | Maxon Cinema 4D") ](https://www.youtube.com/watch?v=YhBUiAuhv-4)

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

---

<div class="post-metadata">

**Author:** ![SKworld](https://blenderartists.org/user_avatar/blenderartists.org/skworld/32/23068_2.png) [@SKworld](https://blenderartists.org/u/SKworld)\
**Post date:** [July 7, 2020, 8:15am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/14 "2020-07-07T08:15:12Z")

</div>

WOW , Unbelievable … 😃

---

<div class="post-metadata">

**Author:** ![jackhumbert](https://blenderartists.org/user_avatar/blenderartists.org/jackhumbert/32/711511_2.png) [@jackhumbert](https://blenderartists.org/u/jackhumbert)\
**Post date:** [July 13, 2021, 11:52pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/15 "2021-07-13T23:52:56Z")

</div>

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

 ![dispersion](https://blenderartists.org/uploads/default/original/4X/d/9/1/d918ed124cbd520087f5a366f505075c150e2ec4.jpeg)

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

 ![flare-off-screen](https://blenderartists.org/uploads/default/original/4X/8/f/6/8f67eabacc98bd97cee22e79aadb2e671fb97fd0.png)

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:

 ![flare-on-screen-diffraction-path-100000](https://blenderartists.org/uploads/default/original/4X/4/2/7/4273c92d2b345c5141ac20c4b6d9e3a59b170658.jpeg)

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!](https://www.dropbox.com/s/dqlza3gonfiol92/lensCookeB01_flares.blend?dl=0)

---

<div class="post-metadata">

**Author:** ![Sol\_Hunter](https://blenderartists.org/user_avatar/blenderartists.org/sol_hunter/32/540837_2.png) [@Sol\_Hunter](https://blenderartists.org/u/Sol_Hunter)\
**Post date:** [July 22, 2021, 3:18pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/16 "2021-07-22T15:18:45Z")

</div>

Really neat stuff!

---

<div class="post-metadata">

**Author:** ![siminon](https://blenderartists.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@siminon](https://blenderartists.org/u/siminon)\
**Post date:** [October 27, 2022, 8:02am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/17 "2022-10-27T08:02:02Z")

</div>

Just came across your project on youtube, really awseome stuff! I’m planning on something similar, but for freeform optics and this would be a great base to work on! Are you willing to share your rhino/grasshopper file? I already tried to replicate it from the video and the picture, but didn’t manage to do it completely…

---

<div class="post-metadata">

**Author:** ![Hellerkopf](https://blenderartists.org/user_avatar/blenderartists.org/hellerkopf/32/1100025_2.png) [@Hellerkopf](https://blenderartists.org/u/Hellerkopf)\
**Post date:** [March 22, 2024, 4:21pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/18 "2024-03-22T16:21:06Z")

</div>

Amazing work! Would it be possible for you to share the blend file of the scene again? - the dropbox link does not work anymore.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![daniel\_westlund](https://blenderartists.org/user_avatar/blenderartists.org/daniel_westlund/32/1472945_2.png) [@daniel\_westlund](https://blenderartists.org/u/daniel_westlund)\
**Post date:** [March 23, 2024, 11:30pm UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/19 "2024-03-23T23:30:31Z")

</div>

I love it! I ttoed something similar but not as organized as this… you can watch it here

[![](https://blenderartists.org/uploads/default/original/4X/3/9/5/395ccedf5631d950e1947959b42749b21a57ca29.jpeg "Camera Obscura") ](https://www.youtube.com/watch?v=w8d_qdKuwLs)

Best  
Daniel

---

<div class="post-metadata">

**Author:** ![Atair](https://blenderartists.org/user_avatar/blenderartists.org/atair/32/1297014_2.png) [@Atair](https://blenderartists.org/u/Atair)\
**Post date:** [April 28, 2024, 8:00am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/20 "2024-04-28T08:00:00Z")

</div>

here you go:

> **[lensCookeB01\_publish.zip](https://www.dropbox.com/scl/fi/mlc8438r83cexh6kwrir3/lensCookeB01_publish.zip?rlkey=8rfp8xixv7wsux5gzlqtl8o2d&dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![sergiomutis1](https://blenderartists.org/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sergiomutis1](https://blenderartists.org/u/sergiomutis1)\
**Post date:** [September 3, 2024, 12:10am UTC](https://blenderartists.org/t/virtual-lens-from-scratch-with-grasshopper-and-blender-luxcore/1213126/21 "2024-09-03T00:10:54Z")

</div>

Amazing work! I am particularly impressed by the grasshopper definition. I have been trying to design and prototype some custom cameras + lenses and this is very useful. Is there any chance you might be able to share the gh script for further study?
