UPDATE 2017-09-29:
I found a very useful Tutorial on creating VR Skyboxes. Check it out: https://medium.com/aol-alpha/how-to-design-vr-skyboxes-d460e9eb5a75
Change the Skybox in Unity via Code? This is how it is done. If you want to set the Skybox (manually / not via code) in Unity use:
Edit -> Render Settings and there you can change the Skybox (Das steht zwar in der Doku… Aber scheint falsch zu sein)
Go to Window > Lighting > Scene > Environment Lighting > Skybox
Ok – lets start… But first… RTFM đ :
https://unity3d.com/de/learn/tutorials/topics/graphics/using-skyboxes
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChangeTheSkybox : MonoBehaviour { //Modified code from: https://forum.unity3d.com/threads/changing-skybox-material-through-script.125672/ public Material mat1; public Material mat2; void OnGUI() { if (GUI.Button(new Rect(100, 100, 100, 20), "Material 1")) { RenderSettings.skybox = mat1; } if (GUI.Button(new Rect(100, 130, 100, 20), "Material 2")) { RenderSettings.skybox = mat2; } } }
For the Quick and Dirty test I used the Skyboxes from the DramaticSkies_SkyboxCollection. Have Fun.
Important: This is not “creating the material” via sourcecode. But this can be found here…
http://stackoverflow.com/questions/33463783/change-material-image-texture-from-sphere-with-script
Each side of the SkyBox is 2048×2048 in my dummy scene. (8192 Pixels for 360° on the horizontal axis)
The input panorama is using a different size and areas overlap
I chopped / sliced the CardBoardCam 360° Panorama with Gimp into 4 pieces.
1) Define the Slices (25%) with Define Image > Guides > New Guides (by Percent) at 25% 50% 75% horizontal and vertical resp.
2) Guillotine Tool: Apply Image > Tranform > Guillotine
GuillotineTool in Gimp: http://graphicdesign.stackexchange.com/questions/30008/crop-a-big-picture-into-several-small-size-pictures
Afterwards I created a new material in Unity, changed it to 6 sided Skybox and added the slices. (Had a problem with “left and right” – but I guess this is depending on the “point of view”)
IMPORTANT:
Import the Skybox images with… Wrap Mode set to Clamp rather than Repeat (if you don’t do this, the edges of the images will not meet up seamlessly).
https://unity3d.com/de/learn/tutorials/topics/graphics/using-skyboxes