• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Partial Alpha / Blend problems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1MaloW  Members

Posted 12 April 2012 - 09:34 AM

Hi. Me and a few friends are making a game and we're having some problem with the alpha / blending.
What we're getting:

As you can see the glow-effect looks like shit. Here's the image for the glow-effect:

As you can see the alpha isnt correctly blending the parts where the alpha is pretty low in the image. The images are drawn back-to-front (there's 3 of them, the base texture, the text, and the glow), and they are drawn by expanding a quad in the GS.

Texture2D tex2D;
SamplerState linearSampler
{
Filter = MIN_MAG_MIP_LINEAR;
};

{
BlendEnable[0] = TRUE;
SrcBlend = SRC_ALPHA;
DestBlend = INV_SRC_ALPHA;
SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO;
};

DepthStencilState DisableDepthWrite
{
DepthEnable = FALSE;
};

cbuffer EveryFrame
{
float posx;
float posy;
float dimx;
float dimy;
}

RasterizerState NoCulling
{
CullMode = NONE;
};

VSIn VSScene(VSIn input)
{
return input;
}

[maxvertexcount(4)]
void GS( point VSIn input[1], inout TriangleStream<PSSceneIn> triStream )
{
PSSceneIn output;
output.opacity = 1.0f;

float4 basepos = float4(posx, posy, 0, 1);
//bottom left
output.Pos = basepos + float4(0, dimy, 0, 0);
output.tex = float2(0,1);
triStream.Append(output);

//bottom right
output.Pos = basepos + float4(dimx, dimy, 0, 0);
output.tex = float2(1,1);
triStream.Append(output);
//top left
output.Pos = basepos;
output.tex = float2(0,0);
triStream.Append(output);
//top right
output.Pos = basepos + float4(dimx, 0, 0, 0);
output.tex = float2(1,0);
triStream.Append(output);
}

float4 PSScene(PSSceneIn input) : SV_Target
{
float4 tex = tex2D.Sample(linearSampler, input.tex);
return tex;
}

technique11 BasicTech
{
pass p0
{
// Set VS, GS, and PS

SetDepthStencilState( DisableDepthWrite, 0 );
SetRasterizerState( NoCulling );
SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
}

### #2Geoffrey  Members

Posted 12 April 2012 - 05:06 PM

What texture format is the glow effect stored in?
The Trouble With Robots - www.digitalchestnut.com/trouble

### #3MaloW  Members

Posted 13 April 2012 - 03:53 AM

What texture format is the glow effect stored in?

Ah! I was using DXGI_FORMAT_BC1_UNORM, I changed it to DXGI_FORMAT_R32G32B32A32_FLOAT and now it works great, Thanks!

### #4Geoffrey  Members

Posted 13 April 2012 - 05:32 AM

By the way, R32G32B32A32_FLOAT is a huge format and probably isn't widely supported - I suggest you use something a bit lighter like A8R8G8B8.
The Trouble With Robots - www.digitalchestnut.com/trouble

### #5MaloW  Members

Posted 13 April 2012 - 06:38 AM

By the way, R32G32B32A32_FLOAT is a huge format and probably isn't widely supported - I suggest you use something a bit lighter like A8R8G8B8.

hmm ok, will R8G8B8A8 be able to hold all information that a normal .png image has without any loss in quality?

### #6Geoffrey  Members

Posted 13 April 2012 - 10:03 AM

Yes, I believe that is exactly what you get in a PNG file.
The Trouble With Robots - www.digitalchestnut.com/trouble

### #7MJP  Moderators

Posted 13 April 2012 - 02:57 PM

BC1 only provides you with 1 bit of alpha, which is why you get that weird "stenciled out" look with that format. BC2 and BC3 both allow for a full range of alpha values, so you should get much better results with either of them. Otherwise if you don't want to use compression R8G8B8A8_UNORM will give you sufficient precision for a .PNG file.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.