Good Place. Good Things. Good Time.

DirectX 11 Sprite Alpha (Invalid? + Bad Quality)

I have a bug with a texture font.

This is the texture file in photoshop:
DirectX 11 Sprite Alpha (Invalid? + Bad Quality)

This is the result I am getting:
DirectX 11 Sprite Alpha (Invalid? + Bad Quality)

The alpha from 0 and 1 shows weird artifacts as the final result, alongside the low quality of the image itself.
How can i fix this?

blendStateDescription.RenderTarget[0].BlendEnable = TRUE;
blendStateDescription.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;

blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
blendStateDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_INV_DEST_ALPHA;
blendStateDescription.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
blendStateDescription.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendStateDescription.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;

float4 FontPixelShader(PixelInputType input) : SV_TARGET
{
   float4 color;

   // Sample the texture pixel at this location.
   color = shaderTexture.Sample(SampleType, input.tex);

   // If the color is black on the texture then treat this pixel as transparent.
   if(color.r == 0.0f)
   {
       color.a = 0.0f;
   }

   // If the color is other than black on the texture then this is a pixel in the font so draw it using the font pixel color.
   else
   {
       color.rgb = pixelColor.rgb;
       color.a = pixelColor.a;
   }

   return color;
}

// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

Search more articles here: DirectX 11 Sprite Alpha (Invalid? + Bad Quality)

Read original article here: DirectX 11 Sprite Alpha (Invalid? + Bad Quality)



Disclaimers and Denial of responsibility..!

Denial of responsibility! TheTopMag.com is an automatic aggregator of all media around the world. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – jamesonline999@gmail.com . The content will be deleted within 72 hours.
You might also like
Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.