GraphicsHelperGetViewNormalizedDistance Method (SceneNode, CameraNode) |
Namespace: DigitalRune.Graphics
public static float GetViewNormalizedDistance( SceneNode sceneNode, CameraNode cameraNode )
The view-normalized distance is defined as:
distancenormalized = distance / yScale
where distance is the 3D Euclidean distance between the camera and the object. yScale is the second diagonal entry of the projection matrix.
For symmetric perspective projections the above equation is the same as
distancenormalized = distance * tan(fovY / 2)
where fovY is the camera's vertical field-of-view.
In other words, the view-normalized distance is the camera distance times a camera correction factor. The correction factor accounts for the camera field-of-view. The resulting value is inversely proportional to the screen size of the object and independent of the current field-of-view. It can be used to specify LOD distances or similar metrics.
Note that tan(fovY/2) is 1 if the fovY = 90°. This means that distance and view-normalized distance are identical for a camera with a vertical field-of-view of 90°. (This 90° FOV camera is the "reference camera".)
The view-normalized distance is only defined for cameras with perspective projections. The result is undefined for orthographic projections!