Rendering two different scenes with different camer's fov

I have two scenes,scene1 and scene2 I want to render the scene1 with the camera’s fov set to 1 and scene2 set to 75.

One way is to create two cameras with different fovs and use them to render their respective scenes. You can also use the same camera and change its fov forth and back between rendering the scenes, don’t forget to call .updateProjectionMatrix() after assigning fov the new value.

3 Likes

do you want both to display in two views like in this threejs example three.js examples

This will cause an issue of z-fighting in rendering.
I tried it, but still not sure if I set the camera’s settings correctly.
if there is an example for this way, can you please drop it

I’m not sure what you’re trying to do with these two scenes if you have a z-fighting issue, can you show an example?

Z-fighting is a problem that might occur when pieces of geometry inside a scene have similar distances to the camera, it’s not an cross-scene issue.

I initialized two scenes with two cameras. camera1’s fov is 75 and camera2’s fov is 5.
in the render function, I set autoClear to false, then I rendered these two scenes

after I set the same position to the cameras the issue was gone.
I think it’s cameras position

I believe these two scenes share the same depth buffer. The depth of each mesh depends on their respective camera positions, so at some combinations of camera positions, the cube appears to be inside the cone (from the depth buffer point of view) and is occluded by the part of the cone that has smaller depth.
You can clear the depth buffer and observe different behavior:

renderer.render(scene1, camera1);
renderer.clearDepth();
renderer.render(scene2, camera2);

or

renderer.render(scene2, camera2);
renderer.clearDepth();
renderer.render(scene1, camera1);

Thanks for your time, I updated render function to this

but it is still not complete, the part of the cone inside the box must not appear, and the part outside the box must appear .

That will happen automatically if you align the centers of the box and the cone and put them on one scene and use one camera. Or use two scenes but cameras need to have the same position and near / far plane settings. Otherwise you can’t use the depth buffer in a meaningful way.