Toggling visibility of an in-game display when it's not in view of the player?

I’m working on building an ingame digital-camera feature, where the LCD screen shows the live feed of a SceneCapture 2D (acting as the digital-camera lens).

I have that part working fine, except for, when the digital-camera is pointed at an angle that is opposite to the player camera, there are performance drops. I assume this is because the digital-camera is forcing what is behind the player to render; so the game is rendering a ton of stuff that would usually be culled.

What would be the best way to turn the visibility of the SceneCapture on and off, depending on whether the digital-camera LCD screen can be seen by the player? This would ideally include when it is at an angle that the player can’t see (i.e, if you’re taking a ‘selfie’) and if the digital-camera is outside the FOV of the player camera.

On top of this, are there any other performance gains I could make? As far as I know, the SceneCapture 2D node can not be manually updated, is that right? So I can’t give it its own ‘framerate’ of 30fps if the game is running at 60fps?


I too am rendering stuff not-on screen and I’m not seeing any major performance hits. I create a camera in the world and attach it to an object, then render that output to the top-right of the screen as a UMG element (RenderTexture), even if I turn away so that it’s not in my main viewport, I don’t see any major drops and the capture is relatively large (500 * 400ish I think).

I’m not sure about fixed framerate scene captures, mine appears to render at the same rate as the rest of the game.

Thanks for the reply. That’s curious, I don’t know how that wouldn’t affect performance. When you say you don’t see any drops, are you talking about frame rate per second?

Here’s a breakdown of my scene rendering:

Camera facing the same direction as player (visibility of the SceneCapture on)

Camera facing the opposite direction direction to player (visibility of the SceneCapture on)

Note the dramatic millisecond increase of the top three stats, and the drawcalls increase.

And an extreme case, where the player is looking out towards the landscape, and the camera is facing the opposite direction towards a building:

And now with the visiblity of the SceneCapture OFF, we see draw calls drop from 818 to 56 and huge gains in frame-time.

All this time spend rendering and displaying the view behind you is wasted, as you can’t see the camera’s LCD screen when turning the camera at such an angle.

I haven’t gone that into depth with it since it still runs well over 120 FPS for me, that’s on a 980 though. I’ll look into this later and see how much damage it’s really doing.

818 calls does seem insanely high mind you, you’re not re-creating a render target every frame or anything are you?

Don’t worry about those drawcalls; the camera was then looking at a campus with 3 large buildings, each with detailed interiors. The facades aren’t complete on them yet, so less of the interior is being culled than it should be. :slight_smile: I’m not re-creating a render target per frame, the camera is rendering to a single target each frame, which is then applied as a shader to the camera’s screen.

In any case, I am positive that my initial idea of deactivating the SceneCapture’s visibility when it’s facing opposite to the player camera will work, so my original question of the best way to achieve that still stands, if anyone has any suggestions.