Fisheye, or wide angle lens equivalent

Started by CWR63, May 10, 2017, 01:24:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CWR63

I somehow can't respond to other threads, so I'm creating this one.

When rendering interior spaces using a wide angle lens setting in Keyshot, I run into the bane of 3D rendering, parallax distortion; everything is straight lines as opposed to the curvature distortion added by the eye or camera lens.

https://michaellord.me/2014/05/26/when-the-camera-is-just-not-enough-solidworks-photoview-360/

This ancient (I used this technique last century) manner of simulating a more natural wide angle render is the only way to get this, it would seem - even 20 years later. There was a rendering add-on for 3dsMax called Brazil from Blur studios that allowed you to see this distortion in the viewport before render, but that was years ago. 

There's not much call for this, (mostly users want it for creating environment spheres/VR bubbles) so I doubt it will ever be added to Keyshot.  :(


Will Gibbons

Quote from: CWR63 on May 10, 2017, 01:24:31 PM
I somehow can't respond to other threads, so I'm creating this one.

When rendering interior spaces using a wide angle lens setting in Keyshot, I run into the bane of 3D rendering, parallax distortion; everything is straight lines as opposed to the curvature distortion added by the eye or camera lens.

https://michaellord.me/2014/05/26/when-the-camera-is-just-not-enough-solidworks-photoview-360/

This ancient (I used this technique last century) manner of simulating a more natural wide angle render is the only way to get this, it would seem - even 20 years later. There was a rendering add-on for 3dsMax called Brazil from Blur studios that allowed you to see this distortion in the viewport before render, but that was years ago. 

There's not much call for this, (mostly users want it for creating environment spheres/VR bubbles) so I doubt it will ever be added to Keyshot.  :(

Good question! Maybe if we implement some more physical camera controls in the future. As of now, you can do this in a couple quick clicks in Photoshop using the lens correction settings.

CWR63

Well, I figured I should try to implement the 3d lens method in KeyShot and show the results. After seeing your reply I also went back and did versions using lens correction and spherize filters as well. Making 2D distortions yields a result that looks like a distortion of a 2D image and also kind of defeats the purpose of rendering scenes in 3D in the first place. However, this scene does not really demonstrate my point very well, and I will add more examples soon that illustrate this better. This is the scene without the physical lens in the scene, by which I mean that I created the composition with the fisheye and then simply hid the lens object:



I created this from an existing KeyShot scene (I have Zbrush Keyshot Pro and didn't want to do a lot of modeling just to see if this would work) and so I added a sphere and scaled it down on one axis to form an approximation of a lens shape. Since the add geometry sphere in KeyShot is a polar sphere, I turned it 90 degrees to the camera's z axis, figuring the denser, smoother polar topology would work better for a lens. So the X and Z axis were about 28 times the size of the Y axis, and the fisheye distortion was adjusted using the material's refraction index, in this case 2.36. The material was where it initially seemed to all fall apart - using either Glass(Solid) or Glass with 2-sided turned on had identical results BTW - but although the PBR allowed WYSIWYG (yay!) the reflective properties of glass meant big ol' specular patches all obscuring the scene. So Plastic (Transparent) needs to be used. Diffuse, Diffuse Transmission, and Specular all need to be 0 0 0 black, Specular Transmission is full white, Roughness is 0, and the Refractive  Index is how you adjust the distortion of your fisheye. Thinking about it now, you could probably invert the fisheye by making this number negative, but I never had it below 1.45:



Although the use of Plastic (Transparent) material had no unwanted reflections, it did dim the scene slightly as any lens does in the real world; the real drawback is not visible - no alpha, normal lighting, depth or clown renders...the lens object blocks them all. This does limit a lot of post tricks I use on KeyShot renders. Plus, aligning the lens object with the camera's Z axis using geometry view is quite tricky since the numeric position, rotation and scale controls are only global and the move tool is the only option to move an object on it's local axis. There's no way to link or lock an object to a camera, so it would rather labor intensive if the camera needs to be moved.

So here's the reason I need to redo this demonstration - these are the 2 versions using 2D distortion post work. Because I was trying to keep both figures in frame it really wasn't a scene for the fisheye effect, which is better suited to a central figure or object using deep perspective:


Lens Correction


Spherize

When using a fisheye lens in a 3d scene, shapes pile up on one another and obscure things in a way that 2D distortion just doesn't, which I hope to show in a further reply.

Will Gibbons

If you model a lens correctly and apply a refractive glass material to it and place it between your camera and your scene, you will get the effect you're seeking.

CWR63

I modeled 2 lenses, a dual convex and a dual concave. It took a LOT of prep, which I don't have time to recount now, but I will if anyone has an interest. Here are the results:

Scene sans lens:


Single convex (placed camera inside dual convex lens):


Dual convex lens:


Single concave (placed camera inside dual concave lens):


Dual concave lens:


A version made in 3dsMax 5 years ago:


For comparison.

LayC42


CWR63

The results are pretty satisfactory, the preparation was a bit rigorous.

The finished product shows the overall dimming mentioned previously, and noticeable artifacting on edges. For the pro side, you do get to see the lens distortion in the viewport prior to rendering, unlike the 3dsMax fisheye plugin, in which you wouldn't know the result until render - and didn't allow rendering inside the lens circle; making an off-center composition as shown in KeyShot would mean a render 4 times as large.

Because I couldn't link the lens to the camera, everything in the scene had to be oriented to the camera view in Zbrush. I modeled the lenses perpendicular to the front view so that they would always be aligned to a standard camera in KeyShot. This way, distance and lateral placement could be easily adjusted, but the impossibility of aligning angles to match between lens and camera are avoided. Arranging all the objects composition in Zbrush is difficult because it has the oddest perspective view I've encountered in a quarter century of working with 3D programs. Plus, Zbrush has problems importing .obj files with their UV mapping intact (not the function of the software, I know), so I had to find a building model that would accept KeyShot procedural textures unless I felt like learning hard surface architectural modeling just for this test (I didn't).

Also, the lens models need to be geometry edited in KeyShot (surface normals to 12 or 24) or they won't work as lenses - too faceted. If there is too much subdivision applied in Zbrush it produces obvious wrinkling at the polar point of the sphere that the lens is made from - in the center of the frame.

The result is good, but having to lock down the camera and move your meshes around to compose your scene? I won't be using this much. Plus, animation is totally out of the question...