OptiCore + LuxCore Lens System Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial i want to show you how to set up a model of an camera lens in blender using the optical add-on to create the lens models and to render an image with this camera lens with the lux core render engine now camera lenses in general are quite a complex topic there's a lot to talk about lots of different designs that you could show lots of optimizations or limitations to the rendering technique but in this video i just want to focus on a simple lens model to show you how to set it up in lux core and how to get to the first results and what you can see here is an example scene of roughly what it's going to look like in the end to give you an idea what you can expect but we're going to set this up from scratch and first of course we need a lens design that whose parameters we can use to set up our model and one option where you can get such parameters such lens designs from is the free software wind lens which is available from the optics company key optic and it offers all the basic um features that we need like viewing the lens specifications and viewing some performance charts which we can also use to compare our model in blender and to see if what we build actually works and also keyoptic offers a free lens library with a lot of different designs um yeah that we can that we can use and build on and i've already downloaded both wind lens and this lens library so first i want to open this and show you what it looks like that we have in there so wind lens i'm going to go straight to opening a lens file and in the windlands library there are some examples as well as library lenses and they are diff they are grouped into different designs like double gauss lenses which are standard and widely used design type for prime lenses there are laser focus systems there are zoom lenses which are quite complex and what i'm going to use here today triplet lenses and i'm going to use the triplet number five because it's going to be a good example and the first thing that opens is a drawing of the lenses so triplet it has three lenses and there are some basic parameters it just tells us here in the description triplet with an f number of three and a horizontal field of view of 24 degrees and the object focus here or the focus of this lens by default is set to infinity now in the plot we can also go into drawing options and add in the image plane so we can see also where our detector will need to be where the image is focused and more important under tables we find a table of surface specifications and this is how lenses are typically specified in terms of a sequence of surfaces so surface number one will be the front surface of the first lens surface number two the rear surface of the first lens surface number three the first front surface of the second lens and so on as well as the image plane and also not very easy to see here just behind the second lens maybe i can zoom in for you there are some little red dashes here which is an location of an aperture stop which also we are going to want to model in blender and for each surface now there are several parameters that we will also need so firstly of course the surface radius of the radius of curvature of the surface in this example all the surfaces are spherical we are not considering aspheric elements here then there is a separation which basically gives you the thickness of the lens so for the first surface the separation is then the distance under a central axis from the first surface to the second surface then next follows here in the glass column the material that follows after the surface so for the first lens this is a glass type called sk4 made by shot with a refractive index of iss 1.62 if we click on it we get some more numbers at different wavelengths and more accuracy i'm not going to consider chromatic aberration in this video so i'm just going to use the value at 546 nanometers so next there would be the other number which indicates dispersion but as i said we're ignoring that and there's also the half aperture here so which would be the outer radius of the lens to give us its total size and this is specified for all surfaces from surface to surface including the aperture stop and the finally the distance from the last lens to the detector that we're going to need and these settings we're going to now take and copy over into blender and for that first we need to set up a dummy scene i'm also going to limit my window here to the right half of the screen so i can have it side by side with blender so i'm going to create an empty scene just doing this quickly before shrinking blender now i'm going to just delete everything and choose lux core first of all also i'm going to save this file in case i get any crashes we're going to start out with the cpu render engine and in the world tab i'm also going to deactivate the skylight which is set by default now before we actually get to the lenses um i first want to start preparing and setting up the materials so i just create a cube which i'm going to call material dummy i'm going to create myself a second screen where i'm going to have a material node editor as well as a volume node editor now i can start adding materials to my material dummy so first i will add a glass and in the surface sheet here in wind lens we can see the glasses we are sk2 we have f2 and then sk4 again so we'll need two glasses sk4 and f2 so we're naming the first one sk4 and just adding a second glass call that f2 now we're going to specify the glasses with interior and exterior volumes which for the simple lens is not strictly necessary actually we could just use the ior setting here but it's maybe good to do it anyways because in another video i will show achromatic dublin lenses this will be important to have it using volumes so first we need a world volume just going to go to the world tab and just add the default word volume it'll just be clear volume with ior of one so that's exactly what we need so in our material let's start with sk4 we can then just add a pointer to the word volume and assign it as the exterior volume of this and then i'm just going to add in a second new volume i'm going to name that sk4 vault just to keep track of it and now i'll open up here my detailed view of refractive indexes and copy in the value for 546 nanometers which is 1.615212 the precision of that will probably be cropped by blender but that won't matter for us and then i'm going to the f2 material and repeat so first the world volume the exterior volume and add a new volume call that f2 vol and open up my refractive index info again and at the quite similar value of 1.62408 1. i'll just make sure to save and double check actually here we have sk4 wall with 1.615 and f2 has f2 wall with 1.624 okay so this is the setup of the glass materials while we're at it with the dummy materials i'm actually going to add a matte material for the detector which i'm just going to make fully white and i'm going to add another matte material call it black and just make that perfectly black so those are all the materials we will need for now so i'm going to go back into the 3d viewport i'm going to just make my material dummy invisible i will go into side view and from there we can start adding the lenses so on a mesh optical optics i'm going to add a lens open up the parameters and i can start off now with the separation which will be the center thickness of the lens so i'm just going to work here instead of units of meters and millimeters and i'm just going to enter a value of 6 and then the aperture of this radius will be 16.7 so that's here lens radius 16.7 so this is now rather large now the first surface radius is 40.1 and the second surface radius is -537 since the last video i made um the first introduction video to opticor i mentioned that there's a convention with positive and negative surface radii i have since then changed the convention for the second surface so that you can really copy one to one the surface radii as they are given in a lens design software and we don't have to worry about these signs anymore okay so that's the surface radii it's the lens radius the lens center thickness are set just now we need to assign the sk4 material which we can do also here in the opticore specifications because we have set up the material dummy and that's the first lens setup now we're just going to add a second lens and first of all we will want to shift it to the right location so for that we need to add together the separation of the first lens and the air gap and here i'm using a negative direction so it will be -6 minus 10 for me so the aperture of the second lens is 14.9 bit smaller its center thickness is one the material before i forget this is f2 surface 1 has a radius of -47 and surface 2 has a radius of plus 40 and we can go into a wire view to check that this looks basically as we expect so that's the second lens setup save now just let's go straight to the third lens which i'm just going to switch back immediately to sk4 material now we again have to add up some numbers minus 6 minus 10 minus 1 thickness of the other lens minus 3 for the air gap to the aperture stop and minus 7.8 for the air gap to the third lens the radius of this lens is 15.1 its central thickness is six material we have set and the first surface has a radius of 234.5 and the second radial surface has a radius of minus 37.9 and again this looks in comparison to the wind lens drawing as you would expect so i can again save and thus i have concluded the setup of my three lenses but hopefully i have not made any mistake so what do we do next next we can set up our detector so for that i'm just going to add a plane let's call that detector um i'm going to look now the image here has a radius it's quite wide of 42. let's round it up to 45 and double that for the entire width so let's make this just 90 large add the detector material rotate it into the right orientation and again i need to add up a lot of numbers for the location so it's -6 minus 10 minus 1 minus 3 minus 7.8 minus 6 and finally minus 84.93 and now additionally i'm not quite sure why this is done there is an additional distance going back minus 0.3 millimeters from the last specified surface here um to the actual focus plane i'm not quite sure what this convention is for but we need to add 0.3 again for comparison later with other figures from wind lens that we're going to look at now going to top view i'm going to add a camera make it larger so we can see it so rotate it into the right orientation and just move it somewhere in front of the detector going to make the image square because so is the detector at the moment and i'm going to make it an orthographic camera which i recommend for this and for now let's leave the orthographic scale at the default value we'll be changing that in a moment anyways so detector setup camera setup lenses are set up now we will need a aperture this one i'm going to create based on a circle let's make it round and it has a radius of 13.17 so we're going to do that i'm actually going to add another circle in with a radius of 20 a bit larger join the two bridge the edge loops take all the faces extruded a slight bit to make it solid let's make sure the surface normals are correct and assign the black material and we're going to have to put that in the right location as well so again some number adding 6 10 1 and -3 to give the right location of the aperture stop and we can just check in the side view it's now just slightly behind the second lens which is consistent with what we see in wind lens so aperture is also in place and with that setup we can actually start testing our lens to see if it works and performs as we would expect for this we will need a light source and to test it um i'm going to create an area source and make it a laser which is going to give us a parallel infinite light which is good to compare with the wind lens parameters now we want to just roughly under fill the front aperture so radius of 16 should do double that up would be a size of 32 that's a laser now to see an image i'm just going to activate auto brightness to find it first and for the laser we will need light tracing 100 because path tracing doesn't make sense with the laser and we can hop into the uh and uh i almost forgot to often forget about is we need to increase the total path depth to make sure that we get enough specular bounces through the lenses so we can hop into our camera view just limit the field of view a little remember this is now six wide because we've kept the default orthographic scale and let's hope there was no mistake if i go into rendered view we see a spot rendered at the center so i'm going to just reduce the scale orthographic scale of 1 is still more than we need 0.5 let's go to 0.4 for now and i can reduce the gain a bit to 0.1 you see this spot looks actually a bit fancy there of course some limitations of the 32-bit floating point accuracy we can expect from blender but well that's just what it is but at a scale of 0.4 we're getting some spot but how do we know that this is actually correct well we can compare again with wind lens since we have it and check the spot diagram which it offers so wind lens now offers us this spot diagram for in focus out of focus forward and backward and different field angles now the different colors are overlapped here so i'm going to just select the mid wave in green and it's the in focus on axis here in the top middle that we will want to compare to now we need to also check the scale of this which is currently set to a half scale of 0.1 so i'm going to double that up to 0.2 for comparison with our image and then i'm just going to squeeze the screen a bit to make it square and zoom in to get a good comparison with what we see in blender this is a bit large so we can reduce our image here put them side by side and you can see well wind lens only creates certain ray fans so it's not a full fully filled image but our image our focal spot is roughly the same size as what we see here in the spot diagram in wind lens so this actually confirms that our camera model in blender seems to work i could now go also through the different off-axis angles or out-of-focus angles to compare the shapes i'm just going to for time reasons not do that now you can try this yourself if you want to just rotate the laser around the entrance aperture and then you can check find the focus location on your detector and compare but just for now for demonstration i would like to show a bit more complex image before we close this video so before i forget i'm just going to increase the autographic scale to just slightly less than the detector i'm going to delete the area source and for purpose of um yeah avoiding stray light here we're going to need to make ourselves a little a little lens box because we're going to render an image of an hdri in the background so i'm going to just copy the aperture put it at the origin accidentally gave it a z shift so it's a bit smaller than the first lens but actually we're going to ignore that for now then what else will we need we will need to probably make the outer rim of this a bit larger to cover it up at the front and then we can make ourselves i would say for now we do use a hollow cube just make that rather large duplicate it shift it slightly forward and a bit smaller then we can use boolean operations on the cubes let's delete the inner cube and see if that worked yeah now we have some open box here you can actually make a bit longer in x direction we're also going to give this the black material let's go back into side view make sure this is over our detector actually now we'd have some gap here with the disk i just realized so i'm maybe just going to shrink it down a bit and yeah so just so we have a um quick black box and some apertures set up around our detector and then we can open an hdri image i've already just downloaded some yesterday which we could use some 8k image should be large enough for this purpose here and also we will need to switch back from light tracing to path tracing for this and let's go into render view and hope that everything worked out oh yes i forgot i've got the optics viewport denoiser on i actually don't want that now now the image doesn't render out very fast um right now but we can already see something builds up so let me switch back and change to gpu rendering because that will make it a lot faster let's just use a bit smaller image resolution for now to just quickly as a demonstration get a rendering and you can see an image of the landscape which is here a beach and some trees actually forms and yeah let's wait for the 10 second refresh yeah so brightness adjustment got a bit dark yeah our camera lens actually renders an image of the hdri and you even see right now with the default orientations um that the image is flipped upside down as you would expect from a camera lens so this is my first video on how to set up a full camera lens so you have seen that we will need to reach the lens parameters from a lens design file surface by surface create the lenses and blender accordingly with opticor we have set up a detector as a plane with a matte material and an orthographic camera in front of it depending on the lens design at some point um we will need an aperture stop um and then i've built a simple black housing for the lens to avoid straight light on the detector and then we were able to render an hdri image successfully through the lens and in upcoming videos i will go into more details like more complex lens design give a bit longer example and performance of that with also achromatic duplets how to set those up where two glasses are fused together and then i will also talk about different uh performance aspects of this so obviously such a lens will not render as fast as if you use an ordinary blender type or looks corender type camera but yeah how to perhaps optimize this and what you will be what you can expect of this
Info
Channel: HowToPrint
Views: 1,652
Rating: undefined out of 5
Keywords:
Id: 3hln88ukiZI
Channel Id: undefined
Length: 25min 32sec (1532 seconds)
Published: Sun Sep 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.