Can Scene Capture 2D render only part of the viewport?

Hi, I’m implementing a portal effect and I’m using scene capture 2D in order to generate the portal’s destination: https://youtu.be/6QCgtk4MpJ8

I’m concern about rendering optimization where the problem is that the portal may be far way, but the scene capture component will always be rendering the entire screen to the render target texture…

Is there any way I can specify only part of the viewport to be rendered by the scene capture component? Maybe using rectangle coordinates (x1,y1,x2,y2) so the scene capture will not render things that are outside the portal bounds and therefore will be discarted.

Thanks!

I think what you’re looking for is the max view distance on the Scene Capture 2D.

On a side note, I’m curious on how you lined up the portal’s views relative to your character’s position if you’re willing to explain

It’s not view distance… I hope the attached image will make my point.

About the positioning, there’s no mystery about it, each portal just take the relative transform of the player from it and apply it to the target portal rotating by 180º around it root component.

im having an issue with rotating the capture components. no matter what rotation i give them they stay the same.

I think your attached image does not show, how your Scene Capture Component in this view actually works. If I understand your setup correctly, your SCC should be attached to your portal itself, so it will actually capture “through the eyes” of the target portal, and not through your eyes, like in your image. However, you’re right, that there is a lot of overhead due to the relatively small screen size of your portal compared to the capture size behind it.

If you somehow want to optimize your screen component capture efficiency, playing with your render targets resolution might improve results. I don’t think, that you can tell your Scene Capture Component to somehow “do not capture” specific parts of your scene, at least I’m not familiar with a way to do that. :confused: Especially since you would have to adjust this area each time your player moves and it’s view angle changes.

I don’t think there is an option to render only part of the viewport, but I would be happy with any direction on what to change in the engine in order make that feature… or even a “it’s not possible” from any UE4 staff would be good too. :stuck_out_tongue:

Hey, resurrecting this post 5 years later!
Did you ever find out a solution or even a alternative to this problem? I’m struggling to get my portals more performative at the moment and thought the very same thing might work.

Unfortunately not, I left this project behind, I hope you find the solution for it!

That’s a shame, thanks for the swift reply though!

I figured out a way to do this. You can control how much of the viewport is rendered by changing the Field of View of the Scene Capture Camera.
image

However, this normally causes the view to be zoomed in. You can adjust for this (basically undo the zoom) by scaling your texture coordinates in the material. Here’s the formula for scaling your texture coordinates based on the field of view angle (FOV) of your scene capture camera:

tan(captureCameraFOV/2) / tan(playerCameraFOV/2)

This gives you the scale factor that you need to apply to the scene capture image in order to remove the zoom effect.

Here’s what my blueprint looks like that calculates the scale factor:

To apply this to your texture’s UV coordinates, you actually need to invert this though…

Lastly, I apply this scale factor to the UVs in my material:

It works well, and gave me a few more frames-per-second.

Another tip is to make sure the scene you’re capturing is optimized. I gained an additional 5 fps by removing unneeded dynamic lights!