Sign in to follow this  
guyaton

Point Sprites

Recommended Posts

guyaton    130
I notice on alot of tutorials online (and the MSSDK) these renderstates are used:
pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );
pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE,  TRUE );
pd3dDevice->SetRenderState( D3DRS_POINTSIZE,     FtoDW(0.08f) );
pd3dDevice->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(0.00f) );
pd3dDevice->SetRenderState( D3DRS_POINTSCALE_A,  FtoDW(0.00f) );
pd3dDevice->SetRenderState( D3DRS_POINTSCALE_B,  FtoDW(0.00f) );
pd3dDevice->SetRenderState( D3DRS_POINTSCALE_C,  FtoDW(1.00f) );

the only disadvantage is that this assumes a constant point size. I am trying to make the point sprites change in relation to the camera distance, so as the camera moves away, the sprites get smaller. I'm using the FVF "PSIZE" and my struct looks like this:
struct VertexPointSprite
{
	D3DXVECTOR3 vecVert;
	float fSize;
	DWORD dwColor;
	
	static const DWORD FVF;
};
const DWORD VertexPointSprite::FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_PSIZE;

as of right now, the point sprite is always the same size irregardless and when i tried using the scale a, b, and c's the point sprite was the size of a few pixels, even when the size of the point sprite was 2000. thanks

Share this post


Link to post
Share on other sites
IFooBar    906
Try setting point scale C to 1.5. Pointscales are like the attenuation values for light sources. And if you still dont see any changes it might be because of lack of hw support. Try switching to software vertex processing and see if it works then.

On a similar note I've written a tutorial on pointsprites over here and the sample does change scale relative to camera distance, so you can compare that with your code and see what needs to be changed.

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