Microsoft DirectX 8.0 (Visual Basic) |
A screen-space point,
P = (X, Y, Z, W)
of screen-space size S is rasterized as a quadrilateral of the following four vertices.
((X+S/2, Y+S/2, Z, W), (X+S/2, Y-S/2, Z, W), (X-S/2, Y-S/2, Z, W), (X-S/2, Y+S/2, Z, W))
The vertex color attributes are duplicated at each vertex; thus each point is always rendered with constant colors.
The assignment of texture indices is controlled by the D3DRS_POINTSPRITEENABLE render state setting. If D3DRS_POINTSPRITEENABLE is set to False, then the vertex texture coordinates are duplicated at each vertex. If D3DRS_POINTSPRITEENABLE is set to True, then the texture coordinates at the four vertices are set to the following values.
(0.0, 0.0), (0.0, 1.0), (1.0, 0.0), (1.0, 1.0)
This is shown in the following diagram.
When clipping is enabled, points are clipped in the following manner. If the vertex exceeds the range of depth values—MinZ and MaxZ of the D3DVIEWPORT8 type—into which a scene is to be rendered, the point exists outside of the view frustum and is not rendered. If the point, taking into account the point size, is completely outside the viewport in x and y, then the point is not rendered; the remaining points are rendered. It is possible for the point position to be outside the viewport in x or y and still be partially visible.
Points may or may not be correctly clipped to user-defined clip planes. If the D3DPMISCCAPS_CLIPPLANESCALEDPOINTS is not set in the PrimitiveMiscCaps member of D3DCAPS8, then points are clipped to user-defined clip planes based only on the vertex position, ignoring the point size. In this case, scaled points are fully rendered when the vertex position is inside the clip planes, and discarded when the vertex position is outside a clip plane. Applications can prevent potential artifacts by adding a border geometry to clip planes that is as large as the maximum point size.
If the D3DPMISCCAPS_CLIPPLANESCALEDPOINTS bit is set, then the scaled points are correctly clipped to user-defined clip planes.
Hardware vertex processing may or may not support point size. For example, if you create a device with D3DCREATE_HARDWARE_VERTEXPROCESSING on a HAL Device (D3DDEVTYPE_HAL) that has the MaxPointSize member of its D3DCAPS8 type set to 1.0 or 0.0, then all points are a single pixel. To render pixel point sprites less than 1.0, you must use either flexible vertex format (FVF) TL (transformed and lit) vertices or software vertex processing (D3DCREATE_SOFTWARE_VERTEXPROCESSING), in which case the Microsoft® Direct3D® run time emulates the point sprite rendering. For details on FVF TL vertices, see Transformed and Lit Vertex Functionality.
A hardware device that does vertex processing and supports point sprites—MaxPointSize set to greater than 1.0f—is required to perform the size computation for nontransformed sprites and is required to properly set the per-vertex or D3DRS_POINTSIZE for TL vertices.