# Realistic mirror reflection vector with SceneCapture actor?

**URL:** <https://forums.unrealengine.com/t/realistic-mirror-reflection-vector-with-scenecapture-actor/117975>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 26, 2018, 3:30am UTC](https://forums.unrealengine.com/t/realistic-mirror-reflection-vector-with-scenecapture-actor/117975 "2018-10-26T03:30:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [October 26, 2018, 3:30am UTC](https://forums.unrealengine.com/t/realistic-mirror-reflection-vector-with-scenecapture-actor/117975/1 "2018-10-26T03:30:25Z")

</div>

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

> <https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector>

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.

```auto

   // 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);

```

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [October 29, 2018, 1:41am UTC](https://forums.unrealengine.com/t/realistic-mirror-reflection-vector-with-scenecapture-actor/117975/2 "2018-10-29T01:41:58Z")

</div>

FYI, key to making mirror realistic - modify FOV of mirror camera based on view distance. Wider FOV when viewer is close. Narrow FOV when viewer is far away.
