Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Jerware's avatar
Jerware
Explorer
12 years ago

Better Skybox solution?

I'm dealing with a rather large outdoor terrain, and the "Tuscany" skybox solution is far from perfect. If players travel far enough they walk right up to the side of the box. I could connect the box to the player, but then it clips the terrain in the distance. I can't enlarge the box/camera clip plane much further (already 2000x2000) or I risk poor performance on slow PCs.

Can anyone suggest a better solution? Does it seem like Unity might fix the real skybox?

10 Replies

Replies have been turned off for this discussion
  • Don't have my devkit yet and I have not looked at the SDK from Oculus but is it possible to use a "different" skybox for each camera (eye)? Could you have 2 prefabs that are identical and assign one skybox prefab to each eye?

    Just wondering if you have maybe tried this approach if it's feasible.
  • I'll defer to the Unity experts, but I don't think it's possible to apply unique Skyboxes to two different cameras (each eye is a camera). I suppose you could try creating two sets of cameras, and have one render only the background skybox and the other the terrain, using culling masks... but this seems like a waste of resources. Might be worth a shot though.
  • My initial thought was to create new camera, in position with the camera controller, with a skybox and set the output to a render texture. Then map the render texture to something like a very distant plane sized to fit the stereo cameras' FOV, essentially compositing in a sky 'plate'. The basic setup seems to work ok, at least for a quick hack. I don't know how to get the plane to bypass the fog settings, but my Unity knowledge isn't all that great.
  • "Jerware" wrote:
    I'll defer to the Unity experts, but I don't think it's possible to apply unique Skyboxes to two different cameras (each eye is a camera). I suppose you could try creating two sets of cameras, and have one render only the background skybox and the other the terrain, using culling masks... but this seems like a waste of resources. Might be worth a shot though.


    You can do it actually, but it has the same problem as assigning a scene-level skybox as far as I can tell.
  • If you use an actual box with inverted normals then you can just attach it to the player as long as it is just inside the cameras draw range it should work.

    Although with good stereoscopic you might be better off with a sky sphere.

    You might also need some fog to hide where the box/sphere cuts through the terrain.
  • Yes. Unfortunately the default Unity skybox is unusable in the Rift, and the Oculus example skybox is not perfect either.

    One possibility is to have 2 sets of cameras in the same position and updated in code to have the same orientation. Then you could render the sky on one layer (for cameras 1 & 2) and then have the world rendered on a different layer (for cameras 3 & 4). You'd also have to remove the lens effects from cameras 1 & 2 (i.e distortion). It's a little hackish, but maybe worth looking into.

    The skybox solution we are providing can certainly be improved, and it's something we can look into. I just don't know when we will find a better solution to this.

    Hope that helps.
  • Not using Unity myself, but I have found that a sky sphere attached to the player works great.
  • "Jerware" wrote:
    I'm dealing with a rather large outdoor terrain, and the "Tuscany" skybox solution is far from perfect. If players travel far enough they walk right up to the side of the box. I could connect the box to the player, but then it clips the terrain in the distance. I can't enlarge the box/camera clip plane much further (already 2000x2000) or I risk poor performance on slow PCs.

    Can anyone suggest a better solution? Does it seem like Unity might fix the real skybox?

    Wow, when I replied above I totally misunderstood your question...

    I'm a Unity noob but with DirectX you could clear the Z buffer, then render a skybox with z buffering turned off. Your skybox could be very small. Then you would turn z buffering back on and any additional rendering would simply draw over the skybox.

    I'm planning on creating a large outdoor environment myself with unity for the rift (when i get it) so I will have to find a solution to this as well.

    I just took a quick look at the shader features of unity and I'm guessing there must be a way to clear the z-buffer (or depth buffer), draw a small skybox without z-buffering and then render everything else.

    Of course, that's assuming there is a way to specify the render order of game objects in unity... I haven't looked into that yet.
  • Thanks, Arowx. Looks like there might be a solution to the SkyBox issue after all...