I have not tested this myself, but I think you can achieve something like this by using two viewports, where one viewport renders the space "background", and another renders the player/world scene.
In your "background" Viewport you place the scene you want to render and all of the objects you want to be in the background, like the sun. It will need own world
enabled so the nodes don't interfere with the player/world. You'll also want a WorldEnvironment
node with the space skybox in the background scene. Finally, you'll probably want to write a script that syncs the rotation of the "background" Viewport Camera node with the player/world scene Camera, so as the player rotates the view of the background changes.
Then in the world/player scene, you'll want to create a WorldEnvironment
with the background set to Canvas
. Then make a TextureRect node that uses a the "background" Viewport texture. This should make the background of the world/player scene be what the "background" Viewport sees. To make it where other Control/UI nodes are not drawn on the background, just set the Max layer
(or whatever it is called) on the WorldEnvironment
background to something like 1
and then place all of the Control/UI nodes on a CanvasLayer with the layer set to 2
.
Another thing you could try is a similar dual Viewport setup, but instead of using a WorldEnvironment
node, write a simple shader instead. For this to work, I think you'll need to enable transparent bg
on the root viewport. Then you just need to have a TextureRect node that takes the "background" Viewport texture and the SCREEN_TEXTURE
, and overlays them together.
That is what I would try. I'm not sure how feasible either idea is, nor how easy they would be to implement, but that is what I would try. Using two Viewport nodes function similar to how Valve's 3D skyboxes work in the Source engine.
If you want, I can see if I can make a quick prototype once I have the time.