HUD K2_DrawLine FLinearColor does not take Alpha

On my player HUD, I’ve tried to draw a simple line.

	if (ThePawn)
	{
		if (ThePawn->GetLeftHandWeapon() || ThePawn->GetRightHandWeapon())
		{
			float CenterX = Canvas->ClipX / 2;
			float CenterY = Canvas->ClipY / 2;
			float X10 = Canvas->ClipX * 0.1f;
			float Y10 = Canvas->ClipY * 0.1f;
			// Draw the left horizontal line
			Canvas->K2_DrawLine(FVector2D(CenterX - X10, CenterY - Y10), FVector2D(0 + (2 * X10), CenterY - Y10), 2.0f, VisorColor);
		}
	}

The VisorColor has an Alpha of 0.5.

  • RenderColor {R=0.234335005 G=0.894999981 B=0.296303988 …} FLinearColor
  •  R	0.234335005	float
     G	0.894999981	float
     B	0.296303988	float
     A	0.500000000	float
    

However, the line is still drawn with 100% opacity.

When I debug, the function uses the right linear color.

void UCanvas::K2_DrawLine(FVector2D ScreenPositionA, FVector2D ScreenPositionB, float Thickness, FLinearColor RenderColor)
{
	if (FMath::Square(ScreenPositionB.X - ScreenPositionA.X) + FMath::Square(ScreenPositionB.Y - ScreenPositionA.Y))
	{
		FCanvasLineItem LineItem(ScreenPositionA, ScreenPositionB);
		LineItem.LineThickness = Thickness;
		LineItem.SetColor(RenderColor);
		DrawItem(LineItem);
	}
}

Is ther a limitation on FCanvasLineItem with the FLinearColor ? or is it a bug ?

Txs,
Dominique

Hi domzorg,

I ran some tests and was able to see the results that you described with the K2_DrawLine function. In my case, I did not see the specified Alpha value being used either when opening the project directly in the Editor, or when debugging through Visual Studio. I have submitted a report of my observations to have this investigated further (UE-14178). I did have a few additional questions for you, though.

  • What version of the Engine are you using? I was running my tests using 4.7.6 built from source code.
  • Are you seeing these results when playing the game in PIE mode? Do you see the same results when playing in Standalone or with a packaged game?
  • What is your Solution Configuration set to in Visual Studio when you see the Alpha value being used correctly?

Hello ,
When I posted this comment, I was using the 4.7.5, not the 4.7.6.
I see that result when playing in Editor.
I’ve also tried with the compiled source code Engine, same version.
The solution configuration is Development Editor.

D.

Thanks for the additional information. I ran the same tests using 4.7.5 built from source code as well as the binary version 4.7 with the latest update (4.7.6). I still saw the alpha value apparently being ignored when running the project through Visual Studio’s debugger as well as when opening the project directly in the Editor.

When I was looking through this yesterday I did see one spot in the source code where there was a comment stating that some legacy code ignores the Alpha value, and the value is apparently reset to 1 at this point. I am hoping that the report I put in yesterday will clarify if this is still necessary and, if so, how we can better communicate this information.

Many tanks to you for this information.

Have a nice day,
Dominique