Camera |
public class CameraDistanceSortedRenderingQueue : SortedRenderablePrimitiveRenderingQueue
The CameraDistanceSortedRenderingQueue type exposes the following members.
Name | Description | |
---|---|---|
CameraDistanceSortedRenderingQueue | Constructor |
Name | Description | |
---|---|---|
CheckAllBoundingBoxCorners | Gets or sets a Boolean that specifies if all bounding box corners are checked to get distance to the camera. When false (by default) then center of the bounding box is used to get the distance to the camera (this is significantly faster). | |
DistantObjectsFirst | Gets or sets the direction of sorting. When true the objects that are more far away from the camera are rendered first. | |
FixBackFaceMaterialOrder | Gets or sets a Boolean that specifies if the order of objects that render back face is manually fixed so that they are always rendered before front face materials. This is only used when DistantObjectsFirst is true. Default value is true. See remarks in this class description for more info. | |
SortingType |
Gets a RenderingQueueSorterType that specifies when the RenderingQueue needs to be resorted.
(Overrides SortedRenderablePrimitiveRenderingQueueSortingType) |
CameraDistanceSortedRenderingQueue is rendering queue where the objects inside the queue are sorted by their distance from the camera. This is uses for transparent object that need to be rendered so that the objects that are more far away from the camera are rendered first.
The CameraDistanceSortedRenderingQueue uses a highly optimized quick sort algorithm. This algorithm is not a stable sort algorithm. This means that objects with the same sort value can change their positions (for example if A, B and C have the same value, then sort may return them in a different order as initially defined). Because of this it may happen that when a 3D objects is rendered with its back and front face materials, then sometimes the order of those two materials can change and this can lead to some flickering when camera is changed. To fix that the CameraDistanceSortedRenderingQueue by default fixes the order so that when one object renders both back and front material, then back material is always rendered before front material (this only works when no other object has the same distance to the camera - so that there are no other objects inserted into rendering queue between back and front face material). This fix can be disabled with setting FixBackFaceMaterialOrder property to false.
With DistantObjectsFirst property it is possible to change the sorting order. By default this property is set to true so that distant objects are rendered first. This is used for rendering transparent objects. But if you have a few big objects that occlude most of the scene, then you may want to set this property to false. This will render the closest objects first and therefore occlude other objects - improving performance with early rejecting of triangles because of depth testing.
To provide custom sort order, you can subscribe to SortingCompleted event and in the event handler change the order of RenderablePrimitive objects by changing the indexes in the provided SortedIndexes array.