private void OnRenderImage(RenderTexture source, RenderTexture destination) { this.CAMERA_NEAR = base.GetComponent <Camera>().nearClipPlane; this.CAMERA_FAR = base.GetComponent <Camera>().farClipPlane; this.CAMERA_FOV = base.GetComponent <Camera>().fieldOfView; this.CAMERA_ASPECT_RATIO = base.GetComponent <Camera>().aspect; Matrix4x4 identity = Matrix4x4.identity; float num = this.CAMERA_FOV * 0.5f; Vector3 b = base.GetComponent <Camera>().transform.right *this.CAMERA_NEAR * Mathf.Tan(num * 0.0174532924f) * this.CAMERA_ASPECT_RATIO; Vector3 b2 = base.GetComponent <Camera>().transform.up *this.CAMERA_NEAR * Mathf.Tan(num * 0.0174532924f); Vector3 vector = base.GetComponent <Camera>().transform.forward *this.CAMERA_NEAR - b + b2; float d = vector.magnitude * this.CAMERA_FAR / this.CAMERA_NEAR; vector.Normalize(); vector *= d; Vector3 vector2 = base.GetComponent <Camera>().transform.forward *this.CAMERA_NEAR + b + b2; vector2.Normalize(); vector2 *= d; Vector3 vector3 = base.GetComponent <Camera>().transform.forward *this.CAMERA_NEAR + b - b2; vector3.Normalize(); vector3 *= d; Vector3 vector4 = base.GetComponent <Camera>().transform.forward *this.CAMERA_NEAR - b - b2; vector4.Normalize(); vector4 *= d; identity.SetRow(0, vector); identity.SetRow(1, vector2); identity.SetRow(2, vector3); identity.SetRow(3, vector4); this.fogMaterial.SetMatrix("_FrustumCornersWS", identity); this.fogMaterial.SetVector("_CameraWS", base.GetComponent <Camera>().transform.position); this.fogMaterial.SetVector("_Y", new Vector4(this.height, this.heightScale)); this.fogMaterial.SetFloat("_GlobalDensity", this.ViewDistance); this.mieDirectionalG = Mathf.Clamp(this.mieDirectionalG, 0f, 0.999f); this.InscatteringIntensity = Mathf.Clamp(this.InscatteringIntensity, 0f, 30f); this.fogMaterial.SetFloat("mieDirectionalG", this.mieDirectionalG); this.fogMaterial.SetFloat("InscatteringIntensity", this.InscatteringIntensity); this.fogMaterial.SetColor("_FogColor", this.FogColor); this.fogMaterial.SetColor("InscatteringColor", this.InscatteringColor); this.fogMaterial.SetFloat("DirectionalInscatteringStartDistance", this.DirectionalInscatteringStartDistance); this.fogMaterial.SetFloat("reileighCoefficient", this.reileighCoefficient); this.fogMaterial.SetFloat("mieCoefficient", this.mieCoefficient); this.fogMaterial.SetFloat("Molecules", this.Molecules); this.fogMaterial.SetFloat("turbidity", this.turbidity); this.fogMaterial.SetFloat("Exposure", this.Exposure); this.fogMaterial.SetFloat("contrast", this.contrast); this.fogMaterial.SetFloat("TransitionDistance", this.TransitionDistance); this.fogMaterial.SetFloat("SunIntensity", (!this.isDaytime()) ? 0f : this.SunIntensity); this.fogMaterial.SetFloat("SunExponent", this.SunExponent); this.fogMaterial.SetFloat("WorldHeight", this.WorldHeight); this.fogMaterial.SetFloat("SunEditorIntensity", this.SunLightIntensity); this.fogMaterial.SetFloat("OceanLevel", this.OceanLevel); this.fogMaterial.SetFloat("Deepness", this.Deepness); this.fogMaterial.SetColor("DeepColor", this.DeepColor); this.fogMaterial.SetColor("ShoreColor", this.ShoreColor); this.fogMaterial.SetFloat("UnderwaterViewDistance", this.UnderwaterViewDistance); this.fogMaterial.SetFloat("isNighttime", (float)((!this.isDaytime()) ? 1 : 0)); if (this.Sun == null) { Debug.Log("Set the main light"); } else { this.L = -this.Sun.transform.forward; this.LdotUp = Mathf.Clamp01(Vector3.Dot(this.L, Vector3.up)); this.LdotDown = Mathf.Clamp01(Vector3.Dot(this.L, Vector3.down)); } this.fogMaterial.SetVector("L", this.L); this.fogMaterial.SetTexture("frameBuffer", source); if (this.IsolateFog) { this.fogMaterial.SetTexture("frameBuffer", null); } Atmosphere.CustomGraphicsBlit(source, destination, this.fogMaterial, 0); }