Today, I have implemented soft particles by rendering them to a separate render target and blending that with the scene, which worked as expected with additive blended particles. In that case I render the particles to a rendertarget while blending them additively, then drawing that rendertarget in fron of the scene while blending additively, works like a charm, I even save some render time if I use a smaller render target. In the case of alpha blended particles, I have a serious issue. First I draw them with a blend state set up for alpha blending:
D3D11_BLEND_DESC bd; bd.RenderTarget.BlendEnable=true; bd.RenderTarget.SrcBlend = D3D11_BLEND_SRC_ALPHA; bd.RenderTarget.DestBlend = D3D11_BLEND_INV_SRC_ALPHA; bd.RenderTarget.BlendOp = D3D11_BLEND_OP_ADD; bd.RenderTarget.SrcBlendAlpha = D3D11_BLEND_ZERO; bd.RenderTarget.DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; bd.RenderTarget.BlendOpAlpha = D3D11_BLEND_OP_ADD; bd.RenderTarget.RenderTargetWriteMask = 0x0f; bd.IndependentBlendEnable=true;
(This is it after reading the GPU Gems article on this subject.)
The render target which I draw them to is cleared by zero for all channels. When I draw this rendertarget to the screen I use a blend state set up for alphablending (it is used for all the 2d images and definetly works well) and I get this: It seems as if I have depth writing turned on but I made sure it is turned off. If I draw the rendertarget with these alpha blended particles on it, but with no blending (for the RT) I get this: Which seems correct, it just doesn't blend how I want to. On GPU gems there are sure some well described formulas for the blending, but if I set the blendstate descibed there I won't get the results they get. Could someone help me with what I am missing?