Hi Everyone,
I am trying to render in side-by-side stereo. I am using -emulatestereo to allow this but have had to edit the FOV so that the stereo is at an acceptable level by changing variables in UnrealEngine.cpp > CalculateStereoViewOffset() and GetStereoProjectionMatrix()
I am not a C++ programmer and have very much stumbled through the process but I have it looking how I want it to look. A previous post had suggested creating a custom module but I think this is way beyond any small understanding I might have!
The problem I’m having is that I can’t edit the variables without having to rebuild so I was hoping it would be possible to expose them and have access either in the editor or ideally after I have packaged the project.
Here is the section of UnrealEngine.cpp that I am having to edit
virtual void CalculateStereoViewOffset(const enum EStereoscopicPass StereoPassType, const FRotator& ViewRotation, const float WorldToMeters, FVector& ViewLocation) override
{
if( StereoPassType != eSSP_FULL)
{
float EyeOffset = 3.20000005f;
const float PassOffset = (StereoPassType == eSSP_LEFT_EYE) ? EyeOffset : -EyeOffset;
ViewLocation += ViewRotation.Quaternion().RotateVector(FVector(0,PassOffset,0));
}
}
virtual FMatrix GetStereoProjectionMatrix(const enum EStereoscopicPass StereoPassType, const float FOV) const override
{
const float ProjectionCenterOffset = 0.151976421f;
const float PassProjectionOffset = (StereoPassType == eSSP_LEFT_EYE) ? ProjectionCenterOffset : -ProjectionCenterOffset;
const float HalfFov = FMath::DegreesToRadians(FOVInDegrees) / 2.f;
const float InWidth = Width;
const float InHeight = Height;
const float XS = 1.0f / tan(HalfFov);
const float YS = InWidth / tan(HalfFov) / InHeight;
const float InNearZ = GNearClippingPlane;
return FMatrix(
FPlane(XS, 0.0f, 0.0f, 0.0f),
FPlane(0.0f, YS, 0.0f, 0.0f),
FPlane(0.0f, 0.0f, 0.0f, 1.0f),
FPlane(0.0f, 0.0f, InNearZ, 0.0f))
* FTranslationMatrix(FVector(PassProjectionOffset,0,0));
}
I would like to have access to EyeOffset, ProjectionCenterOffset, InWidth and InHeight