Can point sprites even do alpha transparency?

Started by
11 comments, last by Namethatnobodyelsetook 19 years, 6 months ago
I've been having some trouble getting point sprites in my particle engine to fade away using Alpha Transparency. It seems as though no matter what value I give the alpha it doesn't change the appearance of the sprite at all. I got alpha blending to work (praticles blend with the background), but I can't get them to fade away using alpha transparency. At first I thought it was just something in my code, but then I downloaded some random point sprites tutorial code, and theirs couldn't go transparent either. heres the tutorial I tried it on: Point sprites tutorial I set the value of the alpha like so:

D3DVERTEX aPoints[] = { {0.0f,1.0f,0.0f,0.1f,D3DCOLOR_COLORVALUE( 1.0, 
                                                       0.0, 
                                                       1.0, 
                                                       0.0f )},{0.5f,0.866f,0.0f,0.11f,0xffeeeeff},{0.866f,0.5f,0.0f,0.12f,0xffddddff},
						{1.0f,0.0f,0.0f,0.13f,0xffccccff},{0.866f,-0.5f,0.0f,0.14f,0xffbbbbff},{0.5f,-0.866f,0.0f,0.15f,0xffaaaaff},
						{0.0f,-1.0f,0.0f,0.16f,0xff9999ff},{-0.5f,-0.866f,0.0f,0.17f,0xff8888ff},{-0.866f,-0.5f,0.0f,0.18f,0xff7777ff},
						{-1.0f,0.0f,0.0f,0.19f,0xff6666ff},{-0.866f,0.5f,0.0f,0.2f,0xff5555ff},{-0.5f,0.866f,0.0f,0.21f,0xff4444ff}};



You can see the first one I changed it to fushia (which worked), and set its alpha transparency to 0 (which did nothing, setting it to '1' (its mutilplied by 255) also did nothing. If anyone who thinks they understand point sprites cares to give a crack at getting alpha transparency to work I'd really appreciate it. I'm definitley stumped.
Advertisement
It should work. It all depends on your alpha operations.

You should be doing
ALPHA_ARG1 = DIFFUSE
ALPHA_ARG2 = TEXTURE
ALPHA_OP = MODULATE

In order to mix the texture alpha with the vertex alpha.

Which video card? Are you using Shaders?

Luck!
Guimo
Maybe I'm stating the obvious, but have you checked to make sure your texture stage states do a modulation between the alpha of the texture and the alpha of the vertex's diffuse? I haven't tried my hand at point sprites yet myself, but it sounds like you modulate the color components of the texture and the vertex's diffuse value, but not the alpha values.

[edit]Er, yeah, what Guimo said; I'm slow.[/edit]
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
I know it should be working but it isn't :/

I've tried setting pretty much every render state I could think of to every value I could think of with no luck, if you could try downloading the tutorial and see if you can get them to go transparent that would be great.

I'm not using shaders, I doubt it's my video card since it's been the same on three different cards. Take a look at the tutorial source (it's pretty small).

Agony - I've played with textureStageStates a bit but I don't really understand them well enough to do much good, I've mostly just managed to make my sprites not alpha blend anymore, alpha transparency still wouldn't work.
It also might be a limitation of your video card. If I understand correctly, point sprites are fairly modern and handled differently than most things on the actual card.
I'm using a pretty state of the art card (so I doubt thats it). Can anyone paste how to set the texture stages guimo mentioned? Looking at the docs I'm not sure exactly how to do what he's talking about.
This was mentioned in the last thread you posted, but these states are wrong:
m_pDirect3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
m_pDirect3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);

What that does is give you source + dest, which is not what you want. The alpha value isn't even used in the calculation.

What you want is:
SRCBLEND = D3DBLEND_SRCALPHA
DESTBLEND = D3DBLEND_INVSRCALPHA

If you don't set the blend states to use the alpha, then changing the value of the alpha is not going to accomplish anything.
Stay Casual,KenDrunken Hyena
This is my code to alpha transparency in my particle system:
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA  );m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE);m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);        m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);


I hope this help you.
Quote:Original post by DrunkenHyena
This was mentioned in the last thread you posted, but these states are wrong:
m_pDirect3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
m_pDirect3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);

What that does is give you source + dest, which is not what you want. The alpha value isn't even used in the calculation.

What you want is:
SRCBLEND = D3DBLEND_SRCALPHA
DESTBLEND = D3DBLEND_INVSRCALPHA

If you don't set the blend states to use the alpha, then changing the value of the alpha is not going to accomplish anything.


Unfortunately ken I tried that and alpha transparency still did not work. Try downloading the tutorial source if you're at all curious.
Quote:Original post by Anonymous Poster
This is my code to alpha transparency in my particle system:
*** Source Snippet Removed ***

I hope this help you.


*bow* that made alpha transparency work. Thank you! Only trouble is it totally ruined the apperance of my sprites (I think it made alpha blending not work?) I'll look into it and if I can't get it I'll post screenshots.

This topic is closed to new replies.

Advertisement