Skip to main content
New Participant
June 4, 2013

Unity SkyBox Solution

I had the same problem many people where having here, using the Example Oculus Sky box solution and having it clip large terrain at a distance.

The solution is to use use a shader that is set to "Queue"="Background" and ZWrite off for the sky box materials.

Here is the shader I modified:

Shader "Unlit/Vertex Color Multiply Background" {

Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
}

Category {
Tags { "Queue"="Background" }
ZWrite Off

Lighting Off
Fog {Mode Off}

BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}

SubShader {
Pass {

SetTexture [_MainTex] {
Combine texture
}

SetTexture [_MainTex] {
constantColor [_Color]
combine previous * constant
}
}
}
}
}


I use it by dragging the /Assets/Tuscany/Models/Prefabs/Skybox.prefab in to my scene, I replaced each material to use the above shader

I also created a script that makes the skybox copy my OVRCamera position but not its rotation:

using UnityEngine;
using System.Collections;

public class MatchPosition : MonoBehaviour {

public Transform ParentPosition;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
if(ParentPosition !=null)
this.transform.position = ParentPosition.position;
}
}


So this way you can make the sky box small, encompassing both cameras and it will draw first before the entire scene without updating the zbuffer. Also i set both cameras Clear Flags property to Depth Only, since the background will clear the color buffer, you save a little bit of render time.
    This topic has been closed for replies.

    4 replies

    Inspiring
    June 4, 2013
    Cool!

    Does the 3D of the sky still look correct on the Rift, though?
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    ChrisM545Author
    New Participant
    June 4, 2013
    yes it does. in the editor it may get confusing when you fly past the cube as its rendered out of order.
    New Participant
    August 5, 2013
    hi, i also have problems with the skybox. i can see the moon and clouds 2 times :(. my english is not sooo good so i can't understand how to fix it. can you please say what i should do? thanks

    pcProfie
    Up and Coming
    August 5, 2013
    pcProfie,

    Have a look at this thread: viewtopic.php?f=37&t=844