Hi =)
I follow the tutorials from rastertek.com (#13 today) and just created my own pikachu-cursor. I took a PNG-File, deleted the background and switched it to a DDS-File. When I view only the alpha-channel of this file, the pikachu is white and the background is black. So far so good...
In his/her Tutorails he added a function called "TurnOnAlphaBlending();", that registers a BlendingState with the following D3D11_BLEND_DESC:
blendStateDescription.RenderTarget[0].BlendEnable = TRUE;
blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
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;
When I understand alpha blending right, now a Pixel won't be drawn on the screen, if its alpha-channel is 0.0f and you can see what's below it...
But when I draw my Cursor its background is not totally transparent. You can see through but its like you see through a violett glass.
I had to add a few lines in my PixelShader:
if(textureColor.a == 0.0f)
{
textureColor = float4(0.0f,0.0f,0.0f,0.0f);
}
Then I get the result I want.
But I don't know why??? If the alpha-value is zero, that sould be enough, shouldn't it? Why does the color have to be black? Or what sould I change to get the right result without the last lines?
I hope, you can help me =)
Cat