Forum Discussion
ChrisM545
12 years agoHonored Guest
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:
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:
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.
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.
4 Replies
Replies have been turned off for this discussion
- cyberealityGrand ChampionCool!
Does the 3D of the sky still look correct on the Rift, though? - ChrisM545Honored Guestyes it does. in the editor it may get confusing when you fly past the cube as its rendered out of order.
- pcProfieHonored Guesthi, 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 - brendenfrankHonored Guest
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 12 years ago