Situation: have a mirror surface with a SceneCapture behind it. I am calculating the reflection vector using the standard:
r = d-2(dot(d,n))n
It works great but something seems slightly “off” about the reflection when compared to a material using Planar Reflection. Is the proper way to do a mirror using a standard reflection vector? Or is material Planar Reflection some kind of “fake” that isn’t quite realistic so comparison is invalid?
Code here. Calculation is done in the mirror actor which controls a scene capture actor.
// get player viewpoint
FVector playerCamPosition;
FRotator playerCamRotation;
_playerController->GetCameraLocationAndRotation(playerCamPosition, playerCamRotation);
// calculate reflection vector: r = d-2(dot(d,n))n
// n = mirror forward vector
// d = player vector to mirror
// r = reflection vector
FVector n = GetActorForwardVector();
n.Normalize();
FVector d = GetActorLocation() - playerCamPosition;
d.Normalize();
FVector r = d - 2 * (FVector::DotProduct(d, n)) * n;
// set scene capture camera angle and draw debug line
_sceneCapture2d->SetActorRelativeRotation(r.Rotation());
FVector lineStart = GetActorLocation();
FVector lineEnd = GetActorLocation() + r * 20.0f;
DrawDebugLine(GetWorld(), lineStart, lineEnd, FColor::Red);