Download

Quad buffer stereo and using separate render targets

Hi everyone!

I am relatively new to Unreal and am trying to write a plugin that enables quad buffer stereo rendering.
So far I have been looking at the Documentation, Engine Source and the HMD Plugins and after some experimenting it seems that it should not be hard (I am using OpenGL since I work mostly on Linux and Unreal 4.18).
I got the quad buffer stereo rendering itself to work. By that I mean that I can copy images into the back_left and back_right buffer and swap accordingly (using a custom present). So the basic output is there.
In order to copy to the left and right backbuffer, I first have to render two separate images (for left and right eye of course). My approach for this was to create a separate render target that is large enough to hold both images side-by-side and the copy the regions for the left and right eye into the corresponding backbuffers. However, I cannot get rendering into the separate render target to work.

Here is what I did:
I implemented a custom StereoRenderingDevice (inheriting from IStereoRendering). This seems to work fine as far as I can tell.
The second step was to implement a custom RenderTargetManager (inheriting from FXRRenderTargetManager). As FXRRenderTargetManager provides most of the implementation already, this should be a really short class (all I want it to do at this point is to create my very own render target):
class StereoRenderTargetManager : public FXRRenderTargetManager
{
public:
bool ShouldUseSeparateRenderTarget(void) const override {return true;};
};

The last modification required should be in the StereoRenderingDevice class:
IStereoRenderTargetManager * GetRenderTargetManager() override {return pointer_to_stereo_render_target_manager_object;};

And again, this works for the most part as the any function I implement in StereoRenderTargetManager gets called. The problem is: as soon as I have ShouldUseSeparateRenderTarget return true, all I get is a black output. No matter what I try. If I use the default render target I get a lovely image, if i use a separate one all I get is black.
I already tried removing my custom present (did not work), using BlitFramebuffer to copy from the render target to the backbuffer directly (did not work), implementing the AllocateRenderTargetTexture function for StereoRenderTargetManager myself (did not work), … I am currently out of ideas and any help would be very much appreciated!

Some additional info: since I tried using a custom present I checked the size of the render target in the viewport. When I have ShouldUseSeparateRenderTarget return true and implement CalculateRenderTargetSize, then the size of the render target changes correctly. This leads me to assume that the render target gets allocated correctly. But for some reason it is either not written to or I cannot read from it or something like that …

Best regards,
Thomas

Hello, have you solute this question?