Sign in to follow this  

particle textures not working

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok heres the important part of my render function:
		V(device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE));
		V(device->SetRenderState(D3DRS_ALPHABLENDENABLE,  TRUE));
		V(device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO));
	        V(device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE));
		V(device->SetRenderState(D3DRS_POINTSPRITEENABLE,true));
	        V(device->SetRenderState(D3DRS_POINTSCALEENABLE,true));
		V(device->SetRenderState(D3DRS_POINTSIZE,*((unsigned long*)&f)));
	        V(device->SetRenderState(D3DRS_POINTSIZE_MIN,*((unsigned long*)&f)));
		V(device->SetRenderState(D3DRS_POINTSCALE_A,0));
	        V(device->SetRenderState(D3DRS_POINTSCALE_B,0));
		V(device->SetRenderState(D3DRS_POINTSCALE_C,*((unsigned long*)&f)));
		V(device->SetStreamSource(0,buffer,0,sizeof(PARTICLE_VERTEX)));
		V(device->SetFVF(PARTICLE_FVF));
		V(device->SetTexture(0,texture));
		V(device->DrawPrimitive(D3DPT_POINTLIST,0,numAlive));
This is part of a particle system Im working on. Right now I just throw all the particle positions into a vertex buffer and then render it. The problem is they are just showing up as white squares. The texture I loaded is a red circle. I tried a lot of different combinations of alpha blending (including just turning it off) but either I get nothing (they show up as the background color) or I get white squares. Anyone got any ideas what could be wrong? Im using the V() macro for all my api calls and since I got no errors Im assuming the texture loaded ok.

Share this post


Link to post
Share on other sites
Well, problem one is that you're using ZERO for the dest blend function, which means that your particles will overwrite whatever is behind them. Typically, that's not what you want -- you typically want ONE or INVSRCALPHA for your dest function.

However, that's not the reason you're getting a white square -- that's something else, such as not setting the texture stage states right -- are you using MODULATE for colorop and TEXTURE/DIFFUSE as the color arg 1 and arg 2, and DISABLE as the second stage color op?

Share this post


Link to post
Share on other sites
I wasnt before but I added the following and it still shows white squares:

device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );


and I know I got the alpha blend stuff wrong I was playing around with it trying to get it to work.

Share this post


Link to post
Share on other sites
comon Im going crazy here. Does anyone know whats wrong with this? Ive been searching google for hours and so far all Ive found is reasons why what I wrote should work...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Do it with a pixel shader using :VPOS and :PSIZE in the vertex shader (so u can pass the size into the pixel shader).

Share this post


Link to post
Share on other sites

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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