I would like to bring this issue back. I have been looking for a solution for this as well. If used properly this does not have any negative effects to the user. Please, lets focus on finding a solution to where this can be implemented and tested, rather than arguing about if it should be done.
Primary Question:
Where/how can we implement zoom in VR using the main camera (no render targets)?
I have found by modifying the SteamVRHMD class I can scale the planes rendered in the stereo projection matrix.
The problem with this, is that is messes with the distortion needed to render VR properly as it is scaling the image AFTER the distortion is applied and the scene starts to look a little flat.
I am trying to find a way to zoom/scale or change the FOV earlier in the pipeline. Please, anyone with ideas or knowledge of how to accomplish this, share how this can be done. Thank you!
What I’ve done:
UE 4.24
Engine/Plugins/Runtime/Steam/SteamVR/Source/SteamVR/Private/SteamVRHMD.h:194
ADD:
float MatrixPlaneMultiplier = 2.0f;
Engine/Plugins/Runtime/Steam/SteamVR/Source/SteamVR/Private/SteamVRHMD.cpp:1468
UPDATE TO:
FMatrix Mat = FMatrix(
FPlane((MatrixPlaneMultiplier * InvRL), 0.0f, 0.0f, 0.0f),
FPlane(0.0f, (MatrixPlaneMultiplier * InvTB), 0.0f, 0.0f),
FPlane((SumRL * InvRL), (SumTB * InvTB), 0.0f, 1.0f),
FPlane(0.0f, 0.0f, ZNear, 0.0f)
);
Engine/Plugins/Runtime/Steam/SteamVR/Source/SteamVR/Classes/SteamVRFunctionLibrary.h:70
ADD:
UFUNCTION(BlueprintCallable, Category = "Steam VR Camera")
static void SetMatrixPlaneMultiplier(float Multiplier);
Engine/Plugins/Runtime/Steam/SteamVR/Source/SteamVR/Private/SteamVRFunctionLibrary.cpp:39
ADD:
void USteamVRFunctionLibrary::SetMatrixPlaneMultiplier(float Multiplier)
{
FSteamVRHMD* SteamVRHMD = GetSteamVRHMD();
if (SteamVRHMD)
{
SteamVRHMD->MatrixPlaneMultiplier = Multiplier;
}
}
Then in BP you can LERP between something like 2 and 8 to get a smooth zoom effect in VR. As mentioned, the issue is the scene starts to look a little flat.