Little Addon for optical lenses etc.

General project and community related discussions and offtopic threads.
CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 11:13 am

wasd wrote:
Sat Apr 04, 2020 11:26 pm
After attempt to recreate lens from image from the internet and inventing working! but not focusing on infinity lens system, I've discovered this:sca.png
Ther's button in edit tab which look like pair of red/blue eyes.
Just enter desired efl and get your new lens!
Ah, nice feature, thanks for pointing it out!

I can't see any of the images in your other posts. If I try to open them by link it says I have no permission to access your google files.

wasd
Posts: 314
Joined: Tue Apr 24, 2018 7:20 pm

Re: Little Addon for optical lenses etc.

Post by wasd » Sun Apr 05, 2020 11:30 am

CodeHD wrote:
Sun Apr 05, 2020 11:13 am
I can't see any of the images in your other posts. If I try to open them by link it says I have no permission to access your google files.
silly google

it's all here https://drive.google.com/drive/folders/ ... sp=sharing
CPU Bidir (sometimes GPU Path) + Metropolis | Log Power | Core i5-4570

CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 11:58 am

I see the problem in your test scene. Although there seems to be something else wrong, I have several issues with meshes being displayed.
One of the target disks looks like z-figiting surfaces, but there are no doubles, and the aperture looks different in object and edit mode.
And just now when I was playing around, I suddenly could only move objects in discrete increments. :?:

wasd
Posts: 314
Joined: Tue Apr 24, 2018 7:20 pm

Re: Little Addon for optical lenses etc.

Post by wasd » Sun Apr 05, 2020 12:02 pm

CodeHD wrote:
Sun Apr 05, 2020 11:58 am
I see the problem in your test scene. Although there seems to be something else wrong, I have several issues with meshes being displayed.
One of the target disks looks like z-figiting surfaces, but there are no doubles, and the aperture looks different in object and edit mode.
And just now when I was playing around, I suddenly could only move objects in discrete increments. :?:
aperture has shape keys
CPU Bidir (sometimes GPU Path) + Metropolis | Log Power | Core i5-4570

CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 4:19 pm

I can reproduce the problem with a simple test scene, only 1 lens, detector, and a laser light source that produces as focus spot.

In this simple scene, the focus spot grows gradually with increasing x-direction, and becomes vertically/horizontally striped in y/z-direction.
It is a bit worse with BiDir than with Light tracing. It has to be considered also that laser is effectively a point source so the spot I'm observing in the simple scene is really small.

So I would think this is some numerical precision issue. Not sure if this can be overcome, that would be a question for Dade.

In your scene with more complex setup, it somehow appears more sudden, at distances of 4m and then gets worse. Also, you are using multiple lenses , which might amplify the issue.

Side note: You can also start seeing the tesselation of the lens. Makes for some good abstract art though. Behold the holy floating-point :D
LensArt.png

CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 4:22 pm

what can help actually is upscaling the entire scene. With your own camera modelled, you're not dependent on obeying correct units to have DoF working.
However, this only works as long as your models of building don't run into upper limits.

CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 8:27 pm

I have been thinking a bit more. It makes sense that this happens. (Real) lens surfaces need to be shaped and polished very accurately for good optical performance. Kind of why made this addon in the first place ;)
So it makes a difference whether a vertex coordinate is 1.001 or 1.002. If you offset everything, e.g. to 61.001 = 6.1001e1, you have increased one digit of precision.

What we're observing seems to be consistent with 32-bit float accuracy, at least in terms of when significant changes to a lens mesh start to be visible, can't manually confirm a ray-traced image.
@BYOB, could there be any point in the blender2luxcore export where additional precision might be lost? I don't expect it to, just asking for ideas.

A possible workaround might be to
a) never apply transforms to lenses (the mesh keeps precision that way until export)
and then
b.1) either build a scene with the world origin at the centre of a lens system (easy to do for stills but not animations)
or
b.2) write an option for BlendLuxCore to transform all objects so that the camera is at 0 (automatic for every frame in animations).

User avatar
B.Y.O.B.
Developer
Posts: 3555
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Little Addon for optical lenses etc.

Post by B.Y.O.B. » Sun Apr 05, 2020 8:35 pm

CodeHD wrote:
Sun Apr 05, 2020 8:27 pm
@BYOB, could there be any point in the blender2luxcore export where additional precision might be lost? I don't expect it to, just asking for ideas.
Meshes that are not instanced will have their transformation applied, that's a possible spot.
Smooth shaded meshes will use the Blender vertex normal, which is an array of three shorts in Blender, so I guess it's at half precision (2 bytes instead of 4). I think you could circumvent that by using custom split normals (they are floats).

There could be other places, in Blender or LuxCore, but I'm not sure.

CodeHD
Posts: 297
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD » Sun Apr 05, 2020 8:42 pm

B.Y.O.B. wrote:
Sun Apr 05, 2020 8:35 pm
Smooth shaded meshes will use the Blender vertex normal, which is an array of three shorts in Blender, so I guess it's at half precision (2 bytes instead of 4). I think you could circumvent that by using custom split normals (they are floats).
Thats a good point, I guess the normals will be the important value anyways as the surface direction determines the refraction.
But (Blend)LuxCore doesn't suppoprt them yet, right? I switched back from splitting the edges to autosmooth because it prevented smooth shading from working.

User avatar
B.Y.O.B.
Developer
Posts: 3555
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Little Addon for optical lenses etc.

Post by B.Y.O.B. » Sun Apr 05, 2020 8:43 pm

CodeHD wrote:
Sun Apr 05, 2020 8:42 pm
But (Blend)LuxCore doesn't suppoprt them yet, right?
I have added the support in v2.4, you can use it in the latest daily builds.
viewtopic.php?f=5&t=9&start=730#p21203

Post Reply