Lens simulation

I’m currently working on designing some optics for a project, is there anyway you can share these debugging 2d raytracing tools? I tried bodging something together in geonodes, but I couldn’t quite get it working.

Very cool work you’re doing here, btw.

Thanks!

You can add me on discord heinzelnisse#5900, I can send you the file there and explain how it works :slight_smile:

Added a focus aid system, not physically accurate to the real version I found, but the principle is the same.



Reference:
image

7 Likes

This project is very cool. It reminds me of http://www.lentil.xyz/ for Arnold, which I imagine would be interesting to you if you aren’t already familiar with it, considering it has been opensourced.

Ohhh… So beautifull!!!
That gave me the urge to get my A-1 from the closet! :smile:

I have a Canon AE-1 with a very similar viewfinder / focusing aid. There’s something special about optical tools built into the camera for testing focus.

1 Like

I also have a AE-1, but the A-1 is my favorite. :slight_smile:

1 Like

Thanks peeps!

@imacamel I have implemented some of the lenses it uses, but I have not looked at the source code, that’s a bit more advance for me. It looks amazing, would be cool if somebody implemented it for blender :slight_smile:

Incredible testing results.I wonder if we could have lens presets like these.
That would add huge amout of realism to the renderings.
I guess a hardcoded lens simulation would be even faster,maybe if a dev has some time.

Ok, but how much of a render penalty are you willing to accept? 2X? 4X? 10X?

1 Like

You mean speed wise?I dont know tbh.For still renderings i think its not that important.If we could choose a realistic lens setup optional or the faster default setup would fine i guess.

I wonder how other meantioned engines handle its lens setup and how much its slows down.

@Heinzelnisse
How would look a lens system of the human eye? The human eye has only one flexible lens.Would the depth of field looking more realistic?

1 Like

I guess as @SterlingRoth mentioned in another thread, having an OSL camera in Blender would help speed things up considerably.

@Midphase From my experience with OSL in blender just enabling OSL in blender will slow down the render time, the scene below slowed down with 66%! OSL needs a lot of optimization at this point to work well. I don’t know if an OSL camera will fix this issue, so I’m not super optimistic about a implementation. I think a hard coded lens in the source code would be the fastest and easiest thing to do at this point.

I did some render tests comparing speed with different lenses. 4096 samples, 0.01 noise threshold. 2538x1080px

Default camera: 00:50.49


Canon Serenar: 01:22.42

Kodak Petzval: 01:14.71

Anastigmatic Anamorphic: 01:45.74

Time limit 10sec. From left to right: Default camera, Canon Serenar, Kodak Petzval, Anastigmatic Anamorphic

The render speed varies a lot due to how complex the lens system is, but I think the less complex lenses this is usable for animation. In general, 70% of the time spent rendering is cleaning up small noise in the out of focus areas, which can be cleaned up with good denoisers.

WIth my node setup I think a lot of render time is wasted on rendering rays hitting the side of the lens. I haven’t found a way to cancel the ray in material nodes, like a break function in python. This can easily be done in a OSL shader among other optimizations.

@pixelgrip That would be cool to implement! I did a quick google search and it seems like the human eye is documented well, I will implement it when I get time for it. Not sure if focusing will work out of the box… I have not implemented a system to squeeze the lens optics…

4 Likes

Is your file available to test or will this be an add-on on BlenderMarket? What is your plan with this?

You can contact discord.

Sent request!

@Midphase
Its not publicly available jet, I’m planning to make it into a add-on on BlenderMarket. I have not fully planned it out jet, but I have an idea how I should do it.

I think I will add a free version with the OSL shader, the code is depreciated right now, due to OSL limitations but its great to visualize and debug lenses. I’ll might also add a light version with the actual lens setup I’m working on now, this will include some spherical lenses and basic features.

The paid version will include everything, lots of lenses( mostly spherical, some cylindrical and a few aspherical), automatic focusing with distance as input (quite tedious to calibrate), chromatic aberration, focus aid, custom focal length, (tilt shift?), etc.

I want to make a robust setup with a wide range of lenses that is easy to use. I don’t want it to be too expensive, but it has taken quite a while to make. Seems like the price range on these things varies from 5-30$.

5 Likes

Seems like a good plan. I think it might be a good idea to also let people know how much your lens set up affects render times. For still images it might not be that important, but for those like me who primarily work with motion and animated scenes, it can be a substantial deal breaker.

1 Like

Do you plan on implementing lens imperfections to simulate things like bloom, dirty bokeh, and lens flares?

@Midphase Yeah, if I’m going to sell it I need to be transparent of what I sell, that is important to me. There are some other caveats with this setup too, a lens behaves like a real lens, so its important to have the right unit scale in your scene and think like a photographer while you make your scene, not just place the camera afterwords and think it will always work.

@Indecom4000 That is the plan :slight_smile: I don’t want to slow the render down too much by implementing too many features, but if it works to make it optional without slowing things down I will look into implementing some effects. I’ve done some tests with bloom, so that is quite easy to do I think. Dirty bokeh should also be easy to do. Raindrops on the lens etc would also be cool to implement.

I wont do lens flares unfortunately, that’s out of scope for this setup, and its not really practical to ray trace lens flares in cycles right now. That would require a light path tracer, like luxcore. Land Hooman has an amazing setupfor simulating lens flares, so using his setup would be a good way to do it if you want realistic lens flares:

3 Likes