public void Init()
        {
            ScaledCloudMaterial = new Material(CloudShader);
            CloudMaterial = new Material(CloudShader);
            CloudParticleMaterial = new Material(CloudParticleShader);

            if (scaledShaderFloats == null)
            {
                scaledShaderFloats = GetDefault(true);
            }

            if (shaderFloats == null)
            {
                shaderFloats = GetDefault(false);
            }

            Texture2D tex1 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/1", false);
            Texture2D tex2 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/2", false);
            Texture2D tex3 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/3", false);

            tex1.wrapMode = TextureWrapMode.Clamp;
            tex2.wrapMode = TextureWrapMode.Clamp;
            tex3.wrapMode = TextureWrapMode.Clamp;

            CloudParticleMaterial.SetTexture("_TopTex", tex1);
            CloudParticleMaterial.SetTexture("_LeftTex", tex2);
            CloudParticleMaterial.SetTexture("_FrontTex", tex3);
            CloudParticleMaterial.SetFloat("_DistFade", 1f / 2250f);

            Log("Cloud Material initialized");
            UpdateTextures();
            Log("Generating Overlay...");
            CloudOverlay = Overlay.GeneratePlanetOverlay(body, altitude, ScaledCloudMaterial, CloudMaterial, this.mainTexture.StartOffset);

            if (useVolume)
            {
                CloudOverlay.MacroCallback = MacroCallback;
                CloudOverlay.DominantCallback = DominantCallback;
            }

            UpdateFloats();
            Log("Textures initialized");
        }
 public void CloneForMainMenu()
 {
     if (MainMenuClone == null)
     {
         MainMenuClone = GeneratePlanetOverlay(this.Body, this.altitude, this.scaledMaterial, this.macroMaterial, this.Rotation, true);
     }
 }
        public void UpdateRotation(Vector3 rotation)
        {
            float tmp = rotation.x;
            rotation.x = rotation.y;
            rotation.y = tmp;
            OverlayGameObject.transform.Rotate(360f * rotation);

            if(MainMenuClone != null)
            {
                if (MainMenuClone.OverlayGameObject != null)
                {
                    MainMenuClone.UpdateRotation(rotation);
                }
                else
                {
                    MainMenuClone = null;
                }
            }
        }
        public static Overlay GeneratePlanetOverlay(String planet, float altitude, Material scaledMaterial, Material macroMaterial, Vector2 rotation, bool mainMenu = false, bool matchTerrain = false)
        {
            Vector2 Rotation = new Vector2(rotation.x, rotation.y);
            Rotation.x += .25f;

            Transform celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == planet);
            Overlay overlay = new Overlay(planet, altitude, scaledMaterial, macroMaterial, Rotation, OverlayMgr.MAP_LAYER, celestialTransform, mainMenu, matchTerrain);
            if (!mainMenu)
            {
                if (!OverlayDatabase.ContainsKey(planet))
                {
                    OverlayDatabase.Add(planet, new List<Overlay>());
                }
                OverlayDatabase[planet].Add(overlay);
                OverlayList.Add(overlay);
            }

            if (mainMenu)
            {
                overlay.EnableMainMenu();
            }
            else
            {
                overlay.UpdateTranform();
            }
            overlay.SetRotation(Rotation);
            return overlay;
        }