Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Point sprites with glow and alpha blend

This topic is 5149 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

How could I combine the effect that comes from Blend.One - Blend.One and Blend.SourceAlpha - Blend.InvSourceAlpha? With first one you get nicely glowing particle effects, but no fading (expect color fading into background). The second one gives nice blending into surroundings, but makes ugly black boxes around the particles. I would like to have the glow, fade, but no black boxes. What should I do? Business is business and Moses is Moses [Homesite]
Advertisement
Yeah, I searched around, but could find the answer. That thread didn''t help me much. I could show some pictures:

This is with blend one, and the fading is done with color:
One

This is with alpha blend, so no color trick are needed, and the particles fade nicely, but with black boxes and without the nice blend one effect:
Alpha

I would like to combine them both, and get rid of the black boxes...

Business is business and Moses is Moses
[Homesite]
Guest Anonymous Poster
There''s a technique called "SoftAdd" which is basically

srcblend = invdstcolor
dstblend = one

Share this post


Link to post
Share on other sites
When you say "Blend.SourceAlpha - Blend.InvSourceAlpha" are you implying you set the blendmode to subtract?

A standard alpha blend is
SrcBlend = D3DBLEND_SRCALPHA
DestBlend = D3DBLEND_INVSRCALPHA
BlendOp = D3DBLENDOP_ADD
DX9''s new AlphaSrcBlend and AlphaDestBlend can be ignored.

This is the standard normal alpha blend. This should not produce any black boxes. When alpha is 0, you get destcolor, when alpha is 255 you get srccolor.

Share this post


Link to post
Share on other sites
Looking at your image, it looks like your alpha is coming from your vertices, and not from your texture.

What you want is both to have an effect. Set alpha blending in your texture stage states to the following:
alphop = modulate
alphaarg1 = diffuse
alphaarg2 = texture

Share this post


Link to post
Share on other sites
Hmm, I''m still put of luck. This is what I do now:


// I set the particle''s color so that the color itself doesn''t change, but the alpha decreases as the lifetime goes down

p.Color = Color.FromArgb((int)((p.Lifetime / p.OriginalLifetime) * 255.0f), p.Color);

// Here''s the stages I''ve been setting

device.RenderState.PointSpriteEnable = true;
device.RenderState.PointScaleEnable = true;
device.RenderState.AlphaBlendEnable = true;
device.RenderState.ZBufferEnable = false;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.RenderState.BlendOperation = BlendOperation.Add;
device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
device.TextureState[0].AlphaArgument0 = TextureArgument.Diffuse;
device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
device.RenderState.PointSize = 0.05f;
device.SetTexture(0, texture);


These give me this

Business is business and Moses is Moses
[Homesite]
Your code looks just fine, but it seems like your texture either doesn''t have an alpha channel or it''s filled with one value. The alpha channel should look similar to one of your RGB channels (opaque at the center, fading out towards the edges). If you want alpha-blended particles to be as bright as the additive ones, the RGB part of the texture should be a solid bright color (or switch to pre-multiplied alpha).

Share this post


Link to post
Share on other sites
Your image doesn''t have alpha in it. If you want to blend based on per-pixel alpha rather than color, you''re going to have to use an image that contains per-pixel alpha values.

Use the DXTextureTool that comes with the SDK to take two images, your color image, and an alpha image, and merge them into a single image with color and alpha. (preferably you''d do all this in Photoshop, but I''m assuming you don''t have that, being expensive and all).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!