What is the sanest way to implement a 3d skybox that moves with the player?

Specifically I’m talking about the kind of skybox that remains at an infinite distance regardless of your position in the level.

UE4’s included examples (like the sky dome or the distant ShooterGame cityscape) are all based on the assumption that the player will remain within a level’s confines, and that the scale of those confines is much smaller than the distance to the vista. I’m working on a game that takes place in an infinitely generated area and involves fast, long range player movements, so this solution isn’t viable.

My current solution involves making a vista actor that simply snaps to the player’s XY location every frame. This seems inefficient to me, because the assets are still moving and then getting snapped back into place every tick (it also causes noticeable jitter at low framerates). Worse is the fact that they are still dynamic objects and therefore missing out on a lot of very significant rendering optimizations. This method also won’t work in multiplayer games.

Does anyone know if there’s a better way? For that matter, does anyone know if there are plans for a “built in” solution like the Source engine (AFAIK) has?

I think the Source engine has a skybox vertex shader that assumes the camera is in the center of the skybox and only uses the cameras rotation (and scale I suppose) to create the viewprojection matrix. This would be my suggestion as well, though I don’t know how easy it would be to implement in UE4. A dirty solution would be to actually move the camera to the skybox and then back to the player.

I never thought of doing it in a shader! That’s clever as it will mean that static lighting will still bake properly without further setup.

I still see a few potential issues with this for my particular use case:

  • There’s nowhere to put the skybox in the level that the player can’t hypothetically reach.
  • Shadows can’t be cast from the skybox onto the playing field, and my skybox has towering buildings that can block the sun.
  • This method would probably mess up particle effects and such, and my skybox also uses those, often at close range (there’s a thick layer of smog and traffic beneath the player at all times that acts as a visual representation of the kill volume).