Click or drag to resize
DigitalRuneGraphicsHelperGetViewNormalizedDistance Method (Single, Matrix44F)
Converts the specified distance to a view-normalized distance ("LOD distance").

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public static float GetViewNormalizedDistance(
	float distance,
	Matrix44F projection
)

Parameters

distance
Type: SystemSingle
The 3D Euclidean distance between the object and the camera.
projection
Type: DigitalRune.Mathematics.AlgebraMatrix44F
The projection transformation.

Return Value

Type: Single
The view-normalized distance.
Remarks

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!

See Also