# Is it possible to change the field of view for a cube camera?

Hi Friends!

I wonder if there is a way to change the field of view (fov) for the cube camera. Unfortunately I have some lens curves in my scene and I could solve this with a different value for the field of view. However as far as I know the fov is not possible to set for a cube camera, but there should be an alternative work around.

The CubeCamera views everything in all directions, it has no field of view angle like a PerspectiveCamera. I’m not sure what it would mean to do have “lens curve” on a cubemap, can you share in more detail (images, demos, etc.?) on what you are hoping to do?

1 Like

I will share my project as soon as it is online, then you can see what I mean. At the moment I need to solve an error to be able to deploy the pooject.

Here is a example of the lense curve effect, it is basically a distortion at the edge of the scene, like in this example:

On the left image you can see the distortion and on the right image it is without distortion. I have this distortion in my scene and usually this can be solved with the field of view parameter, but how to solve this without the field of view parameter for the cube camera?

The cubecamera uses 6 cameras at 90 degrees each to cover 360 degrees, so if you changed the FOV (reducing it to reduce distortion) it would create gaps in that spherical view -so to answer your question it’s not possible.

The only way is via a special shader pass for each camera, either pre or post processing, so searching for something like that (or develop it yourself) is the right direction towards a solution.
In other words, you need a custom solution.

1 Like

depending on the material you are using, you can,

• Set the CubeRenderTargets `texture.mapping` to `THREE.CubeRefractionMapping`
• modify the `refractionRatio`

example : CubeCamera Refractions (sbcode.net)

1 Like

For the sake of using a unified lingo, lets replace some words with common terms:

here you are refering to the camera frame for projecting the scene, the scene is not deformed but the projected image on a plane (here the camera sensor). You are talking of a distorion at the edge of the projected image.

This effect is not a distorsion in the sense of a form of geometric aberration (like lens cushion/barrel distorsion), but actually the way in which perspective vision beheaves based on the pinhole camera model, see this for a detailed explanation.

Perspective cameras in three.js actually asume the rectilinear projection, which
“renders all straight lines in the subject as straight lines in the image”. That means that, as with a real camera, every image obtained is ruled by this “effect”. In order to make the effect less noticeable you can narrow the fov value, but the effect is there anyways because it’s the way in which the image is produced in the first place.

Asuming the original image is on the left, on the right you see a “corrected” image, in which the rectilinear projection was actually deformed to diminish the effect. As @dllb is suggesting, you could address this correction using a dedicated shader solution, but keep in mind that it will end up bending the straight lines (so you loose the strict linearity that the rectilinear projection offers)

1 Like

@Antonia Special thanks for taking the time to explain the effect and correct explanation. I really apprechiate everything I can learn to get better.

@seanwasere I dont use any material, I am just using a cubmap. When I look at the example I recognize that there are also a distortion at the edge of the projected image.

@bllb Do you know a tutorial on how to learn to create a shader pass for each camera?

thanks to you @nkzmi , we are all learning from eachother here

before going any further: you are looking for how to correct the distortion on the projected image, not for each camera whitin the cubeCamera. Remember that the scene is ok, so what this 6 cameras are capturing is ok too. The distortion effect is taking place inside the perspective camera lens that is actually rendering the scene on the screen, and this is the place for you to make some adjustments.

The way to go is using a shader pass. I would recommend reading the official guide on how to use post-processing in three.js. There is a plenty of very usefull passes, you are looking for one that allows you to cancel some sort of geometric aberration. Depending on your specific use case, this probably would be addressed with a radial distortion pass. Here there is one that you could just plug-n-play, the demo is very self-explanatory. Let us know if this approach suits your needs.

Maybe in this case you could somehow display the image as the background with some translation that depends on the camera position.

I.e. instead of affecting the texture with projection matrix and then trying to correct the deformation, apply original image to the canvas. Probably would require a custom shader or render the image with an ortho camera instead.

I still don’t understand why this is needed on a cube camera? It won’t be a cube if one messes with the field of view.

the scene is ok, so what this 6 cameras are capturing is ok too.

At 90 degrees FOV for each one of the 6 cameras, it’s hardly “OK”, there is always significant linear distortion towards the edges.

The worst non-linear distortion will be when one is looking at a corner of the cube, or at an edge, getting asymmetrical distortion that changes at every angle change, so it can only be corrected on each one of the cameras. ̶I̶ ̶h̶a̶v̶e̶n̶’̶t̶ ̶v̶e̶r̶i̶f̶i̶e̶d̶ ̶t̶h̶i̶s̶ ̶i̶n̶ ̶p̶r̶a̶c̶t̶i̶c̶e̶ ̶r̶e̶c̶e̶n̶t̶l̶y̶,̶ ̶s̶o̶ ̶p̶e̶r̶h̶a̶p̶s̶ ̶I̶’̶m̶ ̶m̶i̶s̶s̶i̶n̶g̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶,̶ ̶b̶u̶t̶ ̶I̶ ̶d̶o̶n̶’̶t̶ ̶t̶h̶i̶n̶k̶ ̶s̶o̶.̶

On a second thought, I’m sure this is true.

One has to make a sphere with a high-res evenly spaced tiny dense dots texture and put the cube camera inside, make a reflection map, apply it to another sphere and look around that second sphere to verify those distortions. Or project each of the 6 cameras on each face of a cube and look inside with another camera at the corners, or the edges.