Expose C++ Variable to Editor

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


Yes UnrealEngine.cpp it’s around line 1900.
I basically want Side-by-Side stereo without the HMD distortion and to allow for Eye Separation and the Convergence Point to be set at runtime.



Are you sure this is UnrealEngine.cpp? the functions you pointing seems to be from HMD interface (support for specific VR headsets), each VR headset support has it own override of those functions, so you would need to change each of them in order for your modifications to work on each headset. Maybe say what you want to modify in it, maybe there less invasive ways to do it

I have managed to expose the variables so that I can set them through the console which is good enough for now using TAutoConsoleVariable
If I set the variables using ConsoleVariables.ini it works perfectly but if I set the variables through the console itself, the view doesn’t update. I’m guessing I need to reinitialize the StereoRenderingDevice so I created a delegate to run a custom function to try.
The custom function runs fine and prints a message on screen but I can’t work out how to reset the StereoRenderingDevice.
I tried GEngine->StereoRenderingDevice.Reset(); but this didn’t work (I think because I never explicitly set StereoRenderingDevice to FFakeStereoRenderingDevice)

Could someone please tell me how I can force the update of the StereoRenderingDevice

Many Thanks,