Table of contents
Collapse the table of content
Expand the table of content

Computing the Size of Point Sprites

Last Updated: 2/14/2017

Point sprites are rendered by using the existing D3DPT_POINT primitive type. The size of point sprites can be controlled either through the new render state D3DRS_POINTSIZE or by the new FVF component D3DFVF_PSIZE.

For vertices without the D3DFVF_PSIZE vertex component, the current value of the D3DRS_POINTSIZE render state should be used. Otherwise, the value specified in the vertex data should be used. In either case, the value is a floating-point number that is the size (width and height) of the rendered quad in rendering target pixels. The default value of the point size render state (1.0) is sent to the driver during initialization.

Two render states control clamping of the computed point sprite size, D3DRS_POINTSIZE_MIN and D3DRS_POINTSIZE_MAX. The computed size of the point should be clamped to be no smaller than the size given by D3DRS_POINTSIZE_MIN and no larger than the size given by D3DRS_POINTSIZE_MAX. It is the driver's responsibility to ensure that the point sprite size is clamped to the minimum and maximum sizes specified by the render states.

For drivers that support hardware vertex processing, the size of point sprites may also be scaled based on the distance from the point to the eye (in eye space). Scaling of the point sprites is enabled by the new render state D3DRS_POINTSCALEENABLE. If the value of this render state is TRUE then the points are scaled according to the following parameters, the Sₛ formula, and maximum/minimum determination. Note that in this case the application-specified point size is expressed in camera space units. This scaling is performed by drivers that support transform and lighting only.

Input point size (either per-vertex or D3DRS_POINTSIZE)

Point scale factors D3DRS_POINTSCALEA/B/C

Height of viewport (dwHeight field in D3D_VIEWPORT)

Pₑ = (Xₑ, Yₑ, Zₑ)
Eye space position of point

De = sqrt (Xₑ² + Yₑ² + Zₑ²)
Distance from eye to position (eye at origin)

Sₛ = Vₕ * Si * sqrt(1/(A + B*Dₑ + C*(Dₑ²)))
Screen space point size

MaxPointSize (member of D3DCAPS8) device capability


Final screen-space point size S =
Smax if Sₛ > Smax

Smin if Sₛ < Smin

Sₛ otherwise

Note that for the application to be drawing single pixel vertices, rather than point sprites, it must have the following render states set:

// All textures must be turned off.
SetTexture (0, NULL); 
SetTextureStageState(1, D3DTSS_COLOROP,  D3DTOP_DISABLE);
// The point size render state must be set to any value between 0.0-1.0
SetRenderState(D3DRS_POINTSIZE, 1.0);
// must be set appropriately to allow
// D3DRS_POINTSIZE to be set to a value between 0.0-1.0

Send comments about this topic to Microsoft

© 2017 Microsoft