示例#1
0
        public static void CreateFogVoid(MenuCommand menuCommand)
        {
            GameObject go = VolumetricFogManager.CreateFogVoid("Fog Void");

            GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
            Undo.RegisterCreatedObjectUndo(go, "Create Fog Void");
            Selection.activeObject = go;
        }
示例#2
0
        void OnEnable()
        {
            VolumetricFogManager manager = Tools.CheckMainManager();

            gameObject.layer = manager.fogLayer;
            FogOfWarInit();
            UpdateMaterialProperties();
        }
示例#3
0
        public static VolumetricFogManager CheckMainManager()
        {
            VolumetricFogManager fog2 = Object.FindObjectOfType <VolumetricFogManager>();

            if (fog2 == null)
            {
                GameObject go = new GameObject();
                fog2    = go.AddComponent <VolumetricFogManager>();
                go.name = fog2.managerName;
            }
            return(fog2);
        }
示例#4
0
 public static void CheckManager <T>(ref T manager) where T : Component
 {
     if (manager == null)
     {
         manager = Object.FindObjectOfType <T>();
         if (manager == null)
         {
             VolumetricFogManager root = CheckMainManager();
             if (root != null)
             {
                 manager = Object.FindObjectOfType <T>();
             }
             if (manager == null)
             {
                 GameObject o = new GameObject();
                 o.transform.SetParent(root.transform, false);
                 manager = o.AddComponent <T>();
                 o.name  = ((IVolumetricFogManager)manager).managerName;
             }
         }
     }
 }
示例#5
0
        public static void CreateManager(MenuCommand menuCommand)
        {
            VolumetricFogManager fog2 = Tools.CheckMainManager();

            Selection.activeObject = fog2.gameObject;
        }
示例#6
0
        void LateUpdate()
        {
            if (fogMat == null || r == null || profile == null)
            {
                return;
            }
            Bounds  bounds  = r.bounds;
            Vector3 center  = bounds.center;
            Vector3 extents = bounds.extents;

            if (profile.shape == VolumetricFogShape.Sphere)
            {
                Vector3 scale = transform.localScale;
                if (scale.z != scale.x || scale.y != scale.x)
                {
                    scale.z = scale.y = scale.x;
                    transform.localScale = scale;
                    extents = r.bounds.extents;
                }
                extents.x *= extents.x;
            }

            Vector4 border = new Vector4(extents.x * profile.border + 0.0001f, extents.x * (1f - profile.border), extents.z * profile.border + 0.0001f, extents.z * (1f - profile.border));

            fogMat.SetVector("_BoundsCenter", center);
            fogMat.SetVector("_BoundsExtents", extents);
            fogMat.SetVector("_BoundsBorder", border);
            fogMat.SetFloat("_BoundsVerticalOffset", profile.verticalOffset);

            VolumetricFogManager globalManager = VolumetricFogManager.instance;
            Light sun = globalManager.sun;

            if (sun != null)
            {
                sunDir = -sun.transform.forward;
                fogMat.SetVector("_SunDir", sunDir);
                dayLight = 1f + sunDir.y * 2f;
                if (dayLight < 0)
                {
                    dayLight = 0;
                }
                else if (dayLight > 1f)
                {
                    dayLight = 1f;
                }
                float brightness;
                float alpha;
                if (profile != null)
                {
                    brightness = profile.brightness;
                    alpha      = profile.albedo.a;
                }
                else
                {
                    brightness = 1f;
                    alpha      = 1f;
                }
                Color lightColor = sun.color * (sun.intensity * brightness * dayLight * 2f);
                lightColor.a = alpha;
                fogMat.SetVector("_LightColor", lightColor);
            }

            windDirectionAcum += profile.windDirection * Time.deltaTime;
            fogMat.SetVector("_WindDirection", windDirectionAcum);

            transform.rotation = Quaternion.identity;

            UpdateNoise();

            if (enableFogOfWar)
            {
                UpdateFogOfWar();
            }
        }