Little Addon for optical lenses etc.

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

Re: Little Addon for optical lenses etc.

Post by CodeHD »

Finally had some time to continue. First addition: Material textbox as suggested by B.Y.O.B. (thanks!) together with checkboxes for smooth shading and adding an edge-split modifier.

The material must be pre-defined on some dummy object. It does not work to create a lens/mirror, add a material to it, rename the material and then enter the name in the textbox. (It only works if the material is called "Material", because Blender will automatically rename it in this case :D)
CodeHD
Donor
Donor
Posts: 437
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD »

I just updated this addon to work with 2.8.
No functional changes yet, aside from expanding the readme, but I now want to continue adding more surface types or even the option of dynamic changes discussed before (If I can manage that ;) )
wasd
Posts: 319
Joined: Tue Apr 24, 2018 7:20 pm

Re: Little Addon for optical lenses etc.

Post by wasd »

That's what I've wanted to make! It's great that now I don't have to ;)

And here's my opinion

1. Blender (2.79b) crashes when N1 goes below zero, so I'd add min parameter equal to at least 0

Code: Select all

  
           num1 = IntProperty(
           name="N1",
           default = 32,
           description="Number of radial vertices",
           min = 3
           )

2. With unit parameter, input field would accept and display length units:

Code: Select all

    
           lensradius = FloatProperty(
           name="Lens Radius",
           default = 3.,
           description="Lens outer radius",
           unit = 'LENGTH'
           )
opti.png
3. With edge split object will be exported as 3 separate meshes, right? What would happen to volume?
CPU Bidir + Metropolis | Core i5-4570
CodeHD
Donor
Donor
Posts: 437
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD »

wasd wrote: Sat Feb 29, 2020 6:03 pm And here's my opinion
Good suggestions no. 1. and 2. ! I will implement that.

Regarding no. 3, so far I have not observed any problems, but that doesn't mean thee will never be any ;)
Good reminder though, casue I wanted to try making my own edge-split for this. The blender default has the issue anyways that it stops working at shallow angles. Not sure it works though without breakign the mesh... I will try.

Edit: Nope, not quite that easy :D
CodeHD
Donor
Donor
Posts: 437
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Little Addon for optical lenses etc.

Post by CodeHD »

I now updated the module with the suggestions from wasd. Edge-plit was replaced by split normals. Apparently edg-esplit is now deprecated anyways...

Furthermore, by request of a GitHub-issue, I already included a first version of aspheric surfaces on lenses, and mirrors can now include a central hole along the main axis.

As a funny side-effect, which I noticed while testing, you can use it to model syringe-needles :D
syringe.png
wasd
Posts: 319
Joined: Tue Apr 24, 2018 7:20 pm

Re: Little Addon for optical lenses etc.

Post by wasd »

You can also make earth (and other spherical bodies) surface with this. I also think that option to make lens horizontal (with it's axis along z axis), square-shaped and square-divided would be great addition!
With just a few clicks I made this disk section of earth, with 20 km diameter.
Look, with camera at 0.5 meter above the ground, the truck that's 6 km from camera is half beneath horizon! Other one, which is closer isn't beneath.
earth_trucks.png
    If it's flat plane, both trucks would be fully visible.
    earth_trucks_flat.png
    CPU Bidir + Metropolis | Core i5-4570
    CodeHD
    Donor
    Donor
    Posts: 437
    Joined: Tue Dec 11, 2018 12:38 pm
    Location: Germany

    Re: Little Addon for optical lenses etc.

    Post by CodeHD »

    wasd wrote: Fri Mar 06, 2020 10:57 pm I also think that option to make lens horizontal (with it's axis along z axis), square-shaped and square-divided would be great addition!
    The rotation (and translation) parameters are currently missing from when I switched to a custom draw method, but that is provided by Blender and will be back.

    By square shaped, do you mean like, for example, a single element of such a micro-lens array?
    https://www.nilt.com/wp-content/uploads ... m137tu.jpg

    And square-divided? Do you mean D-shaped lenses like in this cross-section model? I already have plans to implement those.
    crossection.png
    The truck behind the horizon is a nice touch ;) You could take a ship instead and add it to the sunset scene from the other thread :D
    wasd
    Posts: 319
    Joined: Tue Apr 24, 2018 7:20 pm

    Re: Little Addon for optical lenses etc.

    Post by wasd »

    CodeHD wrote: Fri Mar 06, 2020 11:34 pm And square-divided? Do you mean D-shaped lenses like in this cross-section model? I already have plans to implement those.
    I mean like cut-out of uv-sphere.
    square.png
    square.png (10.99 KiB) Viewed 6858 times
    Maybe I'll do it myself.
    CPU Bidir + Metropolis | Core i5-4570
    CodeHD
    Donor
    Donor
    Posts: 437
    Joined: Tue Dec 11, 2018 12:38 pm
    Location: Germany

    Re: Little Addon for optical lenses etc.

    Post by CodeHD »

    I added a square lens. Have a look if thats what you wanted.
    It is perfectly square now, so not exactly like a u,v-sphere cutout, which would deviate a lot for strongly curved surfaces.

    However, the square surfaces at the moment are not perfectly defined, because I used quadrilaterals, and in this case not all vertices lie in the same plane. I will see what is the most elegant way to define surfaces elements... Shouldn't be much of a problem for most use cases though.

    On a side note, I also fixed a problem with the mirrors for focal lengths < 1.
    Attachments
    sqlens.png
    CodeHD
    Donor
    Donor
    Posts: 437
    Joined: Tue Dec 11, 2018 12:38 pm
    Location: Germany

    Re: Little Addon for optical lenses etc.

    Post by CodeHD »

    I now optimized the mesh geometry of the square lens, and added a cross-section view option (D-shape) to the regular lens.
    Attachments
    DLens.png
    sqlens_tri.png
    Post Reply