Skip to main content
GameDev.net gamedev.net
🔒 Locked

Particle problem

Started by ThoSt Sep 21, 2005 at 6:10 PM 2 replies 500+ views
Original Post
ThoSt
ThoSt
Hi, I am trying to get the hang of particle systems. Now my particles do get rendered, however, they are rendered very big. Also their size does not increase or decrease no matter what parameters I put where. I do not understand the MSDN article about D3DRS_POINTSCALEENABLE, since I am no math professor. Also I have read that if D3DRS_POINTSCALEENABLE is set to FALSE that DX9 would just take the size declared in the vertexbuffer, however if I set it to false my particles are never rendered at all. I have other issues with my particles as well, but those are mostly logic errors/alogrithm going wrong, but my problem with the huge particle remains a mystery to me. I also dont know what else to try/what to read/look up to help my situation. below is some (hopefully) relevant code. struct CUSTOMPARTICLEVERTEX { FLOAT x, y, z; DWORD PSIZE; DWORD Diffuse; }; #define D3DFVF_CUSTOMPARTICLEVERTEX (D3DFVF_XYZ|D3DFVF_PSIZE|D3DFVF_DIFFUSE) /* since I dont know the real meaning of the following lines I just pass 0. However passing anything else does not change the results at all anyways*/ FLOAT MinSize, Scale; MinSize = Scale = 0; // setting up the particle system m_pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); m_pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE); m_pDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *((DWORD*)&MinSize)); m_pDevice->SetRenderState(D3DRS_POINTSCALE_A, *((DWORD*)&Scale)); m_pDevice->SetRenderState(D3DRS_POINTSCALE_B, *((DWORD*)&Scale)); m_pDevice->SetRenderState(D3DRS_POINTSCALE_C, *((DWORD*)&Scale)); m_pDevice->SetStreamSource(0, m_pVB, 0, sizeof(CUSTOMPARTICLEVERTEX)); m_pDevice->SetFVF(D3DFVF_CUSTOMPARTICLEVERTEX); m_pDevice->SetTexture(0, m_Texture); m_pDevice->DrawPrimitive(D3DPT_POINTLIST, 0, m_NumParticles); if anybody could point me in the right direction or could give me some basic things I could check (things that have to be set or functions that have to be called when using a particle system etc) I would be very happy.
bjle
bjle
You will want to have at least one of POINTSCALE A, B, or C be non-zero. (I use POINTSCALE_C = 1.0, and the rest zero.)

You could try removing the PSIZE from your vertex format, and setting the renderstate D3DRS_PSIZE to something like 1.0. If that works, something might be wrong with the way you're setting the individual sizes.
xsirxx
xsirxx
leave MinSize at 0.00f.

are these set?
	m_pDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );	m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );	m_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );	m_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );


And check out D3DRS_POINTSIZE:

pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&Scale) );

Set Scale to whatever, try 10? 100?

and then im not sure what is x, y ,z for yer game but try...
float Scalea = 0.0f;float Scaleb = 1.0f;float Scalec = 1.0f;float Scale  = 10.0f;pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&Scale) );pd3dDevice->SetRenderState( D3DRS_POINTSCALE_A,  *((DWORD*)&(Scalea) );pd3dDevice->SetRenderState( D3DRS_POINTSCALE_B,  *((DWORD*)&(Scaleb) );pd3dDevice->SetRenderState( D3DRS_POINTSCALE_C,  *((DWORD*)&(Scalec) );


I havent touched particles in a LOONNGGG time since I got into shaders, but I imagine yer doing billboarding? The POINTSIZE I believe is the actual scaling. The POINTSCALE_A, _B,_C are I think the axis' to scale on, try 1 on those...

Good luck, post back some results with what happens.
--X
ThoSt
ThoSt
well I still dont exactly understand why and how, but xsirxx's advice worked perfectly. I also tried bjle's suggestion but it really didnt change anything.

However, the renderstates you told me to set were not really correct. All they did was change the rendering of the colors.

As to what I am doing - right now I am just trying to figure everything out. I dont have an exact game or engine in mind, I am not advanced enough as of now to start something like that.

Anyhow, thanks for the help, the scaling now works properly and I can start on working out the other bugs my particle system has :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.