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

Recommended Posts

Hi folks, i draw some particle and want them to fade out as their lifetime is over. Therefore i interpolate the alpha value of each particle. the problem is that either 1.0 or 0.0 it is still visible and shines bright. I use the renderstates
    G3D::d3ddev->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );

G3D::d3ddev->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
G3D::d3ddev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

//
// Set up the render states for using point sprites...
//

G3D::d3ddev->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );    // Turn on point sprites
G3D::d3ddev->SetRenderState( D3DRS_POINTSCALEENABLE,  TRUE );    // Allow sprites to be scaled with distance
G3D::d3ddev->SetRenderState( D3DRS_POINTSIZE,     FtoDW(1.0) );  // Float value that specifies the size to use for point size computation in cases where point size is not specified for each vertex.
G3D::d3ddev->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(1.0f) ); // Float value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering.
G3D::d3ddev->SetRenderState( D3DRS_POINTSCALE_A,  FtoDW(1.0f) ); // Default 1.0
G3D::d3ddev->SetRenderState( D3DRS_POINTSCALE_B,  FtoDW(1.0f) ); // Default 0.0
G3D::d3ddev->SetRenderState( D3DRS_POINTSCALE_C,  FtoDW(1.0f) ); // Default 0.0

i am just a beginner, so could you explain me plz why the alpha value has no effect at all ?? This is my vertex format
D3DFVF_XYZ|D3DFVF_DIFFUSE

p.col = D3DCOLOR_COLORVALUE(1.0f, 1.0f, 1.0f ,0.0f );//white
p.col = D3DCOLOR_COLORVALUE(1.0f, 0.0f, 0.0f ,0.0f );//red
p.col = D3DCOLOR_COLORVALUE(1.0f, 0.0f, 0.0f ,1.0f );//red

0.0f and 1.0f for alpha makes no difference at all I hope you can help me.

Share on other sites
Use
G3D::d3ddev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
G3D::d3ddev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

Share on other sites
Thank you, it was not the solution, but it brought me another idea.

Thats the fact -> in oder to get it fade away, you have to make the particle black.

The less diffuse color the more invisible the particle get.

If i change the color to 0.0, 0.0, 0.0 , 0.0 - the particle disappears

but the alpha value still doesnt matter at all ...

i would really appreciate to know why.

Share on other sites
My particle image doesn't have an actual alpha channel (just black for area not shown) and I had to use:
SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE)

then:
SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);

So that I could get my particles to fade out to zero at the end of their life.

Share on other sites
What I posted was for "normal" alpha blending. I suppose you're doing additive alpha blending, so use this instead (if you are actually outputting alpha channel)

G3D::d3ddev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
G3D::d3ddev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

Or, if not using an alpha channel, and just scaling rgb, as j_smith4 suggests:

G3D::d3ddev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
G3D::d3ddev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 12
• 15
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633354
• Total Posts
3011494
• Who's Online (See full list)

There are no registered users currently online

×