Jump to content
  • Advertisement
Sign in to follow this  

Different Blendfactor for different sprite

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

Is it possible to set different blend factor for different sprites.
I am getting problem. I have made sprite class, when one sprite object blending(blend factor) is set the same blend factor applies to all other objects also.
There are some images whose background i want to make transparent while others background may not.
My question is related to DirectX 11. If know? Please help me.
Thanks!! In advance.

Share this post


Link to post
Share on other sites
Advertisement
I do not know if DirectX 11 support something like that, but I would render opaque and translucent sprites separately. Is there any reason to draw them in the same batch?

Share this post


Link to post
Share on other sites
It something like this:-


D3D11_BLEND_DESC blendDesc;
ZeroMemory( &blendDesc, sizeof( blendDesc ) );
blendDesc.RenderTarget[0].BlendEnable = TRUE;
blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
blendDesc.RenderTarget[0].RenderTargetWriteMask = 0x0F;

float blendFactor[4] = { valueR, valueG, valueB, valueA };

d3dDevice_->CreateBlendState( &blendDesc, &alphaBlendState_ );
d3dContext_->OMSetBlendState( alphaBlendState_, blendFactor, 0xFFFFFFFF );

DirectX 11 does not have separate sprite class hence I have created separately. In which I am using it, this above stuff in my sprite class. It applies to all other sprites also, when I assign to one sprite object.

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.

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

Sign me up!