How to properly project a moving texture onto a mesh?

Hey everyone,

I’m using a decal to project a simple circle texture onto level geometry. Everything’s fine, until the decal is moved around the world:

(Please watch video on YouTube, not here, and set to HD - otherwise, you won’t notice the artifacts):

The decals are flickering, and I’m noticing a very short fade-in time when creating them. Does anyone know how to change that, or is aware of any more fitting way of projecting the texture?

Here’s my current setup:

DecalTexture (Simple texture with alpha)

DecalMaterial (Simple material coloring the white texture, applying its alpha, and blending the decal in translucent mode)

Character with DecalComponent (Rotated downwards, so the texture is projected onto the world)

The decal size is adjusted to fit the character size at run-time:


void ARTSCharacter::BeginPlay()
{
	Super::BeginPlay();

	// ...
	SelectionCircleDecalComponent->DecalSize = FVector(
		GetCapsuleComponent()->GetCollisionShape().Capsule.HalfHeight * 2,
		GetCapsuleComponent()->GetCollisionShape().Capsule.Radius * 2,
		GetCapsuleComponent()->GetCollisionShape().Capsule.Radius * 2);
}

Then, it’s moved along with the character every frame:


void ARTSCharacter::Tick(float DeltaSeconds)
{
	// ...

	if (bSelected)
	{
		SelectionCircleDecalComponent->SetWorldLocation(GetActorLocation());
	}
}

EDIT: This is an open-source project. You can take a look at all assets and code at GitHub - npruehs/ue4-rts: Real-time strategy plugin and showcase for Unreal Engine 4.

Instead of setting the location each tick, attach the decal component to the root component and hide / unhide it as necessary. I’m not sure if this will fix the problem, but it’s worth a shot.

It’s probably due to temporal AA. The decal material has a property called “sharp AA” or something that should alleviate this problem.

The decal component is already attached. I was able to remove the code from Tick, and it would still update its position - but it’s still flickering as well.

I’ve found a property “Reponsive AA”, but that’s disabled (i.e. unchecked and I can’t check the checkbox).

I’ve also updated to Unreal 4.16.2, hoping for a fix, but nothing changed.

Also, I’ve taken a look at this Open-Source RTS game:

They are using the same approach, with a decal material looking as follows:

However, that one was made in Unreal 4.11.2. I’ve tried to copy the material in 4.16.2:

Now, the material won’t even compile, and stop showing a pre-vis:

ShaderCompilerError.png

Has something changed with decals in the latest engine updates?