How do I invoke DrawDistortionMesh_RenderThread()?

Hi there, I am going to implement a Plugin to support a new HMD from SimpleHMD sample.

The function SimpleHMD::DrawDistortionMesh_RenderThread() is going to generate a distortion mesh for HMD rendering, it’s a virtual function inherited by FRCPassPostProcessHMD::Process(FRenderingCompositePassContext& Context), which is call by Post-processing stage of engine’s rendering thread.

The plugin’s virtual function doesn’t call when I enable this sample plugin, my question is how can I invoke this functions so that I can implement my distortion on the scene?

The DrawDistortionMesh_RenderThread() function is called from FRCPassPostProcessHMD::Process(). That’s invoked in PostProcessing.cpp, in the following block:

		bool bStereoRenderingAndHMD = View.Family->EngineShowFlags.StereoRendering && View.Family->EngineShowFlags.HMDDistortion;
		bool bHMDWantsUpscale = false;
		if (bStereoRenderingAndHMD)
		{
			FRenderingCompositePass* Node = NULL;
			const EHMDDeviceType::Type DeviceType = GEngine->HMDDevice->GetHMDDeviceType();
			if(DeviceType == EHMDDeviceType::DT_OculusRift)
			{
				Node = Context.Graph.RegisterPass(new FRCPassPostProcessHMD());
			}

As you can see there, you’ll need to have a few things enabled to do the distortion pass. Assuming stereo is already enabled, you also have to have your View.Family->EngineShowFlags.HMDDistortion set (which you can do in your HMD’s ::SetupViewFamily() member). You’ll also have to report as DT_OculusRift for the time being. The only thing that affects is this distortion call. That will be renamed in the future, but for now, reporting back as that time will allow you to get the distortion mesh.

Hope that helps!