Skip to main content
GameDev.net gamedev.net
🔒 Locked

Different Blendfactor for different sprite

Started by adi64 Jun 6, 2012 at 4:37 PM 1 replies 1k views
Original Post
adi64
adi64
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.
apatriarca
apatriarca
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?
adi64
adi64
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.