Correct way to display two cameras

Hey guys!

After some time trying to get a dynamic split screen, I have managed to get it to work the way I want (some things need polishing, but I have it working)

But I wonder if it is the right way to do it, if there is not a better option in terms of performance, finishes,…

Basically, I have a camera in the middle of the two characters, and when they move away, I show a widget with two images. Each image has a Render Target, and each Render Target is loaded with a SceneCaptureComponent2D.

Also, one image is on top of the other, and with a material, I hide part of the image so that the one below is visible, which does the dynamic camera trick.

I feel like this is not optimal at all, that I should be able to use two cameras instead of capturing scenes to a Render Target and displaying them from the UI…

Anybody know about this? Any tip?

1 Like

This is similar to my post about rendering Secondary Views. It gets much more complex if you don’t want to use SceneCapture2Ds. At least in what I am trying to do. :confused:

I haven’t figured it out yet. If I do I will let you know and help you set up something with your setup.

1 Like

Thanks mate! I didn’t see your post before.

I’ll keep trying things out, I’ll let you know if I see anything too.

Hopefully someone who knows about this will check out our posts.

complex issue.

down in the engine you could use a stencil operation to limit each scene render in the raster stage. you’d have to prefill the rendertarget or the main backbuffer with the “splitter shape” and a simple stencil value of 0 or 1.

when rendering each scene camera view you raster only what is stencil_ref 0 or stencil_ref 1 per respective view. you still render 2 views but should have a single pixel output for both segments, no overdraw.

1 Like

So, it seems inevitable to use RenderTarget to get more than one camera at the same time, right?

If I understood correctly, the only difference is that instead of using two images, one on top of the other, I use only one loading the information according to the stencil channel, right? I’ll try this way too. Thanks!

So, maybe I should also use RenderTarget in the non-split view, because when switching from the camera to the RenderTargets the lighting is not exactly the same and it looks weird…

I wonder if the engine’s default split screen uses Render Target to get more than one camera…

a straight rectangular split screen would internally use RSSetViewports that has a D3D12_VIEWPORT and rectangles provided for each camera view, or it would render it back to back with each viewport set.

you doing it this slanted way is complicating it a lil bit, tbh. needs some hacks to do that fancy thing and only draw everything once. hmmhmm.

a rendertarget in fullscreen will double that. yes.

to fix the lighting difference you gotta enable lumen in the scene capture seperately. this is an intentional control setting for performance reasons.

2 Likes

I have read and followed the instructions to use 2 cameras like that. Thank you.

1 Like

Hi,

Assuming I have to use RenderTarget, the best I have so far is to use a single image to display both cameras with 2 render targets.

In the material assigned to my image (UI) I have 2 render targets (as parameters), and each one is displayed only when the pixel is closest to its associated character (I use some 2d coordinates of where each character is as parameters).

to fix the lighting difference you gotta enable lumen in the scene capture seperately

About lighting, I disabled Lumen in my project and it has some differences in results… :frowning: