Beispiel #1
0
        public void MoveContextItemDown(int index)
        {
            if (index < 0 || index >= this.m_ContextItems.Count - 1)
            {
                return;
            }
            DS_HazeContextItem contextItem = this.m_ContextItems[index];

            this.m_ContextItems.RemoveAt(index);
            this.m_ContextItems.Insert(index + 1, contextItem);
            if (this.m_SoloItem == -1)
            {
                return;
            }
            if (this.m_SoloItem == index)
            {
                ++this.m_SoloItem;
            }
            else
            {
                if (this.m_SoloItem != index + 1)
                {
                    return;
                }
                --this.m_SoloItem;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Move the context variant at index up in the list (unless already at the top).
        /// </summary>
        /// <param name="index"></param>
        public void MoveContextItemUp(int index)
        {
            if (index < 1 || index >= m_ContextItems.Count)
            {
                return;
            }

            DS_HazeContextItem tmp = m_ContextItems[index];

            m_ContextItems.RemoveAt(index);
            m_ContextItems.Insert(index - 1, tmp);

            // Update the solo index.
            if (m_SoloItem == -1)
            {
                return;
            }
            if (m_SoloItem == index)
            {
                m_SoloItem -= 1;
            }
            else if (m_SoloItem == index - 1)
            {
                m_SoloItem++;
            }
        }
        /// <summary>
        /// Linearly interpolate between this variant and another.
        /// </summary>
        /// <param name="other"> DS_HazeContextVariant to interpolate with. </param>
        /// <param name="dt"> How far through the blend. </param>
        public void Lerp(DS_HazeContextItem other, float dt)
        {
            if (other == null)
            {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
                Debug.LogError("DeepSky::DS_HazeContextItem:Lerp - null context passed!");
#endif
                return;
            }

            dt = Mathf.Clamp01(dt);

            float dTinv = 1.0f - dt;

            m_AirScatteringScale           = m_AirScatteringScale * dTinv + other.m_AirScatteringScale * dt;
            m_AirDensityHeightFalloff      = m_AirDensityHeightFalloff * dTinv + other.m_AirDensityHeightFalloff * dt;
            m_HazeScatteringScale          = m_HazeScatteringScale * dTinv + other.m_HazeScatteringScale * dt;
            m_HazeDensityHeightFalloff     = m_HazeDensityHeightFalloff * dTinv + other.m_HazeDensityHeightFalloff * dt;
            m_HazeScatteringDirection      = m_HazeScatteringDirection * dTinv + other.m_HazeScatteringDirection * dt;
            m_HazeSecondaryScatteringRatio = m_HazeSecondaryScatteringRatio * dTinv + other.m_HazeSecondaryScatteringRatio * dt;
            m_FogOpacity              = m_FogOpacity * dTinv + other.m_FogOpacity * dt;
            m_FogScatteringScale      = m_FogScatteringScale * dTinv + other.m_FogScatteringScale * dt;
            m_FogExtinctionScale      = m_FogExtinctionScale * dTinv + other.m_FogExtinctionScale * dt;
            m_FogDensityHeightFalloff = m_FogDensityHeightFalloff * dTinv + other.m_FogDensityHeightFalloff * dt;
            m_FogStartDistance        = m_FogStartDistance * dTinv + other.m_FogStartDistance * dt;
            m_FogScatteringDirection  = m_FogScatteringDirection * dTinv + other.m_FogScatteringDirection * dt;
            m_FogAmbientColour        = m_FogAmbientColour * dTinv + other.m_FogAmbientColour * dt;
            m_FogLightColour          = m_FogLightColour * dTinv + other.m_FogLightColour * dt;
        }
Beispiel #4
0
        /// <summary>
        /// Return a DS_HazeContextVariant that has the linearly interpolated values, from top-to-bottom
        /// in the stack. If a variant is 'soloed', or there's only one, then that is returned as-is.
        /// </summary>
        public DS_HazeContextItem GetContextItemBlended(float time = -1)
        {
            DS_HazeContextItem blended = new DS_HazeContextItem();

            blended.CopyFrom(m_ContextItems[0]);

            // If there's only the default variant, return it directly.
            if (m_ContextItems.Count == 1)
            {
                return(blended);
            }

            // Check for a 'soloed' variant (editor only).
#if UNITY_EDITOR
            if (m_SoloItem > -1 && m_SoloItem < m_ContextItems.Count)
            {
                blended.CopyFrom(m_ContextItems[m_SoloItem]);
                return(blended);
            }
#endif
            // Created a blended variant.
            time = Mathf.Clamp01(time);
            float weight = 0;
            for (int cv = 1; cv < m_ContextItems.Count; cv++)
            {
                weight = m_ContextItems[cv].m_Weight.Evaluate(time);
                blended.Lerp(m_ContextItems[cv], weight);
            }

            return(blended);
        }
        public void Lerp(DS_HazeContextItem other, float dt)
        {
            if (other == null)
            {
                return;
            }
            dt = Mathf.Clamp01(dt);
            float num = 1f - dt;

            this.m_AirScatteringScale           = (float)((double)this.m_AirScatteringScale * (double)num + (double)other.m_AirScatteringScale * (double)dt);
            this.m_AirDensityHeightFalloff      = (float)((double)this.m_AirDensityHeightFalloff * (double)num + (double)other.m_AirDensityHeightFalloff * (double)dt);
            this.m_HazeScatteringScale          = (float)((double)this.m_HazeScatteringScale * (double)num + (double)other.m_HazeScatteringScale * (double)dt);
            this.m_HazeDensityHeightFalloff     = (float)((double)this.m_HazeDensityHeightFalloff * (double)num + (double)other.m_HazeDensityHeightFalloff * (double)dt);
            this.m_HazeScatteringDirection      = (float)((double)this.m_HazeScatteringDirection * (double)num + (double)other.m_HazeScatteringDirection * (double)dt);
            this.m_HazeSecondaryScatteringRatio = (float)((double)this.m_HazeSecondaryScatteringRatio * (double)num + (double)other.m_HazeSecondaryScatteringRatio * (double)dt);
            this.m_FogOpacity              = (float)((double)this.m_FogOpacity * (double)num + (double)other.m_FogOpacity * (double)dt);
            this.m_FogScatteringScale      = (float)((double)this.m_FogScatteringScale * (double)num + (double)other.m_FogScatteringScale * (double)dt);
            this.m_FogExtinctionScale      = (float)((double)this.m_FogExtinctionScale * (double)num + (double)other.m_FogExtinctionScale * (double)dt);
            this.m_FogDensityHeightFalloff = (float)((double)this.m_FogDensityHeightFalloff * (double)num + (double)other.m_FogDensityHeightFalloff * (double)dt);
            this.m_FogStartDistance        = (float)((double)this.m_FogStartDistance * (double)num + (double)other.m_FogStartDistance * (double)dt);
            this.m_FogScatteringDirection  = (float)((double)this.m_FogScatteringDirection * (double)num + (double)other.m_FogScatteringDirection * (double)dt);
            this.m_FogStartHeight          = (float)((double)this.m_FogStartHeight * (double)num + (double)other.m_FogStartHeight * (double)dt);
            this.m_FogAmbientColour        = Color.op_Addition(Color.op_Multiply(this.m_FogAmbientColour, num), Color.op_Multiply(other.m_FogAmbientColour, dt));
            this.m_FogLightColour          = Color.op_Addition(Color.op_Multiply(this.m_FogLightColour, num), Color.op_Multiply(other.m_FogLightColour, dt));
        }
        public DS_HazeContextItem GetRenderContextAtPosition(Vector3 position)
        {
            List <DS_HazeZone> dsHazeZoneList = new List <DS_HazeZone>();

            for (int index = 0; index < this.m_Zones.Count; ++index)
            {
                if (this.m_Zones[index].Contains(position) && ((Behaviour)this.m_Zones[index]).get_enabled())
                {
                    dsHazeZoneList.Add(this.m_Zones[index]);
                }
            }
            if (dsHazeZoneList.Count == 0)
            {
                return((DS_HazeContextItem)null);
            }
            if (dsHazeZoneList.Count == 1)
            {
                return(dsHazeZoneList[0].Context.GetContextItemBlended(this.m_Time));
            }
            dsHazeZoneList.Sort((Comparison <DS_HazeZone>)((z1, z2) => z1 < z2 ? -1 : 1));
            DS_HazeContextItem contextItemBlended = dsHazeZoneList[0].Context.GetContextItemBlended(this.m_Time);

            for (int index = 1; index < dsHazeZoneList.Count; ++index)
            {
                float blendWeight = dsHazeZoneList[index].GetBlendWeight(position);
                contextItemBlended.Lerp(dsHazeZoneList[index].Context.GetContextItemBlended(this.m_Time), blendWeight);
            }
            return(contextItemBlended);
        }
Beispiel #7
0
        /// <summary>
        /// Default constructor - with a 'Default' DS_HazeContextVariant and a time of 0.5 (midday).
        /// </summary>
        public DS_HazeContext()
        {
            m_ContextItems = new List <DS_HazeContextItem>();
            DS_HazeContextItem ctxItem = new DS_HazeContextItem();

            ctxItem.m_Name = "Default";
            m_ContextItems.Add(ctxItem);
        }
Beispiel #8
0
        public void DuplicateContextItem(int index)
        {
            if (index < 0 || index >= this.m_ContextItems.Count)
            {
                return;
            }
            DS_HazeContextItem dsHazeContextItem = new DS_HazeContextItem();

            dsHazeContextItem.CopyFrom(this.m_ContextItems[index]);
            dsHazeContextItem.m_Name += "_Copy";
            this.m_ContextItems.Add(dsHazeContextItem);
        }
Beispiel #9
0
 public void CopyFrom(DS_HazeContext other)
 {
     if (this.m_ContextItems.Count > 0)
     {
         this.m_ContextItems.Clear();
     }
     for (int index = 0; index < other.m_ContextItems.Count; ++index)
     {
         DS_HazeContextItem dsHazeContextItem = new DS_HazeContextItem();
         dsHazeContextItem.CopyFrom(other.m_ContextItems[index]);
         this.m_ContextItems.Add(dsHazeContextItem);
     }
 }
Beispiel #10
0
        /// <summary>
        /// Create and add a duplicate of the passed DS_HazeContextVariant.
        /// </summary>
        /// <param name="index"> Index into context variants list of the one to duplicate. </param>
        public void DuplicateContextItem(int index)
        {
            if (index < 0 || index >= m_ContextItems.Count)
            {
                return;
            }

            DS_HazeContextItem dup = new DS_HazeContextItem();

            dup.CopyFrom(m_ContextItems[index]);
            dup.m_Name += "_Copy";
            m_ContextItems.Add(dup);
        }
Beispiel #11
0
        /// <summary>
        /// Copy settings and time-of-day variants from another DS_HazeContext.
        /// </summary>
        /// <param name="other"> DS_HazeContext to copy from. </param>
        public void CopyFrom(DS_HazeContext other)
        {
            // Clear any existing variants first.
            if (m_ContextItems.Count > 0)
            {
                m_ContextItems.Clear();
            }

            for (int cv = 0; cv < other.m_ContextItems.Count; cv++)
            {
                DS_HazeContextItem ctxV = new DS_HazeContextItem();
                ctxV.CopyFrom(other.m_ContextItems[cv]);

                m_ContextItems.Add(ctxV);
            }
        }
        public void CopyFrom(DS_HazeContextItem other)
        {
            if (other == null)
            {
                return;
            }
            Type type1 = this.GetType();
            Type type2 = other.GetType();

            foreach (FieldInfo field1 in type1.GetFields())
            {
                FieldInfo field2 = type2.GetField(field1.Name);
                field1.SetValue((object)this, field2.GetValue((object)other));
            }
            this.m_Weight = new AnimationCurve(this.m_Weight.get_keys());
        }
Beispiel #13
0
        public DS_HazeContextItem GetContextItemBlended(float time = -1f)
        {
            DS_HazeContextItem dsHazeContextItem = new DS_HazeContextItem();

            dsHazeContextItem.CopyFrom(this.m_ContextItems[0]);
            if (this.m_ContextItems.Count == 1)
            {
                return(dsHazeContextItem);
            }
            time = Mathf.Clamp01(time);
            for (int index = 1; index < this.m_ContextItems.Count; ++index)
            {
                float dt = this.m_ContextItems[index].m_Weight.Evaluate(time);
                dsHazeContextItem.Lerp(this.m_ContextItems[index], dt);
            }
            return(dsHazeContextItem);
        }
Beispiel #14
0
        /// <summary>
        /// Find the zones containing the given position and blend between them.
        /// The render context will be null if the position is not within any zones.
        /// If there is only one zone, that will provide the context as-is.
        /// </summary>
        public DS_HazeContextItem GetRenderContextAtPosition(Vector3 position)
        {
            List <DS_HazeZone> blendZones = new List <DS_HazeZone>();

            for (int zi = 0; zi < m_Zones.Count; zi++)
            {
                if (m_Zones[zi].Contains(position) && m_Zones[zi].enabled)
                {
                    blendZones.Add(m_Zones[zi]);
                }
            }

            if (blendZones.Count == 0)
            {
                return(null);
            }

            if (blendZones.Count == 1)
            {
                return(blendZones[0].Context.GetContextItemBlended(m_Time));
            }

            blendZones.Sort(delegate(DS_HazeZone z1, DS_HazeZone z2)
            {
                if (z1 < z2)
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            });

            // With the list in priority order (lowest to highest), iterate through and blend from first to last.
            DS_HazeContextItem renderContext = blendZones[0].Context.GetContextItemBlended(m_Time);
            float weight = 0;

            for (int ci = 1; ci < blendZones.Count; ci++)
            {
                weight = blendZones[ci].GetBlendWeight(position);
                renderContext.Lerp(blendZones[ci].Context.GetContextItemBlended(m_Time), weight);
            }

            return(renderContext);
        }
        /// <summary>
        /// Copy all the values from 'other'.
        /// </summary>
        /// <param name="other"> The DS_HazeContextVariant to get values from. </param>
        public void CopyFrom(DS_HazeContextItem other)
        {
            if (other == null)
            {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
                Debug.LogError("DeepSky::DS_HazeContextItem:CopyFrom - null context passed!");
#endif
                return;
            }

            Type thisType  = GetType();
            Type otherType = other.GetType();

            foreach (FieldInfo field in thisType.GetFields())
            {
                FieldInfo otherField = otherType.GetField(field.Name);
                field.SetValue(this, otherField.GetValue(other));
            }

            // We need an actual copy of the weight curve, not just the reference.
            m_Weight = new AnimationCurve(m_Weight.keys);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            EditorGUI.indentLevel++;

            float curY      = position.y + EditorGUIUtility.singleLineHeight / 2;
            float ctrlCount = 0;
            float ctrlSizeY = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            // Get all the rects upfront.
            Rect name       = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect aLabel     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect aBetaSMult = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect aBetaS     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect aFalloff   = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hLabel     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hBetaSMult = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hBetaS     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hFalloff   = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hDir       = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect hRatio     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fLabel     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fOpacity   = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fBetaS     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fExtMult   = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fExtS      = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fFalloff   = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fDist      = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fDir       = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fAmb       = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);
            Rect fLight     = new Rect(position.x, curY + ctrlSizeY * ctrlCount++, position.width, EditorGUIUtility.singleLineHeight);

            // Draw all the properties and labels.
            SerializedProperty airMultProp     = property.FindPropertyRelative("m_AirScatteringMultiplier");
            SerializedProperty hazeMultProp    = property.FindPropertyRelative("m_HazeScatteringMultiplier");
            SerializedProperty fogEMultProp    = property.FindPropertyRelative("m_FogExtinctionMultiplier");
            SerializedProperty airScatterProp  = property.FindPropertyRelative("m_AirScatteringScale");
            SerializedProperty hazeScatterProp = property.FindPropertyRelative("m_HazeScatteringScale");
            SerializedProperty fogEProp        = property.FindPropertyRelative("m_FogExtinctionScale");

            GUIStyle popupStyle = new GUIStyle(EditorStyles.popup);

            popupStyle.alignment  = TextAnchor.MiddleLeft;
            popupStyle.fixedWidth = 40;

            DS_HazeCore.HeightFalloffType falloff = DS_HazeCore.HeightFalloffType.Exponential;

            if (DS_HazeCore.Instance != null)
            {
                falloff = DS_HazeCore.Instance.HeightFalloff;
            }

            EditorGUI.PropertyField(name, property.FindPropertyRelative("m_Name"));
            EditorGUI.LabelField(aLabel, "Air:", EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();
            airMultProp.enumValueIndex = EditorGUI.Popup(aBetaSMult, "Scattering Multiplier", airMultProp.enumValueIndex, MultiplierStr, popupStyle);

            float airParamMax = 8 * DS_HazeContextItem.MultiplierAsFloat((DS_HazeContextItem.Multiplier)airMultProp.enumValueIndex);

            EditorGUI.Slider(aBetaS, airScatterProp, 0, airParamMax, "Scattering");

            if (EditorGUI.EndChangeCheck())
            {
                if (airScatterProp.floatValue > airParamMax)
                {
                    airScatterProp.floatValue = airParamMax;
                }
            }

            bool wasEnabled = GUI.enabled;

            if (falloff != DS_HazeCore.HeightFalloffType.Exponential)
            {
                GUI.enabled = false;
            }
            EditorGUI.PropertyField(aFalloff, property.FindPropertyRelative("m_AirDensityHeightFalloff"), new GUIContent("Height Falloff", strToolTipAirHeightFalloff));
            GUI.enabled = wasEnabled;

            EditorGUI.LabelField(hLabel, "Haze:", EditorStyles.boldLabel);
            EditorGUI.BeginChangeCheck();
            hazeMultProp.enumValueIndex = EditorGUI.Popup(hBetaSMult, "Scattering Multiplier", hazeMultProp.enumValueIndex, MultiplierStr, popupStyle);

            float hazeParamMax = 8 * DS_HazeContextItem.MultiplierAsFloat((DS_HazeContextItem.Multiplier)hazeMultProp.enumValueIndex);

            EditorGUI.Slider(hBetaS, hazeScatterProp, 0, hazeParamMax, "Scattering");

            if (EditorGUI.EndChangeCheck())
            {
                if (hazeScatterProp.floatValue > hazeParamMax)
                {
                    hazeScatterProp.floatValue = hazeParamMax;
                }
            }

            wasEnabled = GUI.enabled;
            if (falloff != DS_HazeCore.HeightFalloffType.Exponential)
            {
                GUI.enabled = false;
            }
            EditorGUI.PropertyField(hFalloff, property.FindPropertyRelative("m_HazeDensityHeightFalloff"), new GUIContent("Height Falloff", strToolTipHazeHeightFalloff));
            GUI.enabled = wasEnabled;

            EditorGUI.PropertyField(hDir, property.FindPropertyRelative("m_HazeScatteringDirection"), new GUIContent("Scatter Direction", strToolTipHazeScatterDirection));
            EditorGUI.PropertyField(hRatio, property.FindPropertyRelative("m_HazeSecondaryScatteringRatio"), new GUIContent("Direct/Indirect Ratio", strToolTipHazeIndirectRatio));
            EditorGUI.LabelField(fLabel, "Fog/Mist:", EditorStyles.boldLabel);
            EditorGUI.PropertyField(fOpacity, property.FindPropertyRelative("m_FogOpacity"), new GUIContent("Opacity", strToolTipFogOpacity));

            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(fBetaS, property.FindPropertyRelative("m_FogScatteringScale"), new GUIContent("Scattering", strToolTipFogScatterScale));
            fogEMultProp.enumValueIndex = EditorGUI.Popup(fExtMult, "Extinction Multiplier", fogEMultProp.enumValueIndex, MultiplierStr, popupStyle);

            float fogEParamMax = 8 * DS_HazeContextItem.MultiplierAsFloat((DS_HazeContextItem.Multiplier)fogEMultProp.enumValueIndex);

            EditorGUI.Slider(fExtS, fogEProp, 0, fogEParamMax, "Extinction");

            if (EditorGUI.EndChangeCheck())
            {
                if (fogEProp.floatValue > fogEParamMax)
                {
                    fogEProp.floatValue = fogEParamMax;
                }
            }

            wasEnabled = GUI.enabled;
            if (falloff != DS_HazeCore.HeightFalloffType.Exponential)
            {
                GUI.enabled = false;
            }
            EditorGUI.PropertyField(fFalloff, property.FindPropertyRelative("m_FogDensityHeightFalloff"), new GUIContent("Height Falloff", strToolTipFogHeightFalloff));
            GUI.enabled = wasEnabled;

            EditorGUI.PropertyField(fDist, property.FindPropertyRelative("m_FogStartDistance"), new GUIContent("Start Distance", strToolTipFogStartDistance));
            EditorGUI.PropertyField(fDir, property.FindPropertyRelative("m_FogScatteringDirection"), new GUIContent("Scatter Direction", strToolTipFogScatterDirection));
            EditorGUI.PropertyField(fAmb, property.FindPropertyRelative("m_FogAmbientColour"), new GUIContent("Ambient Colour", strToolTipFogAmbCol));
            EditorGUI.PropertyField(fLight, property.FindPropertyRelative("m_FogLightColour"), new GUIContent("Light Colour", strToolTipFogLightCol));

            EditorGUI.indentLevel--;
            EditorGUI.EndProperty();
        }
        private void SetMaterialFromContext(DS_HazeContextItem ctx)
        {
            if (this.WillRenderWithTemporalReprojection)
            {
                this.m_InterleavedOffsetIndex += 1f / 16f;
                if (Mathf.Approximately(this.m_InterleavedOffsetIndex, 1f))
                {
                    this.m_InterleavedOffsetIndex = 0.0f;
                }
            }
            float num1 = 1f;
            float num2 = 1f;
            float num3 = 1f;

            switch (DS_HazeCore.Instance.HeightFalloff)
            {
            case DS_HazeCore.HeightFalloffType.Exponential:
                float num4 = Mathf.Abs((float)((Component)this).get_transform().get_position().y);
                num1 = Mathf.Exp(-ctx.m_AirDensityHeightFalloff * num4);
                num2 = Mathf.Exp(-ctx.m_HazeDensityHeightFalloff * num4);
                num3 = Mathf.Exp((float)(-(double)ctx.m_FogDensityHeightFalloff * ((double)num4 - (double)ctx.m_FogStartHeight)));
                break;

            case DS_HazeCore.HeightFalloffType.None:
                num1 = 1f;
                num2 = 1f;
                num3 = 1f;
                break;
            }
            Vector3 vector3_1          = Vector3.op_Multiply(ctx.m_AirScatteringScale, new Vector3(0.00116f, 0.0027f, 0.00662f));
            float   num5               = ctx.m_HazeScatteringScale * 0.0021f;
            float   fogScatteringScale = ctx.m_FogScatteringScale;
            float   num6               = ctx.m_FogExtinctionScale * 0.01f;
            Vector4 vector4_1;

            ((Vector4) ref vector4_1).\u002Ector(ctx.m_AirDensityHeightFalloff, ctx.m_HazeDensityHeightFalloff, 0.0f, ctx.m_HazeScatteringDirection);
            Vector4 vector4_2;

            ((Vector4) ref vector4_2).\u002Ector(num5, !this.m_RenderAtmosphereVolumetrics ? 0.0f : ctx.m_HazeSecondaryScatteringRatio, fogScatteringScale, num6);
            Vector4 vector4_3;

            ((Vector4) ref vector4_3).\u002Ector(num1, num2, num3, 0.0f);
            Vector4 vector4_4;

            ((Vector4) ref vector4_4).\u002Ector(ctx.m_FogStartDistance, ctx.m_FogDensityHeightFalloff, ctx.m_FogOpacity, ctx.m_FogScatteringDirection);
            Vector4 vector4_5;

            ((Vector4) ref vector4_5).\u002Ector((float)this.m_GaussianDepthFalloff, this.m_UpsampleDepthThreshold * 0.01f, this.m_TemporalRejectionScale, this.m_TemporalBlendFactor);
            this.m_Material.SetVector("_SamplingParams", vector4_5);
            this.m_Material.SetVector("_InterleavedOffset", new Vector4(this.m_InterleavedOffsetIndex, 0.0f, 0.0f, 0.0f));
            this.m_Material.SetMatrix("_PreviousViewProjMatrix", this.m_PreviousViewProjMatrix);
            this.m_Material.SetMatrix("_PreviousInvViewProjMatrix", this.m_PreviousInvViewProjMatrix);
            Shader.SetGlobalVector("_DS_BetaParams", vector4_2);
            Shader.SetGlobalVector("_DS_RBetaS", Vector4.op_Implicit(vector3_1));
            Shader.SetGlobalVector("_DS_AirHazeParams", vector4_1);
            Shader.SetGlobalVector("_DS_FogParams", vector4_4);
            Shader.SetGlobalVector("_DS_InitialDensityParams", vector4_3);
            Vector3 vector3_2;
            Color   color1;

            if (Object.op_Implicit((Object)this.m_DirectLight))
            {
                vector3_2 = Vector3.op_UnaryNegation(((Component)this.m_DirectLight).get_transform().get_forward());
                Color color2 = this.m_DirectLight.get_color();
                color1 = Color.op_Multiply(((Color) ref color2).get_linear(), this.m_DirectLight.get_intensity());
                Shader.SetGlobalColor("_DS_FogAmbientLight", Color.op_Multiply(((Color) ref ctx.m_FogAmbientColour).get_linear(), this.m_DirectLight.get_intensity()));
                Shader.SetGlobalColor("_DS_FogDirectLight", Color.op_Multiply(((Color) ref ctx.m_FogLightColour).get_linear(), this.m_DirectLight.get_intensity()));
            }
            else
            {
                vector3_2 = Vector3.get_up();
                color1    = Color.get_white();
                Shader.SetGlobalColor("_DS_FogAmbientLight", ((Color) ref ctx.m_FogAmbientColour).get_linear());
                Shader.SetGlobalColor("_DS_FogDirectLight", ((Color) ref ctx.m_FogLightColour).get_linear());
            }
            Shader.SetGlobalVector("_DS_LightDirection", Vector4.op_Implicit(vector3_2));
            Shader.SetGlobalVector("_DS_LightColour", Color.op_Implicit(color1));
        }