Jump to content
  • Advertisement
Sign in to follow this  
Mariusmssj2

DX11 Dx11 Multiple BlendStates

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

<p>Hey guys,

I am trying to have a particle shader and fire shader working together in a scene but they each work only with one state:

For Particles to render well I use this :
    // Create an alpha enabled blend state description.
    blendStateDescription.RenderTarget[0].BlendEnable = TRUE;
    blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
    blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
    blendStateDescription.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
    blendStateDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
    blendStateDescription.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
    blendStateDescription.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
    blendStateDescription.RenderTarget[0].RenderTargetWriteMask = 0x0f;


and for fire I use this:
    // Create an alpha enabled blend state for fire shader
    blendStateDescription.RenderTarget[1].BlendEnable = TRUE;
    blendStateDescription.RenderTarget[1].SrcBlend = D3D11_BLEND_SRC_ALPHA;
    blendStateDescription.RenderTarget[1].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
    blendStateDescription.RenderTarget[1].BlendOp = D3D11_BLEND_OP_ADD;
    blendStateDescription.RenderTarget[1].SrcBlendAlpha = D3D11_BLEND_ONE;
    blendStateDescription.RenderTarget[1].DestBlendAlpha = D3D11_BLEND_ZERO;
    blendStateDescription.RenderTarget[1].BlendOpAlpha = D3D11_BLEND_OP_ADD;
    blendStateDescription.RenderTarget[1].RenderTargetWriteMask = 0x0f;


But I got no idea how assign one to particle shader and other one to fire shader

This is the outcome: eYn4t.pngThanks in advance

Share this post


Link to post
Share on other sites
Advertisement
If you multiply the color intensity by 10 and divide the opacity by 10, you can get alpha filtering to look almost exactly like additive filtering. Only smoke in the fire may use dark colors or it will not look real. Alpha filtering also have the advantage of working well with distance based fog.

Share this post


Link to post
Share on other sites
Hey Dawoodoz, I think I am doing the whole RenderTarget[0] RenderTarget[1] thing wrong.

I really can't find how to apply different blending states to different shaders

Share this post


Link to post
Share on other sites
doing an array of render target blend descriptions is for when you are binding multiple render targets to the OM to be sent to the shader at once. Are you binding multiple render targets at once (sending the fire and particles to the shaders together)?

otherwise, the problem is probably that you are not setting the blending state before you draw your stuff. you have to make sure to set the blending state right before you draw your stuff.

d3d11DevCon->OMSetBlendState(particleTransparency, NULL, 0xffffffff);
d3d11DevCon->Draw(particles);

d3d11DevCon->OMSetBlendState(fireTransparency, NULL, 0xffffffff);
d3d11DevCon->Draw(fire);


If you are not binding multiple render targets, you probably want to just create two different blend states (eg. particleTransparency and fireTransparency), instead of just a single blend state with multiple blend descriptions. I hope that even makes sense, haha

Share this post


Link to post
Share on other sites
<p>

doing an array of render target blend descriptions is for when you are binding multiple render targets to the OM to be sent to the shader at once. Are you binding multiple render targets at once (sending the fire and particles to the shaders together)?

otherwise, the problem is probably that you are not setting the blending state before you draw your stuff. you have to make sure to set the blending state right before you draw your stuff.

d3d11DevCon->OMSetBlendState(particleTransparency, NULL, 0xffffffff);
d3d11DevCon->Draw(particles);

d3d11DevCon->OMSetBlendState(fireTransparency, NULL, 0xffffffff);
d3d11DevCon->Draw(fire);


If you are not binding multiple render targets, you probably want to just create two different blend states (eg. particleTransparency and fireTransparency), instead of just a single blend state with multiple blend descriptions. I hope that even makes sense, haha


well i begun doing Dx11 last week but it does make sense and I shall try to do it now, thanks for the advice [edit]You have my kindest thanks sir, as it worked like a charm :D Thank you

Share this post


Link to post
Share on other sites
One more questions guys if you don't mind, where to find a good tutorial or some material on how to create a sky box in DX11?

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!