using System; using UnityEngine; namespace UnityStandardAssets.CinematicEffects { // Token: 0x02000032 RID: 50 [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Image Effects/Cinematic/Lens Aberrations")] public class LensAberrations : MonoBehaviour { // Token: 0x17000036 RID: 54 // (get) Token: 0x06000087 RID: 135 RVA: 0x000054D7 File Offset: 0x000038D7 public Shader shader { get { if (this.m_Shader == null) { this.m_Shader = Shader.Find("Hidden/LensAberrations"); } return this.m_Shader; } } // Token: 0x17000037 RID: 55 // (get) Token: 0x06000088 RID: 136 RVA: 0x00005500 File Offset: 0x00003900 public Material material { get { if (this.m_Material == null) { this.m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(this.shader); } return this.m_Material; } } // Token: 0x06000089 RID: 137 RVA: 0x0000552A File Offset: 0x0000392A private void OnEnable() { if (!ImageEffectHelper.IsSupported(this.shader, false, false, this)) { base.enabled = false; } this.m_RTU = new RenderTextureUtility(); } // Token: 0x0600008A RID: 138 RVA: 0x00005551 File Offset: 0x00003951 private void OnDisable() { if (this.m_Material != null) { global::UnityEngine.Object.DestroyImmediate(this.m_Material); } this.m_Material = null; this.m_RTU.ReleaseAllTemporaryRenderTextures(); } // Token: 0x0600008B RID: 139 RVA: 0x00005584 File Offset: 0x00003984 private void OnRenderImage(RenderTexture source, RenderTexture destination) { if (!this.vignette.enabled && !this.chromaticAberration.enabled && !this.distortion.enabled) { Graphics.Blit(source, destination); return; } this.material.shaderKeywords = null; if (this.distortion.enabled) { float num = 1.6f * Math.Max(Mathf.Abs(this.distortion.amount), 1f); float num2 = 0.017453292f * Math.Min(160f, num); float num3 = 2f * Mathf.Tan(num2 * 0.5f); Vector4 vector = new Vector4(this.distortion.centerX, this.distortion.centerY, Mathf.Max(this.distortion.amountX, 0.0001f), Mathf.Max(this.distortion.amountY, 0.0001f)); Vector3 vector2 = new Vector3((this.distortion.amount < 0f) ? (1f / num2) : num2, num3, 1f / this.distortion.scale); this.material.EnableKeyword((this.distortion.amount < 0f) ? "UNDISTORT" : "DISTORT"); this.material.SetVector("_DistCenterScale", vector); this.material.SetVector("_DistAmount", vector2); } if (this.chromaticAberration.enabled) { this.material.EnableKeyword("CHROMATIC_ABERRATION"); Vector4 vector3 = new Vector4(this.chromaticAberration.color.r, this.chromaticAberration.color.g, this.chromaticAberration.color.b, this.chromaticAberration.amount * 0.001f); this.material.SetVector("_ChromaticAberration", vector3); } if (this.vignette.enabled) { this.material.SetColor("_VignetteColor", this.vignette.color); if (this.vignette.blur > 0f) { int num4 = source.width / 2; int num5 = source.height / 2; RenderTexture temporaryRenderTexture = this.m_RTU.GetTemporaryRenderTexture(num4, num5, 0, source.format, FilterMode.Bilinear); RenderTexture temporaryRenderTexture2 = this.m_RTU.GetTemporaryRenderTexture(num4, num5, 0, source.format, FilterMode.Bilinear); this.material.SetVector("_BlurPass", new Vector2(1f / (float)num4, 0f)); Graphics.Blit(source, temporaryRenderTexture, this.material, 0); if (this.distortion.enabled) { this.material.DisableKeyword("DISTORT"); this.material.DisableKeyword("UNDISTORT"); } this.material.SetVector("_BlurPass", new Vector2(0f, 1f / (float)num5)); Graphics.Blit(temporaryRenderTexture, temporaryRenderTexture2, this.material, 0); this.material.SetVector("_BlurPass", new Vector2(1f / (float)num4, 0f)); Graphics.Blit(temporaryRenderTexture2, temporaryRenderTexture, this.material, 0); this.material.SetVector("_BlurPass", new Vector2(0f, 1f / (float)num5)); Graphics.Blit(temporaryRenderTexture, temporaryRenderTexture2, this.material, 0); this.material.SetTexture("_BlurTex", temporaryRenderTexture2); this.material.SetFloat("_VignetteBlur", this.vignette.blur * 3f); this.material.EnableKeyword("VIGNETTE_BLUR"); if (this.distortion.enabled) { this.material.EnableKeyword((this.distortion.amount < 0f) ? "UNDISTORT" : "DISTORT"); } } if (this.vignette.desaturate > 0f) { this.material.EnableKeyword("VIGNETTE_DESAT"); this.material.SetFloat("_VignetteDesat", 1f - this.vignette.desaturate); } this.material.SetVector("_VignetteCenter", this.vignette.center); if (Mathf.Approximately(this.vignette.roundness, 1f)) { this.material.EnableKeyword("VIGNETTE_CLASSIC"); this.material.SetVector("_VignetteSettings", new Vector2(this.vignette.intensity, this.vignette.smoothness)); } else { this.material.EnableKeyword("VIGNETTE_FILMIC"); float num6 = (1f - this.vignette.roundness) * 6f + this.vignette.roundness; this.material.SetVector("_VignetteSettings", new Vector3(this.vignette.intensity, this.vignette.smoothness, num6)); } } int num7 = 0; if (this.vignette.enabled && this.chromaticAberration.enabled && this.distortion.enabled) { num7 = 7; } else if (this.vignette.enabled && this.chromaticAberration.enabled) { num7 = 5; } else if (this.vignette.enabled && this.distortion.enabled) { num7 = 6; } else if (this.chromaticAberration.enabled && this.distortion.enabled) { num7 = 4; } else if (this.vignette.enabled) { num7 = 3; } else if (this.chromaticAberration.enabled) { num7 = 1; } else if (this.distortion.enabled) { num7 = 2; } Graphics.Blit(source, destination, this.material, num7); this.m_RTU.ReleaseAllTemporaryRenderTextures(); } // Token: 0x040000DD RID: 221 [LensAberrations.SettingsGroup] public LensAberrations.DistortionSettings distortion = LensAberrations.DistortionSettings.defaultSettings; // Token: 0x040000DE RID: 222 [LensAberrations.SettingsGroup] public LensAberrations.VignetteSettings vignette = LensAberrations.VignetteSettings.defaultSettings; // Token: 0x040000DF RID: 223 [LensAberrations.SettingsGroup] public LensAberrations.ChromaticAberrationSettings chromaticAberration = LensAberrations.ChromaticAberrationSettings.defaultSettings; // Token: 0x040000E0 RID: 224 [SerializeField] private Shader m_Shader; // Token: 0x040000E1 RID: 225 private Material m_Material; // Token: 0x040000E2 RID: 226 private RenderTextureUtility m_RTU; // Token: 0x02000033 RID: 51 [AttributeUsage(AttributeTargets.Field)] public class SettingsGroup : Attribute { } // Token: 0x02000034 RID: 52 [AttributeUsage(AttributeTargets.Field)] public class AdvancedSetting : Attribute { } // Token: 0x02000035 RID: 53 [Serializable] public struct DistortionSettings { // Token: 0x17000038 RID: 56 // (get) Token: 0x0600008E RID: 142 RVA: 0x00005BE4 File Offset: 0x00003FE4 public static LensAberrations.DistortionSettings defaultSettings { get { return new LensAberrations.DistortionSettings { enabled = false, amount = 0f, centerX = 0f, centerY = 0f, amountX = 1f, amountY = 1f, scale = 1f }; } } // Token: 0x040000E3 RID: 227 public bool enabled; // Token: 0x040000E4 RID: 228 [Range(-100f, 100f)] [Tooltip("Distortion amount.")] public float amount; // Token: 0x040000E5 RID: 229 [Range(-1f, 1f)] [Tooltip("Distortion center point (X axis).")] public float centerX; // Token: 0x040000E6 RID: 230 [Range(-1f, 1f)] [Tooltip("Distortion center point (Y axis).")] public float centerY; // Token: 0x040000E7 RID: 231 [Range(0f, 1f)] [Tooltip("Amount multiplier on X axis. Set it to 0 to disable distortion on this axis.")] public float amountX; // Token: 0x040000E8 RID: 232 [Range(0f, 1f)] [Tooltip("Amount multiplier on Y axis. Set it to 0 to disable distortion on this axis.")] public float amountY; // Token: 0x040000E9 RID: 233 [Range(0.01f, 5f)] [Tooltip("Global screen scaling.")] public float scale; } // Token: 0x02000036 RID: 54 [Serializable] public struct VignetteSettings { // Token: 0x17000039 RID: 57 // (get) Token: 0x0600008F RID: 143 RVA: 0x00005C4C File Offset: 0x0000404C public static LensAberrations.VignetteSettings defaultSettings { get { return new LensAberrations.VignetteSettings { enabled = false, color = new Color(0f, 0f, 0f, 1f), center = new Vector2(0.5f, 0.5f), intensity = 1.4f, smoothness = 0.8f, roundness = 1f, blur = 0f, desaturate = 0f }; } } // Token: 0x040000EA RID: 234 public bool enabled; // Token: 0x040000EB RID: 235 [ColorUsage(false)] [Tooltip("Vignette color. Use the alpha channel for transparency.")] public Color color; // Token: 0x040000EC RID: 236 [Tooltip("Sets the vignette center point (screen center is [0.5,0.5]).")] public Vector2 center; // Token: 0x040000ED RID: 237 [Range(0f, 3f)] [Tooltip("Amount of vignetting on screen.")] public float intensity; // Token: 0x040000EE RID: 238 [Range(0.01f, 3f)] [Tooltip("Smoothness of the vignette borders.")] public float smoothness; // Token: 0x040000EF RID: 239 [LensAberrations.AdvancedSetting] [Range(0f, 1f)] [Tooltip("Lower values will make a square-ish vignette.")] public float roundness; // Token: 0x040000F0 RID: 240 [Range(0f, 1f)] [Tooltip("Blurs the corners of the screen. Leave this at 0 to disable it.")] public float blur; // Token: 0x040000F1 RID: 241 [Range(0f, 1f)] [Tooltip("Desaturate the corners of the screen. Leave this to 0 to disable it.")] public float desaturate; } // Token: 0x02000037 RID: 55 [Serializable] public struct ChromaticAberrationSettings { // Token: 0x1700003A RID: 58 // (get) Token: 0x06000090 RID: 144 RVA: 0x00005CDC File Offset: 0x000040DC public static LensAberrations.ChromaticAberrationSettings defaultSettings { get { return new LensAberrations.ChromaticAberrationSettings { enabled = false, color = Color.green, amount = 0f }; } } // Token: 0x040000F2 RID: 242 public bool enabled; // Token: 0x040000F3 RID: 243 [ColorUsage(false)] [Tooltip("Channels to apply chromatic aberration to.")] public Color color; // Token: 0x040000F4 RID: 244 [Range(-50f, 50f)] [Tooltip("Amount of tangential distortion.")] public float amount; } // Token: 0x02000038 RID: 56 private enum Pass { // Token: 0x040000F6 RID: 246 BlurPrePass, // Token: 0x040000F7 RID: 247 Chroma, // Token: 0x040000F8 RID: 248 Distort, // Token: 0x040000F9 RID: 249 Vignette, // Token: 0x040000FA RID: 250 ChromaDistort, // Token: 0x040000FB RID: 251 ChromaVignette, // Token: 0x040000FC RID: 252 DistortVignette, // Token: 0x040000FD RID: 253 ChromaDistortVignette } } }