示例#1
0
 void Start()
 {
     fog = VolumetricFog.instance;
     fog.fogOfWarEnabled = fogCuttingOn;
     fog.ResetFogOfWar();
     status = GameObject.Find("Status").GetComponent <Text>();
 }
示例#2
0
 void OnEnable()
 {
     fog = VolumetricFog.instance;
     if (fog==null) {
         fog = gameObject.AddComponent<VolumetricFog>();
     }
 }
示例#3
0
        static void CreateFogVolume(MenuCommand menuCommand)
        {
            GameObject fogVolume = Resources.Load <GameObject>("Prefabs/FogVolume");

            if (fogVolume == null)
            {
                Debug.LogError("Could not load FogVolume from Resources/Prefabs folder!");
                return;
            }
            GameObject newFogVolume = Instantiate(fogVolume);

            newFogVolume.name = "Volumetric Fog Volume";

            // Ensure it gets reparented if this was a context click (otherwise does nothing)
            GameObjectUtility.SetParentAndAlign(newFogVolume, menuCommand.context as GameObject);

            // Break prefab link
#if UNITY_2018_3_OR_NEWER
#else
            PrefabUtility.DisconnectPrefabInstance(newFogVolume);
#endif

            // Register root object for undo.
            Undo.RegisterCreatedObjectUndo(newFogVolume, "Create Volumetric Fog Volume");
            Selection.activeObject = newFogVolume;

            // Enables fog volumes in fog component
            VolumetricFog fog = Camera.main.GetComponent <VolumetricFog>();
            if (fog != null)
            {
                fog.useFogVolumes = true;
            }
        }
示例#4
0
        void AssignCustomTexture()
        {
            VolumetricFog fog = VolumetricFog.instance;
            Texture2D     tex = Resources.Load <Texture2D> ("Textures/alphaDemo");

            Color32[] colors = tex.GetPixels32();
            fog.fogOfWarTextureSize = 64;
            fog.fogOfWarTextureData = colors;
        }
        void Update()
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (Input.GetKeyDown(KeyCode.T))
            {
                fog.fogBlur = !fog.fogBlur;
            }
        }
示例#6
0
        void Update()
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (Input.GetKeyDown(KeyCode.T))
            {
                fog.enabled = !fog.enabled;
            }
        }
        /// <summary>
        /// Applies profile settings
        /// </summary>
        /// <param name="fog">Fog.</param>
        public void Load(VolumetricFog fog)
        {
            // Fog Geo
            fog.density                       = density;
            fog.noiseStrength                 = noiseStrength;
            fog.height                        = height;
            fog.baselineHeight                = baselineHeight;
            fog.distance                      = distance;
            fog.distanceFallOff               = distanceFallOff;
            fog.maxFogLength                  = maxFogLength;
            fog.maxFogLengthFallOff           = maxFogLengthFallOff;
            fog.baselineRelativeToCamera      = baselineRelativeToCamera;
            fog.baselineRelativeToCameraDelay = baselineRelativeToCameraDelay;
            fog.noiseScale                    = noiseScale;
            fog.noiseSparse                   = noiseSparse;
            fog.noiseFinalMultiplier          = noiseFinalMultiplier;
            fog.useXYPlane                    = useXYPlane;

            // Fog Colors
            fog.lightingModel     = lightingModel;
            fog.sunCopyColor      = sunCopyColor;
            fog.alpha             = alpha;
            fog.color             = color;
            fog.specularColor     = specularColor;
            fog.specularThreshold = specularThreshold;
            fog.specularIntensity = specularIntensity;
            fog.lightDirection    = lightDirection;
            fog.lightIntensity    = lightIntensity;
            fog.lightColor        = lightColor;

            // Fog animation
            fog.speed              = speed;
            fog.windDirection      = windDirection;
            fog.turbulenceStrength = turbulenceStrength;
            fog.useRealTime        = useRealTime;

            // Fog sky
            fog.skyColor         = skyColor;
            fog.skyHaze          = skyHaze;
            fog.skySpeed         = skySpeed;
            fog.skyNoiseStrength = skyNoiseStrength;
            fog.skyAlpha         = skyAlpha;

            // Optimization
            fog.stepping       = stepping;
            fog.steppingNear   = steppingNear;
            fog.dithering      = dithering;
            fog.ditherStrength = ditherStrength;

            if (downsamplingOverride)
            {
                fog.downsampling  = downsampling;
                fog.edgeImprove   = edgeImprove;
                fog.edgeThreshold = edgeThreshold;
            }
        }
 void OnEnable()
 {
     if (fog == null)
     {
         fog = GetComponent <VolumetricFog> ();
         if (fog == null)
         {
             fog = gameObject.AddComponent <VolumetricFog> ();
         }
     }
 }
示例#9
0
        void OnValidate()
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (fog == null)
            {
                return;
            }
            RestoreHole(lastPosition, lastShape, lastScale.x, lastScale.z);
            StampHole(transform.position, shape, transform.localScale.x, transform.localScale.z);
        }
示例#10
0
 void Start()
 {
     if (targetFog == null)
     {
         targetFog = VolumetricFog.instance;
     }
     if (targetFog != null)
     {
         targetFog.useFogVolumes = true;
     }
 }
        /// <summary>
        /// Replaces profile settings with current fog configuration
        /// </summary>
        public void Save(VolumetricFog fog)
        {
            // Fog Geo
            density                       = fog.density;
            noiseStrength                 = fog.noiseStrength;
            height                        = fog.height;
            baselineHeight                = fog.baselineHeight;
            distance                      = fog.distance;
            distanceFallOff               = fog.distanceFallOff;
            maxFogLength                  = fog.maxFogLength;
            maxFogLengthFallOff           = fog.maxFogLengthFallOff;
            baselineRelativeToCamera      = fog.baselineRelativeToCamera;
            baselineRelativeToCameraDelay = fog.baselineRelativeToCameraDelay;
            noiseScale                    = fog.noiseScale;
            noiseSparse                   = fog.noiseSparse;
            noiseFinalMultiplier          = fog.noiseFinalMultiplier;
            useXYPlane                    = fog.useXYPlane;

            // Fog Colors
            sunCopyColor      = fog.sunCopyColor;
            alpha             = fog.alpha;
            color             = fog.color;
            specularColor     = fog.specularColor;
            specularThreshold = fog.specularThreshold;
            specularIntensity = fog.specularIntensity;
            lightDirection    = fog.lightDirection;
            lightIntensity    = fog.lightIntensity;
            lightColor        = fog.lightColor;
            lightingModel     = fog.lightingModel;

            // Fog animation
            speed              = fog.speed;
            windDirection      = fog.windDirection;
            turbulenceStrength = fog.turbulenceStrength;
            useRealTime        = fog.useRealTime;

            // Fog sky
            skyColor         = fog.skyColor;
            skyHaze          = fog.skyHaze;
            skySpeed         = fog.skySpeed;
            skyNoiseStrength = fog.skyNoiseStrength;
            skyAlpha         = fog.skyAlpha;

            // Optimization
            stepping       = fog.stepping;
            steppingNear   = fog.steppingNear;
            dithering      = fog.dithering;
            ditherStrength = fog.ditherStrength;
            downsampling   = fog.downsampling;
            edgeImprove    = fog.edgeImprove;
            edgeThreshold  = fog.edgeThreshold;
        }
        /// <summary>
        /// Create a random cloud shape fog area near camera position.
        /// </summary>
        void CreateCloud()
        {
            Vector3 position = Camera.main.transform.position + Camera.main.transform.forward * 100 + Random.insideUnitSphere * 50f;

            if (position.y < 10)
            {
                position.y = 10f;
            }
            float         radius = Random.value * 50f + 85f;
            VolumetricFog fog    = VolumetricFog.CreateFogArea(position, radius);

            fog.color = new Color(0.6f, 0.57f, 0.5f, 1f);
        }
        /// <summary>
        /// Create a random box-shape fog area near camera position.
        /// </summary>
        void CreateBoxFog()
        {
            Vector3 position = Camera.main.transform.position + Camera.main.transform.forward * 100 + Random.insideUnitSphere * 50f;

            if (position.y < 10)
            {
                position.y = 10f;
            }
            Vector3       size = new Vector3(Random.value * 50f + 35f, Random.value * 10f + 15f, Random.value * 50f + 35f);
            VolumetricFog fog  = VolumetricFog.CreateFogArea(position, size);

            fog.color      = new Color(0.6f, 0.57f, 0.5f, 1f);
            fog.noiseScale = 2f;
        }
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.C))
     {
         CreateCloud();
     }
     else if (Input.GetKeyDown(KeyCode.B))
     {
         CreateBoxFog();
     }
     else if (Input.GetKeyDown(KeyCode.X))
     {
         VolumetricFog.RemoveAllFogAreas();
     }
 }
示例#15
0
 // Token: 0x06007E8E RID: 32398 RVA: 0x003C0D10 File Offset: 0x003BEF10
 public void Load(VolumetricFog fog)
 {
     fog.density                       = this.density;
     fog.noiseStrength                 = this.noiseStrength;
     fog.height                        = this.height;
     fog.baselineHeight                = this.baselineHeight;
     fog.distance                      = this.distance;
     fog.distanceFallOff               = this.distanceFallOff;
     fog.maxFogLength                  = this.maxFogLength;
     fog.maxFogLengthFallOff           = this.maxFogLengthFallOff;
     fog.baselineRelativeToCamera      = this.baselineRelativeToCamera;
     fog.baselineRelativeToCameraDelay = this.baselineRelativeToCameraDelay;
     fog.noiseScale                    = this.noiseScale;
     fog.noiseSparse                   = this.noiseSparse;
     fog.noiseFinalMultiplier          = this.noiseFinalMultiplier;
     fog.useXYPlane                    = this.useXYPlane;
     fog.lightingModel                 = this.lightingModel;
     fog.sunCopyColor                  = this.sunCopyColor;
     fog.alpha              = this.alpha;
     fog.color              = this.color;
     fog.specularColor      = this.specularColor;
     fog.specularThreshold  = this.specularThreshold;
     fog.specularIntensity  = this.specularIntensity;
     fog.lightDirection     = this.lightDirection;
     fog.lightIntensity     = this.lightIntensity;
     fog.lightColor         = this.lightColor;
     fog.speed              = this.speed;
     fog.windDirection      = this.windDirection;
     fog.turbulenceStrength = this.turbulenceStrength;
     fog.useRealTime        = this.useRealTime;
     fog.skyColor           = this.skyColor;
     fog.skyHaze            = this.skyHaze;
     fog.skySpeed           = this.skySpeed;
     fog.skyNoiseStrength   = this.skyNoiseStrength;
     fog.skyAlpha           = this.skyAlpha;
     fog.stepping           = this.stepping;
     fog.steppingNear       = this.steppingNear;
     fog.dithering          = this.dithering;
     fog.ditherStrength     = this.ditherStrength;
     if (this.downsamplingOverride)
     {
         fog.downsampling  = this.downsampling;
         fog.edgeImprove   = this.edgeImprove;
         fog.edgeThreshold = this.edgeThreshold;
     }
 }
示例#16
0
        static void CreateFogCloud2Layer(MenuCommand menuCommand)
        {
            GameObject fogArea = Resources.Load <GameObject>("Prefabs/FogSphereArea");

            if (fogArea == null)
            {
                Debug.LogError("Could not load FogSphereArea from Resources/Prefabs folder!");
                return;
            }

            GameObject root = new GameObject("Volumetric Fog Cloud Layers");
            Vector3    pos  = Camera.main != null ? Camera.main.transform.position : Vector3.zero;

            pos.y += 70;
            root.transform.position = pos;
            VolumetricFog fog = InstantiateCloudLayer(fogArea, 1).GetComponent <VolumetricFog>();

            fog.transform.SetParent(root.transform, false);
            fog.transform.localScale = new Vector3(2000, 60f, 2000);
            fog.density              = 1f;
            fog.height               = 60f;
            fog.noiseStrength        = 0.778f;
            fog.noiseScale           = 4.37f;
            fog.noiseSparse          = 0.418f;
            fog.noiseFinalMultiplier = 1f;
            fog.distance             = 0;
            fog.distanceFallOff      = 0f;

            fog = InstantiateCloudLayer(fogArea, 2).GetComponent <VolumetricFog>();
            fog.transform.SetParent(root.transform, false);
            fog.transform.localPosition += new Vector3(0, 50, 0);
            fog.transform.localScale     = new Vector3(2000, 50, 2000);
            fog.density              = 1f;
            fog.height               = 50f;
            fog.noiseStrength        = 1f;
            fog.noiseScale           = 5.57f;
            fog.noiseSparse          = 0.458f;
            fog.noiseFinalMultiplier = 1f;
            fog.distance             = 0;
            fog.distanceFallOff      = 0f;


            Selection.activeObject = root;
        }
示例#17
0
        void RestoreHole(Vector3 position, HoleShape shape, float sizeX, float sizeZ)
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (fog == null)
            {
                return;
            }

            fog.fogOfWarEnabled = true;
            switch (shape)
            {
            case HoleShape.Box:
                fog.ResetFogOfWarAlpha(position, sizeX * 0.5f, sizeZ * 0.5f);
                break;

            case HoleShape.Disc:
                fog.ResetFogOfWarAlpha(position, Mathf.Max(sizeX, sizeZ) * 0.5f);
                break;
            }
        }
示例#18
0
        public void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
#if UNITY_EDITOR
            if ("SceneCamera".Equals(Camera.current.name))
            {
                if (fog == null)
                {
                    fog = VolumetricFog.instance;
                }
                if (fog != null && !fog.showInSceneView)
                {
                    fog = null;
                }
            }
#endif

            if (fog == null || !fog.enabled)
            {
                Graphics.Blit(source, destination);
                return;
            }

            if (fog.transparencyBlendMode == TRANSPARENT_MODE.None)
            {
                fog.DoOnRenderImage(source, destination);
            }
            else
            {
                RenderTextureDescriptor desc        = source.descriptor;
                RenderTexture           opaqueFrame = RenderTexture.GetTemporary(desc);
                if (copyOpaqueMat == null)
                {
                    copyOpaqueMat = new Material(Shader.Find("VolumetricFogAndMist/CopyOpaque"));
                }
                copyOpaqueMat.SetFloat("_BlendPower", fog.transparencyBlendPower);
                Graphics.Blit(source, destination, copyOpaqueMat, (fog.computeDepth && fog.downsampling == 1) ? 1 : 0);
                RenderTexture.ReleaseTemporary(opaqueFrame);
            }
        }
示例#19
0
 public void Save(VolumetricFog fog)
 {
     this.density                       = fog.density;
     this.noiseStrength                 = fog.noiseStrength;
     this.height                        = fog.height;
     this.baselineHeight                = fog.baselineHeight;
     this.distance                      = fog.distance;
     this.distanceFallOff               = fog.distanceFallOff;
     this.maxFogLength                  = fog.maxFogLength;
     this.maxFogLengthFallOff           = fog.maxFogLengthFallOff;
     this.baselineRelativeToCamera      = fog.baselineRelativeToCamera;
     this.baselineRelativeToCameraDelay = fog.baselineRelativeToCameraDelay;
     this.noiseScale                    = fog.noiseScale;
     this.noiseSparse                   = fog.noiseSparse;
     this.useXYPlane                    = fog.useXYPlane;
     this.sunCopyColor                  = fog.sunCopyColor;
     this.alpha              = fog.alpha;
     this.color              = fog.color;
     this.specularColor      = fog.specularColor;
     this.specularThreshold  = fog.specularThreshold;
     this.specularIntensity  = fog.specularIntensity;
     this.lightDirection     = fog.lightDirection;
     this.lightIntensity     = fog.lightIntensity;
     this.lightColor         = fog.lightColor;
     this.speed              = fog.speed;
     this.windDirection      = fog.windDirection;
     this.turbulenceStrength = fog.turbulenceStrength;
     this.useRealTime        = fog.useRealTime;
     this.skyColor           = fog.skyColor;
     this.skyHaze            = fog.skyHaze;
     this.skySpeed           = fog.skySpeed;
     this.skyNoiseStrength   = fog.skyNoiseStrength;
     this.skyAlpha           = fog.skyAlpha;
     this.stepping           = fog.stepping;
     this.steppingNear       = fog.steppingNear;
     this.dithering          = fog.dithering;
     this.ditherStrength     = fog.ditherStrength;
 }
示例#20
0
        void StampHole(Vector3 position, HoleShape shape, float sizeX, float sizeZ)
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (fog == null)
            {
                return;
            }

            fog.fogOfWarEnabled = true;
            switch (shape)
            {
            case HoleShape.Box:
                fog.SetFogOfWarAlpha(new Bounds(position, new Vector3(sizeX, 0, sizeZ)), alpha, false, 0, smoothness, 0, 0);
                break;

            case HoleShape.Disc:
                fog.SetFogOfWarAlpha(position, Mathf.Max(sizeX, sizeZ) * 0.5f, alpha, false, 0, smoothness, 0, 0);
                break;
            }
            lastPosition = position;
            lastShape    = shape;
            lastScale    = transform.localScale;
        }
示例#21
0
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
#if UNITY_EDITOR
            if ("SceneCamera".Equals(Camera.current.name))
            {
                if (fog == null)
                {
                    fog = VolumetricFog.instance;
                }
                if (fog != null && !fog.showInSceneView)
                {
                    fog = null;
                }
            }
#endif

            if (fog == null || !fog.enabled)
            {
                Graphics.Blit(source, destination);
                return;
            }

            if (fog.renderBeforeTransparent)
            {
                fog.DoOnRenderImage(source, destination);
            }
            else
            {
                // Save frame buffer
                RenderTextureDescriptor desc = source.descriptor;
                opaqueFrame = RenderTexture.GetTemporary(desc);
                fog.DoOnRenderImage(source, opaqueFrame);
                Shader.SetGlobalTexture("_VolumetricFog_OpaqueFrame", opaqueFrame);
                Graphics.Blit(opaqueFrame, destination);
            }
        }
 void Awake()
 {
     m_VolumetricFog = Camera.main.GetComponent <VolumetricFogAndMist.VolumetricFog>();
     GameManager.instance.addEventListener(this);
 }
示例#23
0
 void Start()
 {
     fog = VolumetricFog.instance;
 }
示例#24
0
        void Update()
        {
            VolumetricFog fog = VolumetricFog.instance;

            if (Input.GetKeyDown(KeyCode.F))
            {
                fog.baselineHeight = 0;
                switch (fog.preset)
                {
                case FOG_PRESET.Custom:
                case FOG_PRESET.Clear:
                    fog.preset = FOG_PRESET.Mist;
                    break;

                case FOG_PRESET.Mist:
                    fog.preset = FOG_PRESET.WindyMist;
                    break;

                case FOG_PRESET.WindyMist:
                    fog.preset = FOG_PRESET.GroundFog;
                    break;

                case FOG_PRESET.GroundFog:
                    fog.preset = FOG_PRESET.FrostedGround;
                    break;

                case FOG_PRESET.FrostedGround:
                    fog.preset = FOG_PRESET.FoggyLake;
                    break;

                case FOG_PRESET.FoggyLake:
                    fog.preset = FOG_PRESET.Fog;
                    break;

                case FOG_PRESET.Fog:
                    fog.preset = FOG_PRESET.HeavyFog;
                    break;

                case FOG_PRESET.HeavyFog:
                    fog.preset = FOG_PRESET.LowClouds;
                    break;

                case FOG_PRESET.LowClouds:
                    fog.preset = FOG_PRESET.SeaClouds;
                    break;

                case FOG_PRESET.SeaClouds:
                    fog.preset = FOG_PRESET.Smoke;
                    break;

                case FOG_PRESET.Smoke:
                    fog.preset = FOG_PRESET.ToxicSwamp;
                    break;

                case FOG_PRESET.ToxicSwamp:
                    fog.preset = FOG_PRESET.SandStorm1;
                    break;

                case FOG_PRESET.SandStorm1:
                    fog.preset = FOG_PRESET.SandStorm2;
                    break;

                case FOG_PRESET.SandStorm2:
                    fog.preset = FOG_PRESET.Mist;
                    break;
                }
            }
            else if (Input.GetKeyDown(KeyCode.T))
            {
                fog.enabled = !fog.enabled;
            }

            status.text = "Current fog preset: " + VolumetricFog.instance.GetCurrentPresetName();
        }
        /// <summary>
        /// Lerps between profile1 and profile2 using t as the transition amount (0..1) and assign the values to given fog
        /// </summary>
        public static void Lerp(VolumetricFogProfile profile1, VolumetricFogProfile profile2, float t, VolumetricFog fog)
        {
            if (t < 0)
            {
                t = 0;
            }
            else if (t > 1f)
            {
                t = 1f;
            }

            // Fog Geo
            fog.density                       = profile1.density * (1f - t) + profile2.density * t;
            fog.noiseStrength                 = profile1.noiseStrength * (1f - t) + profile2.noiseStrength * t;
            fog.height                        = profile1.height * (1f - t) + profile2.height * t;
            fog.heightFallOff                 = profile1.heightFallOff * (1f - t) + profile2.heightFallOff * t;
            fog.baselineHeight                = profile1.baselineHeight * (1f - t) + profile2.baselineHeight * t;
            fog.distance                      = profile1.distance * (1f - t) + profile2.distance * t;
            fog.distanceFallOff               = profile1.distanceFallOff * (1f - t) + profile2.distanceFallOff * t;
            fog.maxFogLength                  = profile1.maxFogLength * (1f - t) + profile2.maxFogLength * t;
            fog.maxFogLengthFallOff           = profile1.maxFogLengthFallOff * (1f - t) + profile2.maxFogLengthFallOff * t;
            fog.baselineRelativeToCamera      = t < 0.5f ? profile1.baselineRelativeToCamera : profile2.baselineRelativeToCamera;
            fog.baselineRelativeToCameraDelay = profile1.baselineRelativeToCameraDelay * (1f - t) + profile2.baselineRelativeToCameraDelay * t;
            fog.noiseScale                    = profile1.noiseScale * (1f - t) + profile2.noiseScale * t;
            fog.noiseSparse                   = profile1.noiseSparse * (1f - t) + profile2.noiseSparse * t;
            fog.noiseFinalMultiplier          = profile1.noiseFinalMultiplier * (1f - t) + profile2.noiseFinalMultiplier * t;

            // Fog Colors
            fog.sunCopyColor      = t < 0.5f ? profile1.sunCopyColor : profile2.sunCopyColor;
            fog.alpha             = profile1.alpha * (1f - t) + profile2.alpha * t;
            fog.color             = profile1.color * (1f - t) + profile2.color * t;
            fog.deepObscurance    = profile1.deepObscurance * (1f - t) + profile2.deepObscurance * t;
            fog.specularColor     = profile1.specularColor * (1f - t) + profile2.specularColor * t;
            fog.specularThreshold = profile1.specularThreshold * (1f - t) + profile2.specularThreshold * t;
            fog.specularIntensity = profile1.specularIntensity * (1f - t) + profile2.specularIntensity * t;
            fog.lightDirection    = profile1.lightDirection * (1f - t) + profile2.lightDirection * t;
            fog.lightIntensity    = profile1.lightIntensity * (1f - t) + profile2.lightIntensity * t;
            fog.lightColor        = profile1.lightColor * (1f - t) + profile2.lightColor * t;

            // Fog animation
            fog.speed              = profile1.speed * (1f - t) + profile2.speed * t;
            fog.windDirection      = profile1.windDirection * (1f - t) + profile2.windDirection * t;
            fog.turbulenceStrength = profile1.turbulenceStrength * (1f - t) + profile2.turbulenceStrength * t;

            // Fog sky
            fog.skyColor         = profile1.skyColor * (1f - t) + profile2.skyColor * t;
            fog.skyHaze          = profile1.skyHaze * (1f - t) + profile2.skyHaze * t;
            fog.skySpeed         = profile1.skySpeed * (1f - t) + profile2.skySpeed * t;
            fog.skyNoiseStrength = profile1.skyNoiseStrength * (1f - t) + profile2.skyNoiseStrength * t;
            fog.skyNoiseScale    = profile1.skyNoiseScale * (1f - t) + profile2.skyNoiseScale * t;
            fog.skyAlpha         = profile1.skyAlpha * (1f - t) + profile2.skyAlpha * t;
            fog.skyDepth         = profile1.skyDepth * (1f - t) + profile2.skyDepth * t;

            // Optimization
            fog.stepping       = profile1.stepping * (1f - t) + profile2.stepping * t;
            fog.steppingNear   = profile1.steppingNear * (1f - t) + profile2.steppingNear * t;
            fog.dithering      = t < 0.5f ? profile1.dithering : profile2.dithering;
            fog.ditherStrength = profile1.ditherStrength * (1f - t) + profile2.ditherStrength * t;

            // Fog Void
            if (profile1.fogVoidOverride && profile2.fogVoidOverride)
            {
                fog.fogVoidDepth    = profile1.fogVoidDepth * (1f - t) + profile2.fogVoidDepth * t;
                fog.fogVoidFallOff  = profile1.fogVoidFallOff * (1f - t) + profile2.fogVoidFallOff * t;
                fog.fogVoidHeight   = profile1.fogVoidHeight * (1f - t) + profile2.fogVoidHeight * t;
                fog.fogVoidPosition = profile1.fogVoidPosition * (1f - t) + profile2.fogVoidPosition * t;
                fog.fogVoidRadius   = profile1.fogVoidRadius * (1f - t) + profile2.fogVoidRadius * t;
            }

            // Light Scattering
            if (profile1.lightScatteringOverride && profile2.lightScatteringOverride)
            {
                fog.lightScatteringDecay        = profile1.lightScatteringDecay * (1f - t) + profile2.lightScatteringDecay * t;
                fog.lightScatteringDiffusion    = profile1.lightScatteringDiffusion * (1f - t) + profile2.lightScatteringDiffusion * t;
                fog.lightScatteringExposure     = profile1.lightScatteringExposure * (1f - t) + profile2.lightScatteringExposure * t;
                fog.lightScatteringIllumination = profile1.lightScatteringIllumination * (1f - t) + profile2.lightScatteringIllumination * t;
                fog.lightScatteringJittering    = profile1.lightScatteringJittering * (1f - t) + profile2.lightScatteringJittering * t;
                fog.lightScatteringSamples      = (int)(profile1.lightScatteringSamples * (1f - t) + profile2.lightScatteringSamples * t);
                fog.lightScatteringSpread       = profile1.lightScatteringSpread * (1f - t) + profile2.lightScatteringSpread * t;
                fog.lightScatteringWeight       = profile1.lightScatteringWeight * (1f - t) + profile2.lightScatteringWeight * t;
            }
        }
        /// <summary>
        /// Replaces profile settings with current fog configuration
        /// </summary>
        public void Save(VolumetricFog fog)
        {
            // Fog Geo
            density                       = fog.density;
            noiseStrength                 = fog.noiseStrength;
            height                        = fog.height;
            heightFallOff                 = fog.heightFallOff;
            baselineHeight                = fog.baselineHeight;
            distance                      = fog.distance;
            distanceFallOff               = fog.distanceFallOff;
            maxFogLength                  = fog.maxFogLength;
            maxFogLengthFallOff           = fog.maxFogLengthFallOff;
            baselineRelativeToCamera      = fog.baselineRelativeToCamera;
            baselineRelativeToCameraDelay = fog.baselineRelativeToCameraDelay;
            noiseScale                    = fog.noiseScale;
            noiseSparse                   = fog.noiseSparse;
            noiseFinalMultiplier          = fog.noiseFinalMultiplier;
            useXYPlane                    = fog.useXYPlane;

            // Fog Colors
            sunCopyColor      = fog.sunCopyColor;
            alpha             = fog.alpha;
            color             = fog.color;
            deepObscurance    = fog.deepObscurance;
            specularColor     = fog.specularColor;
            specularThreshold = fog.specularThreshold;
            specularIntensity = fog.specularIntensity;
            lightDirection    = fog.lightDirection;
            lightIntensity    = fog.lightIntensity;
            lightColor        = fog.lightColor;
            lightingModel     = fog.lightingModel;

            // Fog animation
            speed              = fog.speed;
            windDirection      = fog.windDirection;
            turbulenceStrength = fog.turbulenceStrength;
            useRealTime        = fog.useRealTime;

            // Fog sky
            skyColor         = fog.skyColor;
            skyHaze          = fog.skyHaze;
            skySpeed         = fog.skySpeed;
            skyNoiseStrength = fog.skyNoiseStrength;
            skyNoiseScale    = fog.skyNoiseScale;
            skyAlpha         = fog.skyAlpha;
            skyDepth         = fog.skyDepth;

            // Optimization
            stepping         = fog.stepping;
            steppingNear     = fog.steppingNear;
            dithering        = fog.dithering;
            ditherStrength   = fog.ditherStrength;
            downsampling     = fog.downsampling;
            forceComposition = fog.forceComposition;
            edgeImprove      = fog.edgeImprove;
            edgeThreshold    = fog.edgeThreshold;

            // Fog Void
            fogVoidTopology = fog.fogVoidTopology;
            fogVoidDepth    = fog.fogVoidDepth;
            fogVoidFallOff  = fog.fogVoidFallOff;
            fogVoidHeight   = fog.fogVoidHeight;
            fogVoidPosition = fog.fogVoidPosition;
            fogVoidRadius   = fog.fogVoidRadius;

            // Light scattering
            lightScatteringEnabled       = fog.lightScatteringEnabled;
            lightScatteringDecay         = fog.lightScatteringDecay;
            lightScatteringDiffusion     = fog.lightScatteringDiffusion;
            lightScatteringExposure      = fog.lightScatteringExposure;
            lightScatteringIllumination  = fog.lightScatteringIllumination;
            lightScatteringJittering     = fog.lightScatteringJittering;
            lightScatteringSamples       = fog.lightScatteringSamples;
            lightScatteringSpread        = fog.lightScatteringSamples;
            lightScatteringSpread        = fog.lightScatteringSpread;
            lightScatteringWeight        = fog.lightScatteringWeight;
            lightScatteringBlurDownscale = fog.lightScatteringBlurDownscale;
        }
        /// <summary>
        /// Applies profile settings
        /// </summary>
        /// <param name="fog">Fog.</param>
        public void Load(VolumetricFog fog)
        {
            // Fog Geo
            fog.density                       = density;
            fog.noiseStrength                 = noiseStrength;
            fog.height                        = height;
            fog.heightFallOff                 = heightFallOff;
            fog.baselineHeight                = baselineHeight;
            fog.distance                      = distance;
            fog.distanceFallOff               = distanceFallOff;
            fog.maxFogLength                  = maxFogLength;
            fog.maxFogLengthFallOff           = maxFogLengthFallOff;
            fog.baselineRelativeToCamera      = baselineRelativeToCamera;
            fog.baselineRelativeToCameraDelay = baselineRelativeToCameraDelay;
            fog.noiseScale                    = noiseScale;
            fog.noiseSparse                   = noiseSparse;
            fog.noiseFinalMultiplier          = noiseFinalMultiplier;
            fog.useXYPlane                    = useXYPlane;

            // Fog Colors
            fog.lightingModel     = lightingModel;
            fog.sunCopyColor      = sunCopyColor;
            fog.alpha             = alpha;
            fog.color             = color;
            fog.deepObscurance    = deepObscurance;
            fog.specularColor     = specularColor;
            fog.specularThreshold = specularThreshold;
            fog.specularIntensity = specularIntensity;
            fog.lightDirection    = lightDirection;
            fog.lightIntensity    = lightIntensity;
            fog.lightColor        = lightColor;

            // Fog animation
            fog.speed              = speed;
            fog.windDirection      = windDirection;
            fog.turbulenceStrength = turbulenceStrength;
            fog.useRealTime        = useRealTime;

            // Fog sky
            fog.skyColor         = skyColor;
            fog.skyHaze          = skyHaze;
            fog.skySpeed         = skySpeed;
            fog.skyNoiseStrength = skyNoiseStrength;
            fog.skyNoiseScale    = skyNoiseScale;
            fog.skyAlpha         = skyAlpha;
            fog.skyDepth         = skyDepth;

            // Optimization
            fog.stepping       = stepping;
            fog.steppingNear   = steppingNear;
            fog.dithering      = dithering;
            fog.ditherStrength = ditherStrength;

            if (downsamplingOverride)
            {
                fog.downsampling     = downsampling;
                fog.forceComposition = forceComposition;
                fog.edgeImprove      = edgeImprove;
                fog.edgeThreshold    = edgeThreshold;
            }

            // Fog Void
            if (fogVoidOverride)
            {
                fog.fogVoidTopology = fogVoidTopology;
                fog.fogVoidDepth    = fogVoidDepth;
                fog.fogVoidFallOff  = fogVoidFallOff;
                fog.fogVoidHeight   = fogVoidHeight;
                fog.fogVoidPosition = fogVoidPosition;
                fog.fogVoidRadius   = fogVoidRadius;
            }

            // Light scattering
            if (lightScatteringOverride)
            {
                fog.lightScatteringEnabled       = lightScatteringEnabled;
                fog.lightScatteringDecay         = lightScatteringDecay;
                fog.lightScatteringDiffusion     = lightScatteringDiffusion;
                fog.lightScatteringExposure      = lightScatteringExposure;
                fog.lightScatteringIllumination  = lightScatteringIllumination;
                fog.lightScatteringJittering     = lightScatteringJittering;
                fog.lightScatteringBlurDownscale = lightScatteringBlurDownscale;
                fog.lightScatteringSamples       = lightScatteringSamples;
                fog.lightScatteringSpread        = lightScatteringSpread;
                fog.lightScatteringWeight        = lightScatteringWeight;
            }
        }
 void OnEnable()
 {
     fog = GetComponent <VolumetricFog>();
 }
示例#29
0
 public static void Lerp(VolumetricFogProfile profile1, VolumetricFogProfile profile2, float t, VolumetricFog fog)
 {
     if (t < 0f)
     {
         t = 0f;
     }
     else if (t > 1f)
     {
         t = 1f;
     }
     fog.density                       = profile1.density * (1f - t) + profile2.density * t;
     fog.noiseStrength                 = profile1.noiseStrength * (1f - t) + profile2.noiseStrength * t;
     fog.height                        = profile1.height * (1f - t) + profile2.height * t;
     fog.baselineHeight                = profile1.baselineHeight * (1f - t) + profile2.baselineHeight * t;
     fog.distance                      = profile1.baselineHeight * (1f - t) + profile2.distance * t;
     fog.distanceFallOff               = profile1.distanceFallOff * (1f - t) + profile2.distanceFallOff * t;
     fog.maxFogLength                  = profile1.maxFogLength * (1f - t) + profile2.maxFogLength * t;
     fog.maxFogLengthFallOff           = profile1.maxFogLengthFallOff * (1f - t) + profile2.maxFogLengthFallOff * t;
     fog.baselineRelativeToCamera      = ((t >= 0.5f) ? profile2.baselineRelativeToCamera : profile1.baselineRelativeToCamera);
     fog.baselineRelativeToCameraDelay = profile1.baselineRelativeToCameraDelay * (1f - t) + profile2.baselineRelativeToCameraDelay * t;
     fog.noiseScale                    = profile1.noiseScale * (1f - t) + profile2.noiseScale * t;
     fog.noiseSparse                   = profile1.noiseSparse * (1f - t) + profile2.noiseSparse * t;
     fog.sunCopyColor                  = ((t >= 0.5f) ? profile2.sunCopyColor : profile1.sunCopyColor);
     fog.alpha              = profile1.alpha * (1f - t) + profile2.alpha * t;
     fog.color              = profile1.color * (1f - t) + profile2.color * t;
     fog.specularColor      = profile1.specularColor * (1f - t) + profile2.color * t;
     fog.specularThreshold  = profile1.specularThreshold * (1f - t) + profile2.specularThreshold * t;
     fog.specularIntensity  = profile1.specularIntensity * (1f - t) + profile2.specularIntensity * t;
     fog.lightDirection     = profile1.lightDirection * (1f - t) + profile2.lightDirection * t;
     fog.lightIntensity     = profile1.lightIntensity * (1f - t) + profile2.lightIntensity * t;
     fog.lightColor         = profile1.lightColor * (1f - t) + profile2.lightColor * t;
     fog.speed              = profile1.speed * (1f - t) + profile2.speed * t;
     fog.windDirection      = profile1.windDirection * (1f - t) + profile2.windDirection * t;
     fog.turbulenceStrength = profile1.turbulenceStrength * (1f - t) + profile2.turbulenceStrength * t;
     fog.skyColor           = profile1.skyColor * (1f - t) + profile2.skyColor * t;
     fog.skyHaze            = profile1.skyHaze * (1f - t) + profile2.skyHaze * t;
     fog.skySpeed           = profile1.skySpeed * (1f - t) + profile2.skySpeed * t;
     fog.skyNoiseStrength   = profile1.skyNoiseStrength * (1f - t) + profile2.skyNoiseStrength * t;
     fog.skyAlpha           = profile1.skyAlpha * (1f - t) + profile2.skyAlpha * t;
     fog.stepping           = profile1.stepping * (1f - t) + profile2.stepping * t;
     fog.steppingNear       = profile1.steppingNear * (1f - t) + profile2.steppingNear * t;
     fog.dithering          = ((t >= 0.5f) ? profile2.dithering : profile1.dithering);
     fog.ditherStrength     = profile1.ditherStrength * (1f - t) + profile2.ditherStrength * t;
 }
示例#30
0
 void Start()
 {
     fog = Camera.main.GetComponent<VolumetricFog>();
 }