Thanks to RVillani and NoobsDeSroobs, this is now working ([Animated GIF; 47.2MB][1]).
I basically used the set-up suggested by RVillani, exposing UOffset
and VOffset
as parameters and then using a Material Instance for the starfield material.
The base C++ CameraActor class does the movement:
FVector Position = GetActorLocation();
FVector Diff = Position - LastPosition;
LastPosition = Position;
if (StarfieldMID) {
float UOffset, VOffset;
if (StarfieldMID->GetScalarParameterValue(TEXT("UOffset"), UOffset) &&
StarfieldMID->GetScalarParameterValue(TEXT("VOffset"), VOffset)) {
UOffset += Diff.X * UVOffsetScale;
VOffset -= Diff.Z * UVOffsetScale;
StarfieldMID->SetScalarParameterValue(TEXT("UOffset"), UOffset);
StarfieldMID->SetScalarParameterValue(TEXT("VOffset"), VOffset);
} else {
UE_LOG(LogGame, Error, TEXT("[%s] Failed to get U/V offset parameter values"), *GetName());
}
}
and the blueprint-subclass creates the Material Instance Dynamic in the BeginPlay event and passes it to the base class:
I don’t think using a Material Parameter Collection was at all straight forward and I didn’t see what advantage it gave me over a material instance as I will be adding a total of 3 textures to the starfield to give a parallax effect and MPCs seem to be global, unless I have misunderstood their use? Thanks anyway for the suggestion.