Skip to main content
gamedev.net
🔒 Locked

Point Sprites alpha

Started by outlawhacker 1 reply 550+ views
Original Post
outlawhacker
outlawhacker
Hey I'm trying to do particle effects with Point sprites in DirectX 9. I'm having trouble with changing the alpha value. I use a png with a alpha background. I've also tried using a bmp with renderstate BLEND_ONE but no luck. This is how I do it:

struct PointVertex
{
	D3DXVECTOR3 m_Pos;
	float m_Size;
	D3DCOLOR m_Color;
};

#define FVF_POINTVERTEX		(D3DFVF_XYZ |  D3DFVF_PSIZE | D3DFVF_DIFFUSE )

// Set render states before rendering
a_Device->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); a_Device->SetRenderState(D3DRS_POINTSCALEENABLE,  TRUE);		a_Device->SetRenderState(D3DRS_POINTSIZE, FtoDW(m_Size)); a_Device->SetRenderState(D3DRS_POINTSIZE_MIN, FtoDW(0.0f));
a_Device->SetRenderState(D3DRS_POINTSCALE_A, FtoDW(0.0f));
a_Device->SetRenderState(D3DRS_POINTSCALE_B, FtoDW(0.0f));
a_Device->SetRenderState(D3DRS_POINTSCALE_C, FtoDW(1.0f));

a_Device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
a_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

a_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
a_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

// Example setting colors
vertices->m_Color = 0x11ffffff;

// Render the point sprites veritices
// jada jada


The size and colors works fine when I'm changing it, but the alpha isn't affected. Any idea what I'm doing wrong? Thanks in advance for replies
jollyjeffers
jollyjeffers
If you want per-vertex alpha then you have to set up the texture blending state to module accordingly. Otherwise it'll just be trying to read the alpha from the texture (which is usually better anyway)...

Off the top of my head, it should be as simple as:

IDirect3DDevice9::SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
IDirect3DDevice9::SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
IDirect3DDevice9::SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );


If that doesn't work, try some of the other params for the alpha op [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
outlawhacker
outlawhacker
Yeah!

I don't know what you just said. But it worked!

Thanks dude!

Topic Locked

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

Sign in to reply to this topic.