Download

Translucencies overriding eachother

Hello Community!

I’m having an issue with a texture with a render target and another texture that’s a character that I want to be always in front, but sometimes in 1/15 of the time, the render texture will try to bleed through the character texture.

The character has Disable Depth Test checked and the render texture does not. I also have a bit of code that tells the texture to fade in and out too.

Translucency Issue.jpg



void AOpponent::FadeOutOpponent()
{
	float FadeValue = 0.f;
	
	//Ensure The Scalar Parameter Exists
	if (MatInst->GetScalarParameterValue(FName(TEXT("Opponent_Fade")), FadeValue))
	{
		//Fade Out Opponent As long as it's above 0.0f
		if (FadeValue > 0.f)
		{
			MatInst->SetScalarParameterValue(FName(TEXT("Opponent_Fade")), FadeValue - 0.2);
		}
		//Once the Scalar is at 0.0f..
		else
		{
			//Initialize next Opponent Attacker
			MatInst->SetScalarParameterValue(FName(TEXT("Opponent_Fade")), 0.f);
			GetWorld()->GetTimerManager().ClearTimer(FadeHandle);
			InitializeOpponent();
		}
	}
}

void AOpponent::FadeInOpponent()
{
	float FadeValue = 0.f;
	//Ensure The Scalar Parameter Exists
	if (MatInst->GetScalarParameterValue(FName(TEXT("Opponent_Fade")), FadeValue))
	{
		//Fade In Opponent as long as it's above 1.0f
		if (FadeValue < 2.f)
		{
			MatInst->SetScalarParameterValue(FName(TEXT("Opponent_Fade")), FadeValue + 0.1f);
		}
		//Once the Scalar is at 1.0f..
		else
		{
			//Clear the Timer Handle
			MatInst->SetScalarParameterValue(FName(TEXT("Opponent_Fade")), 2.f);
			GetWorld()->GetTimerManager().ClearTimer(FadeHandle);
		}
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Turquoise, "DID NOT FIND MATERIAL INST");
	}
}


I’m not 100% sure why this is happening. but I was curious if there was a way to prevent the 1/15 chance of this sort of thing happening?

I managed to solve this issue. The Render texture and the character texture were fighting for which will be rendering on the top from the “Translucency Sort Priority” Tab. I set this up now and it works like a charm now :).

20f3436f6f83a189940420953d94ba072db1e055.jpeg