using System; using UnityEngine; namespace UnityStandardAssets.CinematicEffects { // Token: 0x0200001F RID: 31 [ExecuteInEditMode] [AddComponentMenu("Image Effects/Cinematic/Depth Of Field")] [RequireComponent(typeof(Camera))] public class DepthOfField : MonoBehaviour { // Token: 0x17000029 RID: 41 // (get) Token: 0x06000065 RID: 101 RVA: 0x00003EC8 File Offset: 0x000022C8 public Shader filmicDepthOfFieldShader { get { if (this.m_FilmicDepthOfFieldShader == null) { this.m_FilmicDepthOfFieldShader = Shader.Find("Hidden/DepthOfField/DepthOfField"); } return this.m_FilmicDepthOfFieldShader; } } // Token: 0x1700002A RID: 42 // (get) Token: 0x06000066 RID: 102 RVA: 0x00003EF1 File Offset: 0x000022F1 public Shader medianFilterShader { get { if (this.m_MedianFilterShader == null) { this.m_MedianFilterShader = Shader.Find("Hidden/DepthOfField/MedianFilter"); } return this.m_MedianFilterShader; } } // Token: 0x1700002B RID: 43 // (get) Token: 0x06000067 RID: 103 RVA: 0x00003F1A File Offset: 0x0000231A public Shader textureBokehShader { get { if (this.m_TextureBokehShader == null) { this.m_TextureBokehShader = Shader.Find("Hidden/DepthOfField/BokehSplatting"); } return this.m_TextureBokehShader; } } // Token: 0x1700002C RID: 44 // (get) Token: 0x06000068 RID: 104 RVA: 0x00003F43 File Offset: 0x00002343 public Material filmicDepthOfFieldMaterial { get { if (this.m_FilmicDepthOfFieldMaterial == null) { this.m_FilmicDepthOfFieldMaterial = ImageEffectHelper.CheckShaderAndCreateMaterial(this.filmicDepthOfFieldShader); } return this.m_FilmicDepthOfFieldMaterial; } } // Token: 0x1700002D RID: 45 // (get) Token: 0x06000069 RID: 105 RVA: 0x00003F6D File Offset: 0x0000236D public Material medianFilterMaterial { get { if (this.m_MedianFilterMaterial == null) { this.m_MedianFilterMaterial = ImageEffectHelper.CheckShaderAndCreateMaterial(this.medianFilterShader); } return this.m_MedianFilterMaterial; } } // Token: 0x1700002E RID: 46 // (get) Token: 0x0600006A RID: 106 RVA: 0x00003F97 File Offset: 0x00002397 public Material textureBokehMaterial { get { if (this.m_TextureBokehMaterial == null) { this.m_TextureBokehMaterial = ImageEffectHelper.CheckShaderAndCreateMaterial(this.textureBokehShader); } return this.m_TextureBokehMaterial; } } // Token: 0x1700002F RID: 47 // (get) Token: 0x0600006B RID: 107 RVA: 0x00003FC4 File Offset: 0x000023C4 public ComputeBuffer computeBufferDrawArgs { get { if (this.m_ComputeBufferDrawArgs == null) { this.m_ComputeBufferDrawArgs = new ComputeBuffer(1, 16, ComputeBufferType.DrawIndirect); this.m_ComputeBufferDrawArgs.SetData(new int[] { 0, 1, 0, 0 }); } return this.m_ComputeBufferDrawArgs; } } // Token: 0x17000030 RID: 48 // (get) Token: 0x0600006C RID: 108 RVA: 0x00004011 File Offset: 0x00002411 public ComputeBuffer computeBufferPoints { get { if (this.m_ComputeBufferPoints == null) { this.m_ComputeBufferPoints = new ComputeBuffer(90000, 28, ComputeBufferType.Append); } return this.m_ComputeBufferPoints; } } // Token: 0x0600006D RID: 109 RVA: 0x00004038 File Offset: 0x00002438 private void OnEnable() { if (!ImageEffectHelper.IsSupported(this.filmicDepthOfFieldShader, true, true, this) || !ImageEffectHelper.IsSupported(this.medianFilterShader, true, true, this)) { base.enabled = false; return; } if (ImageEffectHelper.supportsDX11 && !ImageEffectHelper.IsSupported(this.textureBokehShader, true, true, this)) { base.enabled = false; return; } this.ComputeBlurDirections(true); base.GetComponent().depthTextureMode |= DepthTextureMode.Depth; } // Token: 0x0600006E RID: 110 RVA: 0x000040B4 File Offset: 0x000024B4 private void OnDisable() { this.ReleaseComputeResources(); if (this.m_FilmicDepthOfFieldMaterial != null) { global::UnityEngine.Object.DestroyImmediate(this.m_FilmicDepthOfFieldMaterial); } if (this.m_TextureBokehMaterial != null) { global::UnityEngine.Object.DestroyImmediate(this.m_TextureBokehMaterial); } if (this.m_MedianFilterMaterial != null) { global::UnityEngine.Object.DestroyImmediate(this.m_MedianFilterMaterial); } this.m_FilmicDepthOfFieldMaterial = null; this.m_TextureBokehMaterial = null; this.m_MedianFilterMaterial = null; this.m_RTU.ReleaseAllTemporaryRenderTextures(); } // Token: 0x0600006F RID: 111 RVA: 0x0000413C File Offset: 0x0000253C private void OnRenderImage(RenderTexture source, RenderTexture destination) { if (this.medianFilterMaterial == null || this.filmicDepthOfFieldMaterial == null) { Graphics.Blit(source, destination); return; } if (this.settings.visualizeBluriness) { Vector4 vector; Vector4 vector2; this.ComputeCocParameters(out vector, out vector2); this.filmicDepthOfFieldMaterial.SetVector("_BlurParams", vector); this.filmicDepthOfFieldMaterial.SetVector("_BlurCoe", vector2); Graphics.Blit(null, destination, this.filmicDepthOfFieldMaterial, (this.settings.tweakMode != DepthOfField.TweakMode.Explicit) ? 6 : 7); } else { this.DoDepthOfField(source, destination); } this.m_RTU.ReleaseAllTemporaryRenderTextures(); } // Token: 0x06000070 RID: 112 RVA: 0x000041EC File Offset: 0x000025EC private void DoDepthOfField(RenderTexture source, RenderTexture destination) { this.m_CurrentQualitySettings = this.quality; if (this.settings.quality != DepthOfField.QualityPreset.Custom) { this.m_CurrentQualitySettings = DepthOfField.QualitySettings.presetQualitySettings[(int)this.settings.quality]; } float num = (float)source.height / 720f; float num2 = num; float num3 = Mathf.Max(this.blur.nearRadius, this.blur.farRadius) * num2 * 0.75f; float num4 = this.blur.nearRadius * num; float num5 = this.blur.farRadius * num; float num6 = Mathf.Max(num4, num5); DepthOfField.ApertureShape apertureShape = this.settings.apertureShape; if (apertureShape != DepthOfField.ApertureShape.Hexagonal) { if (apertureShape == DepthOfField.ApertureShape.Octogonal) { num6 *= 1.15f; } } else { num6 *= 1.2f; } if (num6 < 0.5f) { Graphics.Blit(source, destination); return; } int num7 = source.width / 2; int num8 = source.height / 2; Vector4 vector = new Vector4(num4 * 0.5f, num5 * 0.5f, 0f, 0f); RenderTexture temporaryRenderTexture = this.m_RTU.GetTemporaryRenderTexture(num7, num8, 0, RenderTextureFormat.ARGBHalf, FilterMode.Bilinear); RenderTexture temporaryRenderTexture2 = this.m_RTU.GetTemporaryRenderTexture(num7, num8, 0, RenderTextureFormat.ARGBHalf, FilterMode.Bilinear); if (this.m_CurrentQualitySettings.preventHaloing) { this.filmicDepthOfFieldMaterial.EnableKeyword("USE_SPECIAL_FETCH_FOR_COC"); } else { this.filmicDepthOfFieldMaterial.DisableKeyword("USE_SPECIAL_FETCH_FOR_COC"); } Vector4 vector2; Vector4 vector3; this.ComputeCocParameters(out vector2, out vector3); this.filmicDepthOfFieldMaterial.SetVector("_BlurParams", vector2); this.filmicDepthOfFieldMaterial.SetVector("_BlurCoe", vector3); this.filmicDepthOfFieldMaterial.SetVector("_BoostParams", new Vector4(num4 * this.blur.nearBoostAmount * -0.5f, num5 * this.blur.farBoostAmount * 0.5f, this.blur.boostPoint, 0f)); Graphics.Blit(source, temporaryRenderTexture2, this.filmicDepthOfFieldMaterial, (this.settings.tweakMode != DepthOfField.TweakMode.Explicit) ? 4 : 5); RenderTexture renderTexture = temporaryRenderTexture2; RenderTexture renderTexture2 = temporaryRenderTexture; if (this.shouldPerformBokeh) { RenderTexture temporaryRenderTexture3 = this.m_RTU.GetTemporaryRenderTexture(num7, num8, 0, RenderTextureFormat.ARGBHalf, FilterMode.Bilinear); Graphics.Blit(renderTexture, temporaryRenderTexture3, this.filmicDepthOfFieldMaterial, 1); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", new Vector4(0f, 1.5f, 0f, 1.5f)); Graphics.Blit(temporaryRenderTexture3, renderTexture2, this.filmicDepthOfFieldMaterial, 0); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", new Vector4(1.5f, 0f, 0f, 1.5f)); Graphics.Blit(renderTexture2, temporaryRenderTexture3, this.filmicDepthOfFieldMaterial, 0); this.textureBokehMaterial.SetTexture("_BlurredColor", temporaryRenderTexture3); this.textureBokehMaterial.SetFloat("_SpawnHeuristic", this.bokehTexture.spawnHeuristic); this.textureBokehMaterial.SetVector("_BokehParams", new Vector4(this.bokehTexture.scale * num2, this.bokehTexture.intensity, this.bokehTexture.threshold, num3)); Graphics.SetRandomWriteTarget(1, this.computeBufferPoints); Graphics.Blit(renderTexture, renderTexture2, this.textureBokehMaterial, 1); Graphics.ClearRandomWriteTargets(); DepthOfField.SwapRenderTexture(ref renderTexture, ref renderTexture2); this.m_RTU.ReleaseTemporaryRenderTexture(temporaryRenderTexture3); } this.filmicDepthOfFieldMaterial.SetVector("_BlurParams", vector2); this.filmicDepthOfFieldMaterial.SetVector("_BlurCoe", vector); this.filmicDepthOfFieldMaterial.SetVector("_BoostParams", new Vector4(num4 * this.blur.nearBoostAmount * -0.5f, num5 * this.blur.farBoostAmount * 0.5f, this.blur.boostPoint, 0f)); RenderTexture renderTexture3 = null; if (this.m_CurrentQualitySettings.dilateNearBlur) { RenderTexture temporaryRenderTexture4 = this.m_RTU.GetTemporaryRenderTexture(num7, num8, 0, RenderTextureFormat.RGHalf, FilterMode.Bilinear); renderTexture3 = this.m_RTU.GetTemporaryRenderTexture(num7, num8, 0, RenderTextureFormat.RGHalf, FilterMode.Bilinear); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", new Vector4(0f, num4 * 0.75f, 0f, 0f)); Graphics.Blit(renderTexture, temporaryRenderTexture4, this.filmicDepthOfFieldMaterial, 2); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", new Vector4(num4 * 0.75f, 0f, 0f, 0f)); Graphics.Blit(temporaryRenderTexture4, renderTexture3, this.filmicDepthOfFieldMaterial, 3); this.m_RTU.ReleaseTemporaryRenderTexture(temporaryRenderTexture4); renderTexture3.filterMode = FilterMode.Point; } if (this.m_CurrentQualitySettings.prefilterBlur) { Graphics.Blit(renderTexture, renderTexture2, this.filmicDepthOfFieldMaterial, 8); DepthOfField.SwapRenderTexture(ref renderTexture, ref renderTexture2); } DepthOfField.ApertureShape apertureShape2 = this.settings.apertureShape; if (apertureShape2 != DepthOfField.ApertureShape.Circular) { if (apertureShape2 != DepthOfField.ApertureShape.Hexagonal) { if (apertureShape2 == DepthOfField.ApertureShape.Octogonal) { this.DoOctogonalBlur(renderTexture3, ref renderTexture, ref renderTexture2, num6); } } else { this.DoHexagonalBlur(renderTexture3, ref renderTexture, ref renderTexture2, num6); } } else { this.DoCircularBlur(renderTexture3, ref renderTexture, ref renderTexture2, num6); } DepthOfField.FilterQuality medianFilter = this.m_CurrentQualitySettings.medianFilter; if (medianFilter != DepthOfField.FilterQuality.Normal) { if (medianFilter == DepthOfField.FilterQuality.High) { Graphics.Blit(renderTexture, renderTexture2, this.medianFilterMaterial, 1); DepthOfField.SwapRenderTexture(ref renderTexture, ref renderTexture2); } } else { this.medianFilterMaterial.SetVector("_Offsets", new Vector4(1f, 0f, 0f, 0f)); Graphics.Blit(renderTexture, renderTexture2, this.medianFilterMaterial, 0); DepthOfField.SwapRenderTexture(ref renderTexture, ref renderTexture2); this.medianFilterMaterial.SetVector("_Offsets", new Vector4(0f, 1f, 0f, 0f)); Graphics.Blit(renderTexture, renderTexture2, this.medianFilterMaterial, 0); DepthOfField.SwapRenderTexture(ref renderTexture, ref renderTexture2); } this.filmicDepthOfFieldMaterial.SetVector("_BlurCoe", vector); this.filmicDepthOfFieldMaterial.SetVector("_Convolved_TexelSize", new Vector4((float)renderTexture.width, (float)renderTexture.height, 1f / (float)renderTexture.width, 1f / (float)renderTexture.height)); this.filmicDepthOfFieldMaterial.SetTexture("_SecondTex", renderTexture); int num9 = ((this.settings.tweakMode != DepthOfField.TweakMode.Explicit) ? 13 : 14); if (this.m_CurrentQualitySettings.highQualityUpsampling) { num9 = ((this.settings.tweakMode != DepthOfField.TweakMode.Explicit) ? 15 : 16); } if (this.shouldPerformBokeh) { RenderTexture temporaryRenderTexture5 = this.m_RTU.GetTemporaryRenderTexture(source.height, source.width, 0, source.format, FilterMode.Bilinear); Graphics.Blit(source, temporaryRenderTexture5, this.filmicDepthOfFieldMaterial, num9); Graphics.SetRenderTarget(temporaryRenderTexture5); ComputeBuffer.CopyCount(this.computeBufferPoints, this.computeBufferDrawArgs, 0); this.textureBokehMaterial.SetBuffer("pointBuffer", this.computeBufferPoints); this.textureBokehMaterial.SetTexture("_MainTex", this.bokehTexture.texture); this.textureBokehMaterial.SetVector("_Screen", new Vector3(1f / (1f * (float)source.width), 1f / (1f * (float)source.height), num3)); this.textureBokehMaterial.SetPass(0); Graphics.DrawProceduralIndirect(MeshTopology.Points, this.computeBufferDrawArgs, 0); Graphics.Blit(temporaryRenderTexture5, destination); } else { Graphics.Blit(source, destination, this.filmicDepthOfFieldMaterial, num9); } } // Token: 0x06000071 RID: 113 RVA: 0x00004994 File Offset: 0x00002D94 private void DoHexagonalBlur(RenderTexture blurredFgCoc, ref RenderTexture src, ref RenderTexture dst, float maxRadius) { this.ComputeBlurDirections(false); int num; int num2; DepthOfField.GetDirectionalBlurPassesFromRadius(blurredFgCoc, maxRadius, out num, out num2); this.filmicDepthOfFieldMaterial.SetTexture("_SecondTex", blurredFgCoc); RenderTexture temporaryRenderTexture = this.m_RTU.GetTemporaryRenderTexture(src.width, src.height, 0, src.format, FilterMode.Bilinear); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_HexagonalBokehDirection1); Graphics.Blit(src, temporaryRenderTexture, this.filmicDepthOfFieldMaterial, num); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_HexagonalBokehDirection2); Graphics.Blit(temporaryRenderTexture, src, this.filmicDepthOfFieldMaterial, num); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_HexagonalBokehDirection3); this.filmicDepthOfFieldMaterial.SetTexture("_ThirdTex", src); Graphics.Blit(temporaryRenderTexture, dst, this.filmicDepthOfFieldMaterial, num2); this.m_RTU.ReleaseTemporaryRenderTexture(temporaryRenderTexture); DepthOfField.SwapRenderTexture(ref src, ref dst); } // Token: 0x06000072 RID: 114 RVA: 0x00004A7C File Offset: 0x00002E7C private void DoOctogonalBlur(RenderTexture blurredFgCoc, ref RenderTexture src, ref RenderTexture dst, float maxRadius) { this.ComputeBlurDirections(false); int num; int num2; DepthOfField.GetDirectionalBlurPassesFromRadius(blurredFgCoc, maxRadius, out num, out num2); this.filmicDepthOfFieldMaterial.SetTexture("_SecondTex", blurredFgCoc); RenderTexture temporaryRenderTexture = this.m_RTU.GetTemporaryRenderTexture(src.width, src.height, 0, src.format, FilterMode.Bilinear); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_OctogonalBokehDirection1); Graphics.Blit(src, temporaryRenderTexture, this.filmicDepthOfFieldMaterial, num); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_OctogonalBokehDirection2); Graphics.Blit(temporaryRenderTexture, dst, this.filmicDepthOfFieldMaterial, num); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_OctogonalBokehDirection3); Graphics.Blit(src, temporaryRenderTexture, this.filmicDepthOfFieldMaterial, num); this.filmicDepthOfFieldMaterial.SetVector("_Offsets", this.m_OctogonalBokehDirection4); this.filmicDepthOfFieldMaterial.SetTexture("_ThirdTex", dst); Graphics.Blit(temporaryRenderTexture, src, this.filmicDepthOfFieldMaterial, num2); this.m_RTU.ReleaseTemporaryRenderTexture(temporaryRenderTexture); } // Token: 0x06000073 RID: 115 RVA: 0x00004B84 File Offset: 0x00002F84 private void DoCircularBlur(RenderTexture blurredFgCoc, ref RenderTexture src, ref RenderTexture dst, float maxRadius) { int num; if (blurredFgCoc != null) { this.filmicDepthOfFieldMaterial.SetTexture("_SecondTex", blurredFgCoc); num = ((maxRadius <= 10f) ? 12 : 10); } else { num = ((maxRadius <= 10f) ? 11 : 9); } Graphics.Blit(src, dst, this.filmicDepthOfFieldMaterial, num); DepthOfField.SwapRenderTexture(ref src, ref dst); } // Token: 0x06000074 RID: 116 RVA: 0x00004BF8 File Offset: 0x00002FF8 private void ComputeCocParameters(out Vector4 blurParams, out Vector4 blurCoe) { Camera component = base.GetComponent(); float num = ((!this.focus.transform) ? (this.focus.plane * this.focus.plane * this.focus.plane * this.focus.plane) : (component.WorldToViewportPoint(this.focus.transform.position).z / component.farClipPlane)); if (this.settings.tweakMode == DepthOfField.TweakMode.Basic || this.settings.tweakMode == DepthOfField.TweakMode.Advanced) { float num2 = this.focus.rangeAdjustment * this.focus.rangeAdjustment * this.focus.rangeAdjustment * this.focus.rangeAdjustment; float num3 = 4f / Mathf.Tan(0.5f * component.fieldOfView * 0.017453292f); float num4 = num3 / this.focus.fStops; blurCoe = new Vector4(0f, 0f, 1f, 1f); blurParams = new Vector4(num4, num3, num, num2); } else { float num5 = this.focus.nearPlane * this.focus.nearPlane * this.focus.nearPlane * this.focus.nearPlane; float num6 = this.focus.farPlane * this.focus.farPlane * this.focus.farPlane * this.focus.farPlane; float num7 = this.focus.rangeAdjustment * this.focus.rangeAdjustment * this.focus.rangeAdjustment * this.focus.rangeAdjustment; float num8 = num7; if (num <= num5) { num = num5 + 1E-07f; } if (num >= num6) { num = num6 - 1E-07f; } if (num - num7 <= num5) { num7 = num - num5 - 1E-07f; } if (num + num8 >= num6) { num8 = num6 - num - 1E-07f; } float num9 = 1f / (num5 - num + num7); float num10 = 1f / (num6 - num - num8); float num11 = 1f - num9 * num5; float num12 = 1f - num10 * num6; blurParams = new Vector4(-1f * num9, -1f * num11, 1f * num10, 1f * num12); blurCoe = new Vector4(0f, 0f, (num12 - num11) / (num9 - num10), 0f); } } // Token: 0x06000075 RID: 117 RVA: 0x00004E8B File Offset: 0x0000328B private void ReleaseComputeResources() { if (this.m_ComputeBufferDrawArgs != null) { this.m_ComputeBufferDrawArgs.Release(); } if (this.m_ComputeBufferPoints != null) { this.m_ComputeBufferPoints.Release(); } this.m_ComputeBufferDrawArgs = null; this.m_ComputeBufferPoints = null; } // Token: 0x06000076 RID: 118 RVA: 0x00004EC8 File Offset: 0x000032C8 private void ComputeBlurDirections(bool force) { if (!force && Math.Abs(this.m_LastApertureOrientation - this.settings.apertureOrientation) < 1E-45f) { return; } this.m_LastApertureOrientation = this.settings.apertureOrientation; float num = this.settings.apertureOrientation * 0.017453292f; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); this.m_OctogonalBokehDirection1 = new Vector4(0.5f, 0f, 0f, 0f); this.m_OctogonalBokehDirection2 = new Vector4(0f, 0.5f, 1f, 0f); this.m_OctogonalBokehDirection3 = new Vector4(-0.353553f, 0.353553f, 1f, 0f); this.m_OctogonalBokehDirection4 = new Vector4(0.353553f, 0.353553f, 1f, 0f); this.m_HexagonalBokehDirection1 = new Vector4(0.5f, 0f, 0f, 0f); this.m_HexagonalBokehDirection2 = new Vector4(0.25f, 0.433013f, 1f, 0f); this.m_HexagonalBokehDirection3 = new Vector4(0.25f, -0.433013f, 1f, 0f); if (num > 1E-45f) { DepthOfField.Rotate2D(ref this.m_OctogonalBokehDirection1, num2, num3); DepthOfField.Rotate2D(ref this.m_OctogonalBokehDirection2, num2, num3); DepthOfField.Rotate2D(ref this.m_OctogonalBokehDirection3, num2, num3); DepthOfField.Rotate2D(ref this.m_OctogonalBokehDirection4, num2, num3); DepthOfField.Rotate2D(ref this.m_HexagonalBokehDirection1, num2, num3); DepthOfField.Rotate2D(ref this.m_HexagonalBokehDirection2, num2, num3); DepthOfField.Rotate2D(ref this.m_HexagonalBokehDirection3, num2, num3); } } // Token: 0x17000031 RID: 49 // (get) Token: 0x06000077 RID: 119 RVA: 0x00005070 File Offset: 0x00003470 private bool shouldPerformBokeh { get { return ImageEffectHelper.supportsDX11 && this.bokehTexture.texture != null && this.textureBokehMaterial && this.settings.tweakMode != DepthOfField.TweakMode.Basic; } } // Token: 0x06000078 RID: 120 RVA: 0x000050C4 File Offset: 0x000034C4 private static void Rotate2D(ref Vector4 direction, float cosinus, float sinus) { Vector4 vector = direction; direction.x = vector.x * cosinus - vector.y * sinus; direction.y = vector.x * sinus + vector.y * cosinus; } // Token: 0x06000079 RID: 121 RVA: 0x0000510C File Offset: 0x0000350C private static void SwapRenderTexture(ref RenderTexture src, ref RenderTexture dst) { RenderTexture renderTexture = dst; dst = src; src = renderTexture; } // Token: 0x0600007A RID: 122 RVA: 0x00005124 File Offset: 0x00003524 private static void GetDirectionalBlurPassesFromRadius(RenderTexture blurredFgCoc, float maxRadius, out int blurPass, out int blurAndMergePass) { if (blurredFgCoc == null) { if (maxRadius > 10f) { blurPass = 25; blurAndMergePass = 27; } else if (maxRadius > 5f) { blurPass = 21; blurAndMergePass = 23; } else { blurPass = 17; blurAndMergePass = 19; } } else if (maxRadius > 10f) { blurPass = 26; blurAndMergePass = 28; } else if (maxRadius > 5f) { blurPass = 22; blurAndMergePass = 24; } else { blurPass = 18; blurAndMergePass = 20; } } // Token: 0x04000072 RID: 114 private const float kMaxBlur = 35f; // Token: 0x04000073 RID: 115 [DepthOfField.TopLevelSettings] public DepthOfField.GlobalSettings settings = DepthOfField.GlobalSettings.defaultSettings; // Token: 0x04000074 RID: 116 [DepthOfField.SettingsGroup] [DepthOfField.AllTweakModes] public DepthOfField.QualitySettings quality = DepthOfField.QualitySettings.presetQualitySettings[3]; // Token: 0x04000075 RID: 117 [DepthOfField.SettingsGroup] public DepthOfField.FocusSettings focus = DepthOfField.FocusSettings.defaultSettings; // Token: 0x04000076 RID: 118 [DepthOfField.SettingsGroup] public DepthOfField.BokehTextureSettings bokehTexture = DepthOfField.BokehTextureSettings.defaultSettings; // Token: 0x04000077 RID: 119 [DepthOfField.SettingsGroup] public DepthOfField.BlurSettings blur = DepthOfField.BlurSettings.defaultSettings; // Token: 0x04000078 RID: 120 [SerializeField] private Shader m_FilmicDepthOfFieldShader; // Token: 0x04000079 RID: 121 [SerializeField] private Shader m_MedianFilterShader; // Token: 0x0400007A RID: 122 [SerializeField] private Shader m_TextureBokehShader; // Token: 0x0400007B RID: 123 private RenderTextureUtility m_RTU = new RenderTextureUtility(); // Token: 0x0400007C RID: 124 private Material m_FilmicDepthOfFieldMaterial; // Token: 0x0400007D RID: 125 private Material m_MedianFilterMaterial; // Token: 0x0400007E RID: 126 private Material m_TextureBokehMaterial; // Token: 0x0400007F RID: 127 private ComputeBuffer m_ComputeBufferDrawArgs; // Token: 0x04000080 RID: 128 private ComputeBuffer m_ComputeBufferPoints; // Token: 0x04000081 RID: 129 private DepthOfField.QualitySettings m_CurrentQualitySettings; // Token: 0x04000082 RID: 130 private float m_LastApertureOrientation; // Token: 0x04000083 RID: 131 private Vector4 m_OctogonalBokehDirection1; // Token: 0x04000084 RID: 132 private Vector4 m_OctogonalBokehDirection2; // Token: 0x04000085 RID: 133 private Vector4 m_OctogonalBokehDirection3; // Token: 0x04000086 RID: 134 private Vector4 m_OctogonalBokehDirection4; // Token: 0x04000087 RID: 135 private Vector4 m_HexagonalBokehDirection1; // Token: 0x04000088 RID: 136 private Vector4 m_HexagonalBokehDirection2; // Token: 0x04000089 RID: 137 private Vector4 m_HexagonalBokehDirection3; // Token: 0x02000020 RID: 32 private enum Passes { // Token: 0x0400008B RID: 139 BlurAlphaWeighted, // Token: 0x0400008C RID: 140 BoxBlur, // Token: 0x0400008D RID: 141 DilateFgCocFromColor, // Token: 0x0400008E RID: 142 DilateFgCoc, // Token: 0x0400008F RID: 143 CaptureCoc, // Token: 0x04000090 RID: 144 CaptureCocExplicit, // Token: 0x04000091 RID: 145 VisualizeCoc, // Token: 0x04000092 RID: 146 VisualizeCocExplicit, // Token: 0x04000093 RID: 147 CocPrefilter, // Token: 0x04000094 RID: 148 CircleBlur, // Token: 0x04000095 RID: 149 CircleBlurWithDilatedFg, // Token: 0x04000096 RID: 150 CircleBlurLowQuality, // Token: 0x04000097 RID: 151 CircleBlowLowQualityWithDilatedFg, // Token: 0x04000098 RID: 152 Merge, // Token: 0x04000099 RID: 153 MergeExplicit, // Token: 0x0400009A RID: 154 MergeBicubic, // Token: 0x0400009B RID: 155 MergeExplicitBicubic, // Token: 0x0400009C RID: 156 ShapeLowQuality, // Token: 0x0400009D RID: 157 ShapeLowQualityDilateFg, // Token: 0x0400009E RID: 158 ShapeLowQualityMerge, // Token: 0x0400009F RID: 159 ShapeLowQualityMergeDilateFg, // Token: 0x040000A0 RID: 160 ShapeMediumQuality, // Token: 0x040000A1 RID: 161 ShapeMediumQualityDilateFg, // Token: 0x040000A2 RID: 162 ShapeMediumQualityMerge, // Token: 0x040000A3 RID: 163 ShapeMediumQualityMergeDilateFg, // Token: 0x040000A4 RID: 164 ShapeHighQuality, // Token: 0x040000A5 RID: 165 ShapeHighQualityDilateFg, // Token: 0x040000A6 RID: 166 ShapeHighQualityMerge, // Token: 0x040000A7 RID: 167 ShapeHighQualityMergeDilateFg } // Token: 0x02000021 RID: 33 private enum MedianPasses { // Token: 0x040000A9 RID: 169 Median3, // Token: 0x040000AA RID: 170 Median3X3 } // Token: 0x02000022 RID: 34 private enum BokehTexturesPasses { // Token: 0x040000AC RID: 172 Apply, // Token: 0x040000AD RID: 173 Collect } // Token: 0x02000023 RID: 35 public enum TweakMode { // Token: 0x040000AF RID: 175 Basic, // Token: 0x040000B0 RID: 176 Advanced, // Token: 0x040000B1 RID: 177 Explicit } // Token: 0x02000024 RID: 36 public enum ApertureShape { // Token: 0x040000B3 RID: 179 Circular, // Token: 0x040000B4 RID: 180 Hexagonal, // Token: 0x040000B5 RID: 181 Octogonal } // Token: 0x02000025 RID: 37 public enum QualityPreset { // Token: 0x040000B7 RID: 183 Simple, // Token: 0x040000B8 RID: 184 Low, // Token: 0x040000B9 RID: 185 Medium, // Token: 0x040000BA RID: 186 High, // Token: 0x040000BB RID: 187 VeryHigh, // Token: 0x040000BC RID: 188 Ultra, // Token: 0x040000BD RID: 189 Custom } // Token: 0x02000026 RID: 38 public enum FilterQuality { // Token: 0x040000BF RID: 191 None, // Token: 0x040000C0 RID: 192 Normal, // Token: 0x040000C1 RID: 193 High } // Token: 0x02000027 RID: 39 [AttributeUsage(AttributeTargets.Field)] public class TopLevelSettings : Attribute { } // Token: 0x02000028 RID: 40 [AttributeUsage(AttributeTargets.Field)] public class SettingsGroup : Attribute { } // Token: 0x02000029 RID: 41 [AttributeUsage(AttributeTargets.Field)] public class AllTweakModes : Attribute { } // Token: 0x0200002A RID: 42 [AttributeUsage(AttributeTargets.Field)] public class Basic : Attribute { } // Token: 0x0200002B RID: 43 [AttributeUsage(AttributeTargets.Field)] public class Advanced : Attribute { } // Token: 0x0200002C RID: 44 [AttributeUsage(AttributeTargets.Field)] public class Explicit : Attribute { } // Token: 0x0200002D RID: 45 [Serializable] public struct GlobalSettings { // Token: 0x17000032 RID: 50 // (get) Token: 0x06000081 RID: 129 RVA: 0x000051E4 File Offset: 0x000035E4 public static DepthOfField.GlobalSettings defaultSettings { get { return new DepthOfField.GlobalSettings { visualizeBluriness = false, tweakMode = DepthOfField.TweakMode.Basic, quality = DepthOfField.QualityPreset.High, apertureShape = DepthOfField.ApertureShape.Circular, apertureOrientation = 0f }; } } // Token: 0x040000C2 RID: 194 [Tooltip("Allows to view where the blur will be applied. Yellow for near blur, blue for far blur.")] public bool visualizeBluriness; // Token: 0x040000C3 RID: 195 [Tooltip("Setup mode. Use \"Advanced\" if you need more control on blur settings and/or want to use a bokeh texture. \"Explicit\" is the same as \"Advanced\" but makes use of \"Near Plane\" and \"Far Plane\" values instead of \"F-Stop\".")] public DepthOfField.TweakMode tweakMode; // Token: 0x040000C4 RID: 196 [Tooltip("Quality presets. Use \"Custom\" for more advanced settings.")] public DepthOfField.QualityPreset quality; // Token: 0x040000C5 RID: 197 [Space] [Tooltip("\"Circular\" is the fastest, followed by \"Hexagonal\" and \"Octogonal\".")] public DepthOfField.ApertureShape apertureShape; // Token: 0x040000C6 RID: 198 [Range(0f, 179f)] [Tooltip("Rotates the aperture when working with \"Hexagonal\" and \"Ortogonal\".")] public float apertureOrientation; } // Token: 0x0200002E RID: 46 [Serializable] public struct QualitySettings { // Token: 0x040000C7 RID: 199 [Tooltip("Enable this to get smooth bokeh.")] public bool prefilterBlur; // Token: 0x040000C8 RID: 200 [Tooltip("Applies a median filter for even smoother bokeh.")] public DepthOfField.FilterQuality medianFilter; // Token: 0x040000C9 RID: 201 [Tooltip("Dilates near blur over in focus area.")] public bool dilateNearBlur; // Token: 0x040000CA RID: 202 [Tooltip("Uses high quality upsampling.")] public bool highQualityUpsampling; // Token: 0x040000CB RID: 203 [Tooltip("Prevent haloing from bright in focus region over dark out of focus region.")] public bool preventHaloing; // Token: 0x040000CC RID: 204 public static DepthOfField.QualitySettings[] presetQualitySettings = new DepthOfField.QualitySettings[] { new DepthOfField.QualitySettings { prefilterBlur = false, medianFilter = DepthOfField.FilterQuality.None, dilateNearBlur = false, highQualityUpsampling = false, preventHaloing = false }, new DepthOfField.QualitySettings { prefilterBlur = true, medianFilter = DepthOfField.FilterQuality.None, dilateNearBlur = false, highQualityUpsampling = false, preventHaloing = false }, new DepthOfField.QualitySettings { prefilterBlur = true, medianFilter = DepthOfField.FilterQuality.Normal, dilateNearBlur = false, highQualityUpsampling = false, preventHaloing = false }, new DepthOfField.QualitySettings { prefilterBlur = true, medianFilter = DepthOfField.FilterQuality.Normal, dilateNearBlur = true, highQualityUpsampling = false, preventHaloing = false }, new DepthOfField.QualitySettings { prefilterBlur = true, medianFilter = DepthOfField.FilterQuality.High, dilateNearBlur = true, highQualityUpsampling = false, preventHaloing = true }, new DepthOfField.QualitySettings { prefilterBlur = true, medianFilter = DepthOfField.FilterQuality.High, dilateNearBlur = true, highQualityUpsampling = true, preventHaloing = true } }; } // Token: 0x0200002F RID: 47 [Serializable] public struct FocusSettings { // Token: 0x17000033 RID: 51 // (get) Token: 0x06000083 RID: 131 RVA: 0x000053B0 File Offset: 0x000037B0 public static DepthOfField.FocusSettings defaultSettings { get { return new DepthOfField.FocusSettings { transform = null, plane = 0.225f, nearPlane = 0f, farPlane = 1f, fStops = 5f, rangeAdjustment = 0.9f }; } } // Token: 0x040000CD RID: 205 [DepthOfField.Basic] [DepthOfField.Advanced] [DepthOfField.Explicit] [Tooltip("Auto-focus on a selected transform.")] public Transform transform; // Token: 0x040000CE RID: 206 [DepthOfField.Basic] [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Focus distance.")] public float plane; // Token: 0x040000CF RID: 207 [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Near focus distance.")] public float nearPlane; // Token: 0x040000D0 RID: 208 [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Far focus distance.")] public float farPlane; // Token: 0x040000D1 RID: 209 [DepthOfField.Basic] [DepthOfField.Advanced] [Range(0f, 32f)] [Tooltip("Simulates focal ratio. Lower values will result in a narrow depth of field.")] public float fStops; // Token: 0x040000D2 RID: 210 [DepthOfField.Basic] [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Focus range/spread. Use this to fine-tune the F-Stop range.")] public float rangeAdjustment; } // Token: 0x02000030 RID: 48 [Serializable] public struct BokehTextureSettings { // Token: 0x17000034 RID: 52 // (get) Token: 0x06000084 RID: 132 RVA: 0x0000540C File Offset: 0x0000380C public static DepthOfField.BokehTextureSettings defaultSettings { get { return new DepthOfField.BokehTextureSettings { texture = null, scale = 1f, intensity = 50f, threshold = 2f, spawnHeuristic = 0.15f }; } } // Token: 0x040000D3 RID: 211 [DepthOfField.Advanced] [DepthOfField.Explicit] [Tooltip("Adding a texture to this field will enable the use of \"Bokeh Textures\". Use with care. This feature is only available on Shader Model 5 compatible-hardware and performance scale with the amount of bokeh.")] public Texture2D texture; // Token: 0x040000D4 RID: 212 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0.01f, 5f)] [Tooltip("Maximum size of bokeh textures on screen.")] public float scale; // Token: 0x040000D5 RID: 213 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0.01f, 100f)] [Tooltip("Bokeh brightness.")] public float intensity; // Token: 0x040000D6 RID: 214 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0.01f, 50f)] [Tooltip("Controls the amount of bokeh textures. Lower values mean more bokeh splats.")] public float threshold; // Token: 0x040000D7 RID: 215 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0.01f, 1f)] [Tooltip("Controls the spawn conditions. Lower values mean more visible bokeh.")] public float spawnHeuristic; } // Token: 0x02000031 RID: 49 [Serializable] public struct BlurSettings { // Token: 0x17000035 RID: 53 // (get) Token: 0x06000085 RID: 133 RVA: 0x0000545C File Offset: 0x0000385C public static DepthOfField.BlurSettings defaultSettings { get { return new DepthOfField.BlurSettings { nearRadius = 20f, farRadius = 20f, boostPoint = 0.75f, nearBoostAmount = 0f, farBoostAmount = 0f }; } } // Token: 0x040000D8 RID: 216 [DepthOfField.Basic] [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 35f)] [Tooltip("Maximum blur radius for the near plane.")] public float nearRadius; // Token: 0x040000D9 RID: 217 [DepthOfField.Basic] [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 35f)] [Tooltip("Maximum blur radius for the far plane.")] public float farRadius; // Token: 0x040000DA RID: 218 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0.5f, 4f)] [Tooltip("Blur luminosity booster threshold for the near and far boost amounts.")] public float boostPoint; // Token: 0x040000DB RID: 219 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Boosts luminosity in the near blur.")] public float nearBoostAmount; // Token: 0x040000DC RID: 220 [DepthOfField.Advanced] [DepthOfField.Explicit] [Range(0f, 1f)] [Tooltip("Boosts luminosity in the far blur.")] public float farBoostAmount; } } }