public Bloom() { this.screenBlendMode = Bloom.BloomScreenBlendMode.Add; this.hdr = Bloom.HDRBloomMode.Auto; this.sepBlurSpread = 2.5f; this.quality = Bloom.BloomQuality.High; this.bloomIntensity = 0.5f; this.bloomThreshhold = 0.5f; this.bloomThreshholdColor = Color.white; this.bloomBlurIterations = 2; this.hollywoodFlareBlurIterations = 2; this.lensflareMode = Bloom.LensFlareStyle.Anamorphic; this.hollyStretchWidth = 2.5f; this.lensflareThreshhold = 0.3f; this.lensFlareSaturation = 0.75f; this.flareColorA = new Color(0.4f, 0.4f, 0.8f, 0.75f); this.flareColorB = new Color(0.4f, 0.8f, 0.8f, 0.75f); this.flareColorC = new Color(0.8f, 0.4f, 0.8f, 0.75f); this.flareColorD = new Color(0.8f, 0.4f, (float)0, 0.75f); this.blurWidth = 1f; }
// Token: 0x0600026E RID: 622 RVA: 0x0001E7BC File Offset: 0x0001C9BC public virtual void OnRenderImage(RenderTexture source, RenderTexture destination) { if (!this.CheckResources()) { Graphics.Blit(source, destination); } else { this.doHdr = false; if (this.hdr == Bloom.HDRBloomMode.Auto) { bool flag; if (flag = (source.format == RenderTextureFormat.ARGBHalf)) { flag = this.GetComponent <Camera>().allowHDR; } this.doHdr = flag; } else { this.doHdr = (this.hdr == Bloom.HDRBloomMode.On); } bool supportHDRTextures; if (supportHDRTextures = this.doHdr) { supportHDRTextures = this.supportHDRTextures; } this.doHdr = supportHDRTextures; Bloom.BloomScreenBlendMode bloomScreenBlendMode = this.screenBlendMode; if (this.doHdr) { bloomScreenBlendMode = Bloom.BloomScreenBlendMode.Add; } RenderTextureFormat format = (!this.doHdr) ? RenderTextureFormat.Default : RenderTextureFormat.ARGBHalf; int width = source.width / 2; int height = source.height / 2; int width2 = source.width / 4; int height2 = source.height / 4; float num = 1f * (float)source.width / (1f * (float)source.height); float num2 = 0.001953125f; RenderTexture temporary = RenderTexture.GetTemporary(width2, height2, 0, format); RenderTexture temporary2 = RenderTexture.GetTemporary(width, height, 0, format); if (this.quality > Bloom.BloomQuality.Cheap) { Graphics.Blit(source, temporary2, this.screenBlend, 2); RenderTexture temporary3 = RenderTexture.GetTemporary(width2, height2, 0, format); Graphics.Blit(temporary2, temporary3, this.screenBlend, 2); Graphics.Blit(temporary3, temporary, this.screenBlend, 6); RenderTexture.ReleaseTemporary(temporary3); } else { Graphics.Blit(source, temporary2); Graphics.Blit(temporary2, temporary, this.screenBlend, 6); } RenderTexture.ReleaseTemporary(temporary2); RenderTexture renderTexture = RenderTexture.GetTemporary(width2, height2, 0, format); this.BrightFilter(this.bloomThreshhold * this.bloomThreshholdColor, temporary, renderTexture); if (this.bloomBlurIterations < 1) { this.bloomBlurIterations = 1; } else if (this.bloomBlurIterations > 10) { this.bloomBlurIterations = 10; } for (int i = 0; i < this.bloomBlurIterations; i++) { float num3 = (1f + (float)i * 0.25f) * this.sepBlurSpread; RenderTexture temporary4 = RenderTexture.GetTemporary(width2, height2, 0, format); this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4((float)0, num3 * num2, (float)0, (float)0)); Graphics.Blit(renderTexture, temporary4, this.blurAndFlaresMaterial, 4); RenderTexture.ReleaseTemporary(renderTexture); renderTexture = temporary4; temporary4 = RenderTexture.GetTemporary(width2, height2, 0, format); this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num3 / num * num2, (float)0, (float)0, (float)0)); Graphics.Blit(renderTexture, temporary4, this.blurAndFlaresMaterial, 4); RenderTexture.ReleaseTemporary(renderTexture); renderTexture = temporary4; if (this.quality > Bloom.BloomQuality.Cheap) { if (i == 0) { Graphics.SetRenderTarget(temporary); GL.Clear(false, true, Color.black); Graphics.Blit(renderTexture, temporary); } else { temporary.MarkRestoreExpected(); Graphics.Blit(renderTexture, temporary, this.screenBlend, 10); } } } if (this.quality > Bloom.BloomQuality.Cheap) { Graphics.SetRenderTarget(renderTexture); GL.Clear(false, true, Color.black); Graphics.Blit(temporary, renderTexture, this.screenBlend, 6); } if (this.lensflareIntensity > Mathf.Epsilon) { RenderTexture temporary5 = RenderTexture.GetTemporary(width2, height2, 0, format); if (this.lensflareMode == Bloom.LensFlareStyle.Ghosting) { this.BrightFilter(this.lensflareThreshhold, renderTexture, temporary5); if (this.quality > Bloom.BloomQuality.Cheap) { this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4((float)0, 1.5f / (1f * (float)temporary.height), (float)0, (float)0)); Graphics.SetRenderTarget(temporary); GL.Clear(false, true, Color.black); Graphics.Blit(temporary5, temporary, this.blurAndFlaresMaterial, 4); this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(1.5f / (1f * (float)temporary.width), (float)0, (float)0, (float)0)); Graphics.SetRenderTarget(temporary5); GL.Clear(false, true, Color.black); Graphics.Blit(temporary, temporary5, this.blurAndFlaresMaterial, 4); } this.Vignette(0.975f, temporary5, temporary5); this.BlendFlares(temporary5, renderTexture); } else { float num4 = 1f * Mathf.Cos(this.flareRotation); float num5 = 1f * Mathf.Sin(this.flareRotation); float num6 = this.hollyStretchWidth * 1f / num * num2; float num7 = this.hollyStretchWidth * num2; this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num4, num5, (float)0, (float)0)); this.blurAndFlaresMaterial.SetVector("_Threshhold", new Vector4(this.lensflareThreshhold, 1f, (float)0, (float)0)); this.blurAndFlaresMaterial.SetVector("_TintColor", new Vector4(this.flareColorA.r, this.flareColorA.g, this.flareColorA.b, this.flareColorA.a) * this.flareColorA.a * this.lensflareIntensity); this.blurAndFlaresMaterial.SetFloat("_Saturation", this.lensFlareSaturation); temporary.DiscardContents(); Graphics.Blit(temporary5, temporary, this.blurAndFlaresMaterial, 2); temporary5.DiscardContents(); Graphics.Blit(temporary, temporary5, this.blurAndFlaresMaterial, 3); this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num4 * num6, num5 * num6, (float)0, (float)0)); this.blurAndFlaresMaterial.SetFloat("_StretchWidth", this.hollyStretchWidth); temporary.DiscardContents(); Graphics.Blit(temporary5, temporary, this.blurAndFlaresMaterial, 1); this.blurAndFlaresMaterial.SetFloat("_StretchWidth", this.hollyStretchWidth * 2f); temporary5.DiscardContents(); Graphics.Blit(temporary, temporary5, this.blurAndFlaresMaterial, 1); this.blurAndFlaresMaterial.SetFloat("_StretchWidth", this.hollyStretchWidth * 4f); temporary.DiscardContents(); Graphics.Blit(temporary5, temporary, this.blurAndFlaresMaterial, 1); for (int i = 0; i < this.hollywoodFlareBlurIterations; i++) { num6 = this.hollyStretchWidth * 2f / num * num2; this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num6 * num4, num6 * num5, (float)0, (float)0)); temporary5.DiscardContents(); Graphics.Blit(temporary, temporary5, this.blurAndFlaresMaterial, 4); this.blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num6 * num4, num6 * num5, (float)0, (float)0)); temporary.DiscardContents(); Graphics.Blit(temporary5, temporary, this.blurAndFlaresMaterial, 4); } if (this.lensflareMode == Bloom.LensFlareStyle.Anamorphic) { this.AddTo(1f, temporary, renderTexture); } else { this.Vignette(1f, temporary, temporary5); this.BlendFlares(temporary5, temporary); this.AddTo(1f, temporary, renderTexture); } } RenderTexture.ReleaseTemporary(temporary5); } int pass = (int)bloomScreenBlendMode; this.screenBlend.SetFloat("_Intensity", this.bloomIntensity); this.screenBlend.SetTexture("_ColorBuffer", source); if (this.quality > Bloom.BloomQuality.Cheap) { RenderTexture temporary6 = RenderTexture.GetTemporary(width, height, 0, format); Graphics.Blit(renderTexture, temporary6); Graphics.Blit(temporary6, destination, this.screenBlend, pass); RenderTexture.ReleaseTemporary(temporary6); } else { Graphics.Blit(renderTexture, destination, this.screenBlend, pass); } RenderTexture.ReleaseTemporary(temporary); RenderTexture.ReleaseTemporary(renderTexture); } }