Sign in to follow this  
maya18222

Point Sprite Size

Recommended Posts

At the moment im using a fixed point sprite size by setting PSIZE to some value, which causes the problem of - Moving closer to the particle source, causes particles to get smaller - Moving away from the particle source, causes particles to get bigger so how do i resolve this? is it just a case of experimentation? such as u + vDistanceNear = SizeNear u + vDistanceFar = SizeFar and just calculate the u and v for the mapping formula?

Share this post


Link to post
Share on other sites
I would say it depends if you set the PSIZE @ the vertex, if so i think the values of D3DRS_POINTSCALE_A, 3DRS_POINTSCALE_B, D3DRS_POINTSCALE_C dont matter because you are overriding the size. if not you can tweak those values to your like.

Share this post


Link to post
Share on other sites
I saw those values in the documentation. But i dont see how that works. How is it working out the dustance from the camera to the point?

Quote:
Point size is determined by D3DRS_POINTSCALEENABLE. If this value is set to FALSE, the application-specified point size is used as the screen-space (post-transformed) size. Vertices that are passed to Direct3D in screen space do not have point sizes computed; the specified point size is interpreted as screen-space size.

If D3DRS_POINTSCALEENABLE is TRUE, Direct3D computes the screen-space point size according to the following formula. The application-specified point size is expressed in camera space units.

S s = Vh * S i * sqrt(1/(A + B * D e + C *( D e2 )))

In this formula, the input point size, S i, is either per-vertex or the value of the D3DRS_POINTSIZE render state. The point scale factors, D3DRS_POINTSCALE_A, D3DRS_POINTSCALE_B, and D3DRS_POINTSCALE_C, are represented by the points A, B, and C. The height of the viewport, V h, is the D3DVIEWPORT9 structure's Height member representing the viewport. D e, the distance from the eye to the position (the eye at the origin), is computed by taking the eye space position of the point (Xe, Ye, Ze) and performing the following operation.

D e = sqrt (Xe2 + Y e2 + Z e2)


It says

"D e, the distance from the eye to the position (the eye at the origin), is computed by taking the eye space position of the point (Xe, Ye, Ze) and performing the following operation."

If its taking the distance from the origin, ( i assumed a better approach would be to take the distance from thr cam to the point), and the particle is moving slowly, but the camera moving away quickly, its not going to scale correctly.

could some one explain this?

Share this post


Link to post
Share on other sites
The distances are calculated in camera space. In camera/eye space, the camera position is the origin. So the points are transformed to camera space and their distance to the origin is found.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this