View Frustum |
A view frustum is a truncated pyramid that determines what can be in view. Only objects within the frustum can appear on the screen. The camera is at the tip of the pyramid. The pyramid extends out along the direction the camera is looking as shown below.
The frustum starts at the near plane and ends at the far plane. These planes are parallel and their normals are along the direction the camera is looking. The length of the frustum is determined by the distance from the camera to the near plane and the distance from the camera to the far plane as shown below.
These values can be set using the NearPlane (get / set) and FarPlane (get / set) camera properties, as shown below:
getScene().getCamera().setNearPlane(10000.0); getScene().getCamera().setFarPlane(10000000.0);
Moving the near plane too far from the camera can result in objects frequently getting clipped by the near plane as shown below.
Insight3D uses multiple view frustums to correct the precision problems of a close near plane but it can sometimes cause a performance hit. It is recommended to start with the default near plane distance of 1 meter and adjust it only if necessary.
The camera's FarNearPlaneRatio (get / set) property is used to compute the size and number of view frustums used for rendering. It is not recommended to modify this property unless you have a good reason. A low far-to-near ratio provides better depth buffer precision but may create more view frustums, which can adversely affect performance.
The view frustum closest to the camera has a near plane distance defined by the NearPlane (get / set) property. Its far plane distance is computed by multiplying its near plane distance by FarNearPlaneRatio (get / set). The next farthest view frustum has a near plane distance of the previous view frustum's far plane (ignoring a slight overlap). Its far plane distance is again computed using the far-to-near ratio. This process continues until the final view frustum has a far plane distance that satisfies the FarPlane (get / set) property.
The following image (not to scale) shows an example where 3 view frustums are created based on the NearPlane (get / set), FarPlane (get / set), and FarNearPlaneRatio (get / set) properties. Note that view frustums farther away from the camera are larger.
Depending on the window's aspect ratio, the field of view is either the angle between the top and bottom view frustum planes, or the left and right planes. If the Y dimension of the window is larger than the X dimension, then the field of view is the angle between the top and bottom planes, otherwise it is the angle between the left and right planes. Set the field of view using the camera's FieldOfView (get / set) property. Use the HorizontalFieldOfView (get) and VerticalFieldOfView (get) properties to get the horizontal and vertical fields of view.
getScene().getCamera().setFieldOfView(Trig.degreesToRadians(120.0));
Wider fields of view create bigger view frustums with more potentially visible objects and can look distorted.