void RestyleEarth()
        {
            if (gameObject == null || earthRenderer == null)
            {
                return;
            }

            string materialName;

            earthRenderer.enabled = _showWorld;
            switch (_earthStyle)
            {
            case EARTH_STYLE.Alternate1:
                materialName = "Earth2";
                break;

            case EARTH_STYLE.Alternate2:
                materialName = "Earth4";
                break;

            case EARTH_STYLE.Alternate3:
                materialName = "Earth5";
                break;

            case EARTH_STYLE.SolidColor:
                materialName = "EarthSolidColor";
                break;

            case EARTH_STYLE.NaturalHighRes:
                materialName = "EarthHighRes";
                break;

            case EARTH_STYLE.Scenic:
                materialName = "EarthScenic";
                break;

            case EARTH_STYLE.ScenicCityLights:
                materialName = "EarthScenicCityLights";
                break;

            case EARTH_STYLE.NaturalHighResScenic:
                materialName = "EarthHighResScenic";
                break;

            case EARTH_STYLE.NaturalHighResScenicCityLights:
                materialName = "EarthHighResScenicCityLights";
                break;

            case EARTH_STYLE.NaturalHighResScenicScatter:
                materialName      = "EarthHighResScenicScatter";
                _earthGlowScatter = true;
                break;

            case EARTH_STYLE.NaturalHighResScenicScatterCityLights:
                materialName      = "EarthHighResScenicScatterCityLights";
                _earthGlowScatter = true;
                break;

            case EARTH_STYLE.NaturalHighRes16K:
                materialName = "EarthHighRes16K";
                break;

            case EARTH_STYLE.NaturalHighRes16KScenic:
                materialName = "EarthHighRes16KScenic";
                break;

            case EARTH_STYLE.NaturalHighRes16KScenicCityLights:
                materialName = "EarthHighRes16KScenicCityLights";
                break;

            case EARTH_STYLE.NaturalHighRes16KScenicScatter:
                materialName      = "EarthHighRes16KScenicScatter";
                _earthGlowScatter = true;
                break;

            case EARTH_STYLE.NaturalHighRes16KScenicScatterCityLights:
                materialName      = "EarthHighRes16KScenicScatterCityLights";
                _earthGlowScatter = true;
                break;

            case EARTH_STYLE.Custom:
                materialName = "EarthCustom";
                break;

            case EARTH_STYLE.StandardShader2K:
                materialName = "EarthStandardShader";
                break;

            case EARTH_STYLE.StandardShader8K:
                materialName = "EarthStandardShaderHighRes";
                break;

            default:
                materialName = "Earth";
                break;
            }

            if (earthRenderer.sharedMaterial == null || !earthRenderer.sharedMaterial.name.Equals(materialName))
            {
                Material earthMaterial = Instantiate(Resources.Load <Material> ("Materials/" + materialName));
                earthMaterial.hideFlags = HideFlags.DontSave;
                if (_earthStyle == EARTH_STYLE.SolidColor)
                {
                    earthMaterial.color = _earthColor;
                }
                earthMaterial.name     = materialName;
                earthRenderer.material = earthMaterial;
            }

            if (_showTiles)
            {
                if (backFacesRendererMat != null)
                {
                    backFacesRendererMat.color = Color.white;
                }
                if (Application.isPlaying)
                {
                    if (tilesRoot == null)
                    {
                        InitTileSystem();
                    }
                    else
                    {
                        ResetTiles();
                    }
                    if (!_tileTransparentLayer)
                    {
                        earthRenderer.enabled = false;
                        return;
                    }
                }
                else if (tilesRoot != null)
                {
                    tilesRoot.gameObject.SetActive(false);
                }
            }
            else if (backFacesRendererMat != null)
            {
                backFacesRendererMat.color = Color.black;
            }
            if (_sun != null)
            {
                _earthScenicLightDirection = -_sun.forward;
            }
            DrawAtmosphere();

            Drawing.ReverseSphereNormals(earthRenderer.gameObject, _earthInvertedMode, _earthHighDensityMesh);
            if (_earthInvertedMode && lastRestyleEarthNormalsScaleCheck.x > 0 || !_earthInvertedMode && lastRestyleEarthNormalsScaleCheck.x < 0)
            {
                transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
                lastRestyleEarthNormalsScaleCheck = transform.lossyScale;
            }
            if (backFacesRendererMat)
            {
                backFacesRendererMat.SetFloat("_Inverted", _earthInvertedMode ? 1 : 0);
            }

            UpdateMaterialBrightness();
            UpdateMaterialsZWrite();
        }
Exemple #2
0
        float m_scaleDepth = 0.25f;              // The scale depth (i.e. the altitude at which the atmosphere's average density is found)

        #endregion


        #region Drawing stuff

        void RestyleEarth()
        {
            if (gameObject == null)
            {
                return;
            }

            isScenic = false;
            string materialName;

            switch (_earthStyle)
            {
            case EARTH_STYLE.Alternate1:
                materialName = "Earth2";
                break;

            case EARTH_STYLE.Alternate2:
                materialName = "Earth4";
                break;

            case EARTH_STYLE.Alternate3:
                materialName = "Earth5";
                break;

            case EARTH_STYLE.SolidColor:
                materialName = "EarthSolidColor";
                break;

            case EARTH_STYLE.NaturalHighRes:
                materialName = "EarthHighRes";
                break;

            case EARTH_STYLE.Scenic:
                materialName = "EarthScenic";
                isScenic     = true;
                break;

            case EARTH_STYLE.NaturalHighResScenic:
                materialName = "EarthHighResScenic";
                isScenic     = true;
                break;

            case EARTH_STYLE.NaturalHighResScenicScatter:
                materialName      = "EarthHighResScenicScatter";
                _earthGlowScatter = true;
                isScenic          = true;
                break;

            case EARTH_STYLE.Custom:
                materialName = "EarthCustom";
                break;

            default:
                materialName = "Earth";
                break;
            }
            if (earthRenderer.sharedMaterial == null || !earthRenderer.sharedMaterial.name.Equals(materialName))
            {
                Material earthMaterial = Instantiate(Resources.Load <Material> ("Materials/" + materialName));
                earthMaterial.hideFlags = HideFlags.DontSave;
                if (_earthStyle == EARTH_STYLE.SolidColor)
                {
                    earthMaterial.color = _earthColor;
                }
                earthMaterial.name     = materialName;
                earthRenderer.material = earthMaterial;
            }

            if (isScenic)
            {
                earthRenderer.sharedMaterial.SetVector("_SunLightDirection", _earthScenicLightDirection);
                earthRenderer.sharedMaterial.SetFloat("_ScenicIntensity", _earthScenicAtmosphereIntensity);
            }
            DrawAtmosphere();

            Drawing.ReverseSphereNormals(earthRenderer.gameObject, _earthInvertedMode, _earthHighDensityMesh);
            if (_earthInvertedMode && lastGlobeScaleCheck.x > 0 || !_earthInvertedMode && lastGlobeScaleCheck.x < 0)
            {
                transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
                lastGlobeScaleCheck  = transform.localScale;
            }
        }
        void RestyleEarth()
        {
            if (gameObject == null || earthRenderer == null)
            {
                return;
            }

            isScenic = false;
            string materialName;

            if (_earthStyle == EARTH_STYLE.Tiled)
            {
                if (Application.isPlaying)
                {
                    earthRenderer.enabled = false;
                    if (tilesRoot == null)
                    {
                        InitTileSystem();
                    }
                    else
                    {
                        ResetTiles();
                    }
                    return;
                }
                else
                {
                    materialName = "Earth2";
                }
            }
            else
            {
                earthRenderer.enabled = true;
                if (tilesRoot != null)
                {
                    tilesRoot.gameObject.SetActive(false);
                }
                switch (_earthStyle)
                {
                case EARTH_STYLE.Alternate1:
                    materialName = "Earth2";
                    break;

                case EARTH_STYLE.Alternate2:
                    materialName = "Earth4";
                    break;

                case EARTH_STYLE.Alternate3:
                    materialName = "Earth5";
                    break;

                case EARTH_STYLE.SolidColor:
                    materialName = "EarthSolidColor";
                    break;

                case EARTH_STYLE.NaturalHighRes:
                    materialName = "EarthHighRes";
                    break;

                case EARTH_STYLE.Scenic:
                    materialName = "EarthScenic";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.ScenicCityLights:
                    materialName = "EarthScenicCityLights";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.NaturalHighResScenic:
                    materialName = "EarthHighResScenic";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.NaturalHighResScenicCityLights:
                    materialName = "EarthHighResScenicCityLights";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.NaturalHighResScenicScatter:
                    materialName      = "EarthHighResScenicScatter";
                    _earthGlowScatter = true;
                    isScenic          = true;
                    break;

                case EARTH_STYLE.NaturalHighResScenicScatterCityLights:
                    materialName      = "EarthHighResScenicScatterCityLights";
                    _earthGlowScatter = true;
                    isScenic          = true;
                    break;

                case EARTH_STYLE.NaturalHighRes16K:
                    materialName = "EarthHighRes16K";
                    break;

                case EARTH_STYLE.NaturalHighRes16KScenic:
                    materialName = "EarthHighRes16KScenic";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.NaturalHighRes16KScenicCityLights:
                    materialName = "EarthHighRes16KScenicCityLights";
                    isScenic     = true;
                    break;

                case EARTH_STYLE.NaturalHighRes16KScenicScatter:
                    materialName      = "EarthHighRes16KScenicScatter";
                    _earthGlowScatter = true;
                    isScenic          = true;
                    break;

                case EARTH_STYLE.NaturalHighRes16KScenicScatterCityLights:
                    materialName      = "EarthHighRes16KScenicScatterCityLights";
                    _earthGlowScatter = true;
                    isScenic          = true;
                    break;

                case EARTH_STYLE.Custom:
                    materialName = "EarthCustom";
                    break;

                case EARTH_STYLE.StandardShader2K:
                    materialName = "EarthStandardShader";
                    break;

                case EARTH_STYLE.StandardShader8K:
                    materialName = "EarthStandardShaderHighRes";
                    break;

                default:
                    materialName = "Earth";
                    break;
                }
            }
            if (earthRenderer.sharedMaterial == null || !earthRenderer.sharedMaterial.name.Equals(materialName))
            {
                Material earthMaterial = Instantiate(Resources.Load <Material> ("Materials/" + materialName));
                earthMaterial.hideFlags = HideFlags.DontSave;
                if (_earthStyle == EARTH_STYLE.SolidColor)
                {
                    earthMaterial.color = _earthColor;
                }
                earthMaterial.name     = materialName;
                earthRenderer.material = earthMaterial;
            }

            if (isScenic)
            {
                earthRenderer.sharedMaterial.SetVector("_SunLightDirection", _earthScenicLightDirection);
                earthRenderer.sharedMaterial.SetFloat("_ScenicIntensity", _earthScenicAtmosphereIntensity);
            }
            DrawAtmosphere();

            Drawing.ReverseSphereNormals(earthRenderer.gameObject, _earthInvertedMode, _earthHighDensityMesh);
            if (_earthInvertedMode && lastGlobeScaleCheck.x > 0 || !_earthInvertedMode && lastGlobeScaleCheck.x < 0)
            {
                transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
                lastGlobeScaleCheck  = transform.localScale;
            }

            UpdateMaterialBrightness();
        }