using System; using UnityEngine; namespace UnityStandardAssets.ImageEffects { // Token: 0x02000056 RID: 86 [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Image Effects/Bloom and Glow/BloomAndFlares (3.5, Deprecated)")] public class BloomAndFlares : PostEffectsBase { // Token: 0x060000D5 RID: 213 RVA: 0x00008D20 File Offset: 0x00007120 public override bool CheckResources() { base.CheckSupport(false); this.screenBlend = base.CheckShaderAndCreateMaterial(this.screenBlendShader, this.screenBlend); this.lensFlareMaterial = base.CheckShaderAndCreateMaterial(this.lensFlareShader, this.lensFlareMaterial); this.vignetteMaterial = base.CheckShaderAndCreateMaterial(this.vignetteShader, this.vignetteMaterial); this.separableBlurMaterial = base.CheckShaderAndCreateMaterial(this.separableBlurShader, this.separableBlurMaterial); this.addBrightStuffBlendOneOneMaterial = base.CheckShaderAndCreateMaterial(this.addBrightStuffOneOneShader, this.addBrightStuffBlendOneOneMaterial); this.hollywoodFlaresMaterial = base.CheckShaderAndCreateMaterial(this.hollywoodFlaresShader, this.hollywoodFlaresMaterial); this.brightPassFilterMaterial = base.CheckShaderAndCreateMaterial(this.brightPassFilterShader, this.brightPassFilterMaterial); if (!this.isSupported) { base.ReportAutoDisable(); } return this.isSupported; } // Token: 0x060000D6 RID: 214 RVA: 0x00008DF4 File Offset: 0x000071F4 private void OnRenderImage(RenderTexture source, RenderTexture destination) { if (!this.CheckResources()) { Graphics.Blit(source, destination); return; } this.doHdr = false; if (this.hdr == HDRBloomMode.Auto) { this.doHdr = source.format == RenderTextureFormat.ARGBHalf && base.GetComponent().allowHDR; } else { this.doHdr = this.hdr == HDRBloomMode.On; } this.doHdr = this.doHdr && this.supportHDRTextures; BloomScreenBlendMode bloomScreenBlendMode = this.screenBlendMode; if (this.doHdr) { bloomScreenBlendMode = BloomScreenBlendMode.Add; } RenderTextureFormat renderTextureFormat = ((!this.doHdr) ? RenderTextureFormat.Default : RenderTextureFormat.ARGBHalf); RenderTexture temporary = RenderTexture.GetTemporary(source.width / 2, source.height / 2, 0, renderTextureFormat); RenderTexture temporary2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, renderTextureFormat); RenderTexture temporary3 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, renderTextureFormat); RenderTexture temporary4 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, renderTextureFormat); float num = 1f * (float)source.width / (1f * (float)source.height); float num2 = 0.001953125f; Graphics.Blit(source, temporary, this.screenBlend, 2); Graphics.Blit(temporary, temporary2, this.screenBlend, 2); RenderTexture.ReleaseTemporary(temporary); this.BrightFilter(this.bloomThreshold, this.useSrcAlphaAsMask, temporary2, temporary3); temporary2.DiscardContents(); if (this.bloomBlurIterations < 1) { this.bloomBlurIterations = 1; } for (int i = 0; i < this.bloomBlurIterations; i++) { float num3 = (1f + (float)i * 0.5f) * this.sepBlurSpread; this.separableBlurMaterial.SetVector("offsets", new Vector4(0f, num3 * num2, 0f, 0f)); RenderTexture renderTexture = ((i != 0) ? temporary2 : temporary3); Graphics.Blit(renderTexture, temporary4, this.separableBlurMaterial); renderTexture.DiscardContents(); this.separableBlurMaterial.SetVector("offsets", new Vector4(num3 / num * num2, 0f, 0f, 0f)); Graphics.Blit(temporary4, temporary2, this.separableBlurMaterial); temporary4.DiscardContents(); } if (this.lensflares) { if (this.lensflareMode == LensflareStyle34.Ghosting) { this.BrightFilter(this.lensflareThreshold, 0f, temporary2, temporary4); temporary2.DiscardContents(); this.Vignette(0.975f, temporary4, temporary3); temporary4.DiscardContents(); this.BlendFlares(temporary3, temporary2); temporary3.DiscardContents(); } else { this.hollywoodFlaresMaterial.SetVector("_threshold", new Vector4(this.lensflareThreshold, 1f / (1f - this.lensflareThreshold), 0f, 0f)); this.hollywoodFlaresMaterial.SetVector("tintColor", new Vector4(this.flareColorA.r, this.flareColorA.g, this.flareColorA.b, this.flareColorA.a) * this.flareColorA.a * this.lensflareIntensity); Graphics.Blit(temporary4, temporary3, this.hollywoodFlaresMaterial, 2); temporary4.DiscardContents(); Graphics.Blit(temporary3, temporary4, this.hollywoodFlaresMaterial, 3); temporary3.DiscardContents(); this.hollywoodFlaresMaterial.SetVector("offsets", new Vector4(this.sepBlurSpread * 1f / num * num2, 0f, 0f, 0f)); this.hollywoodFlaresMaterial.SetFloat("stretchWidth", this.hollyStretchWidth); Graphics.Blit(temporary4, temporary3, this.hollywoodFlaresMaterial, 1); temporary4.DiscardContents(); this.hollywoodFlaresMaterial.SetFloat("stretchWidth", this.hollyStretchWidth * 2f); Graphics.Blit(temporary3, temporary4, this.hollywoodFlaresMaterial, 1); temporary3.DiscardContents(); this.hollywoodFlaresMaterial.SetFloat("stretchWidth", this.hollyStretchWidth * 4f); Graphics.Blit(temporary4, temporary3, this.hollywoodFlaresMaterial, 1); temporary4.DiscardContents(); if (this.lensflareMode == LensflareStyle34.Anamorphic) { for (int j = 0; j < this.hollywoodFlareBlurIterations; j++) { this.separableBlurMaterial.SetVector("offsets", new Vector4(this.hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f)); Graphics.Blit(temporary3, temporary4, this.separableBlurMaterial); temporary3.DiscardContents(); this.separableBlurMaterial.SetVector("offsets", new Vector4(this.hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f)); Graphics.Blit(temporary4, temporary3, this.separableBlurMaterial); temporary4.DiscardContents(); } this.AddTo(1f, temporary3, temporary2); temporary3.DiscardContents(); } else { for (int k = 0; k < this.hollywoodFlareBlurIterations; k++) { this.separableBlurMaterial.SetVector("offsets", new Vector4(this.hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f)); Graphics.Blit(temporary3, temporary4, this.separableBlurMaterial); temporary3.DiscardContents(); this.separableBlurMaterial.SetVector("offsets", new Vector4(this.hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f)); Graphics.Blit(temporary4, temporary3, this.separableBlurMaterial); temporary4.DiscardContents(); } this.Vignette(1f, temporary3, temporary4); temporary3.DiscardContents(); this.BlendFlares(temporary4, temporary3); temporary4.DiscardContents(); this.AddTo(1f, temporary3, temporary2); temporary3.DiscardContents(); } } } this.screenBlend.SetFloat("_Intensity", this.bloomIntensity); this.screenBlend.SetTexture("_ColorBuffer", source); Graphics.Blit(temporary2, destination, this.screenBlend, (int)bloomScreenBlendMode); RenderTexture.ReleaseTemporary(temporary2); RenderTexture.ReleaseTemporary(temporary3); RenderTexture.ReleaseTemporary(temporary4); } // Token: 0x060000D7 RID: 215 RVA: 0x0000942B File Offset: 0x0000782B private void AddTo(float intensity_, RenderTexture from, RenderTexture to) { this.addBrightStuffBlendOneOneMaterial.SetFloat("_Intensity", intensity_); Graphics.Blit(from, to, this.addBrightStuffBlendOneOneMaterial); } // Token: 0x060000D8 RID: 216 RVA: 0x0000944C File Offset: 0x0000784C private void BlendFlares(RenderTexture from, RenderTexture to) { this.lensFlareMaterial.SetVector("colorA", new Vector4(this.flareColorA.r, this.flareColorA.g, this.flareColorA.b, this.flareColorA.a) * this.lensflareIntensity); this.lensFlareMaterial.SetVector("colorB", new Vector4(this.flareColorB.r, this.flareColorB.g, this.flareColorB.b, this.flareColorB.a) * this.lensflareIntensity); this.lensFlareMaterial.SetVector("colorC", new Vector4(this.flareColorC.r, this.flareColorC.g, this.flareColorC.b, this.flareColorC.a) * this.lensflareIntensity); this.lensFlareMaterial.SetVector("colorD", new Vector4(this.flareColorD.r, this.flareColorD.g, this.flareColorD.b, this.flareColorD.a) * this.lensflareIntensity); Graphics.Blit(from, to, this.lensFlareMaterial); } // Token: 0x060000D9 RID: 217 RVA: 0x00009598 File Offset: 0x00007998 private void BrightFilter(float thresh, float useAlphaAsMask, RenderTexture from, RenderTexture to) { if (this.doHdr) { this.brightPassFilterMaterial.SetVector("threshold", new Vector4(thresh, 1f, 0f, 0f)); } else { this.brightPassFilterMaterial.SetVector("threshold", new Vector4(thresh, 1f / (1f - thresh), 0f, 0f)); } this.brightPassFilterMaterial.SetFloat("useSrcAlphaAsMask", useAlphaAsMask); Graphics.Blit(from, to, this.brightPassFilterMaterial); } // Token: 0x060000DA RID: 218 RVA: 0x00009628 File Offset: 0x00007A28 private void Vignette(float amount, RenderTexture from, RenderTexture to) { if (this.lensFlareVignetteMask) { this.screenBlend.SetTexture("_ColorBuffer", this.lensFlareVignetteMask); Graphics.Blit(from, to, this.screenBlend, 3); } else { this.vignetteMaterial.SetFloat("vignetteIntensity", amount); Graphics.Blit(from, to, this.vignetteMaterial); } } // Token: 0x040001B6 RID: 438 public TweakMode34 tweakMode; // Token: 0x040001B7 RID: 439 public BloomScreenBlendMode screenBlendMode = BloomScreenBlendMode.Add; // Token: 0x040001B8 RID: 440 public HDRBloomMode hdr; // Token: 0x040001B9 RID: 441 private bool doHdr; // Token: 0x040001BA RID: 442 public float sepBlurSpread = 1.5f; // Token: 0x040001BB RID: 443 public float useSrcAlphaAsMask = 0.5f; // Token: 0x040001BC RID: 444 public float bloomIntensity = 1f; // Token: 0x040001BD RID: 445 public float bloomThreshold = 0.5f; // Token: 0x040001BE RID: 446 public int bloomBlurIterations = 2; // Token: 0x040001BF RID: 447 public bool lensflares; // Token: 0x040001C0 RID: 448 public int hollywoodFlareBlurIterations = 2; // Token: 0x040001C1 RID: 449 public LensflareStyle34 lensflareMode = LensflareStyle34.Anamorphic; // Token: 0x040001C2 RID: 450 public float hollyStretchWidth = 3.5f; // Token: 0x040001C3 RID: 451 public float lensflareIntensity = 1f; // Token: 0x040001C4 RID: 452 public float lensflareThreshold = 0.3f; // Token: 0x040001C5 RID: 453 public Color flareColorA = new Color(0.4f, 0.4f, 0.8f, 0.75f); // Token: 0x040001C6 RID: 454 public Color flareColorB = new Color(0.4f, 0.8f, 0.8f, 0.75f); // Token: 0x040001C7 RID: 455 public Color flareColorC = new Color(0.8f, 0.4f, 0.8f, 0.75f); // Token: 0x040001C8 RID: 456 public Color flareColorD = new Color(0.8f, 0.4f, 0f, 0.75f); // Token: 0x040001C9 RID: 457 public Texture2D lensFlareVignetteMask; // Token: 0x040001CA RID: 458 public Shader lensFlareShader; // Token: 0x040001CB RID: 459 private Material lensFlareMaterial; // Token: 0x040001CC RID: 460 public Shader vignetteShader; // Token: 0x040001CD RID: 461 private Material vignetteMaterial; // Token: 0x040001CE RID: 462 public Shader separableBlurShader; // Token: 0x040001CF RID: 463 private Material separableBlurMaterial; // Token: 0x040001D0 RID: 464 public Shader addBrightStuffOneOneShader; // Token: 0x040001D1 RID: 465 private Material addBrightStuffBlendOneOneMaterial; // Token: 0x040001D2 RID: 466 public Shader screenBlendShader; // Token: 0x040001D3 RID: 467 private Material screenBlend; // Token: 0x040001D4 RID: 468 public Shader hollywoodFlaresShader; // Token: 0x040001D5 RID: 469 private Material hollywoodFlaresMaterial; // Token: 0x040001D6 RID: 470 public Shader brightPassFilterShader; // Token: 0x040001D7 RID: 471 private Material brightPassFilterMaterial; } }