STK Components for .NET 2021 r2

## 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.

Near and Far Planes

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 and FarPlane camera properties, as shown below:

C#

Scene.Camera.NearPlane = 10000; Scene.Camera.FarPlane = 10000000;

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.

Far-to-Near Plane Ratio

The camera's FarNearPlaneRatio 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 property. Its far plane distance is computed by multiplying its near plane distance by FarNearPlaneRatio. 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 property.

The following image (not to scale) shows an example where 3 view frustums are created based on the NearPlane, FarPlane, and FarNearPlaneRatio properties. Note that view frustums farther away from the camera are larger.

Field Of View

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 property. Use the HorizontalFieldOfView and VerticalFieldOfView properties to get the horizontal and vertical fields of view.

C#

`Scene.Camera.FieldOfView = Trig.DegreesToRadians(120);`

Wider fields of view create bigger view frustums with more potentially visible objects and can look distorted.