100 lines
3.1 KiB
C#
100 lines
3.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x0200005B RID: 91
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(Camera))]
|
|
[AddComponentMenu("Image Effects/Blur/Blur (Optimized)")]
|
|
public class BlurOptimized : PostEffectsBase
|
|
{
|
|
// Token: 0x060000E8 RID: 232 RVA: 0x00009B0C File Offset: 0x00007F0C
|
|
public override bool CheckResources()
|
|
{
|
|
base.CheckSupport(false);
|
|
this.blurMaterial = base.CheckShaderAndCreateMaterial(this.blurShader, this.blurMaterial);
|
|
if (!this.isSupported)
|
|
{
|
|
base.ReportAutoDisable();
|
|
}
|
|
return this.isSupported;
|
|
}
|
|
|
|
// Token: 0x060000E9 RID: 233 RVA: 0x00009B45 File Offset: 0x00007F45
|
|
public void OnDisable()
|
|
{
|
|
if (this.blurMaterial)
|
|
{
|
|
global::UnityEngine.Object.DestroyImmediate(this.blurMaterial);
|
|
}
|
|
}
|
|
|
|
// Token: 0x060000EA RID: 234 RVA: 0x00009B64 File Offset: 0x00007F64
|
|
public void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (!this.CheckResources())
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
return;
|
|
}
|
|
float num = 1f / (1f * (float)(1 << this.downsample));
|
|
this.blurMaterial.SetVector("_Parameter", new Vector4(this.blurSize * num, -this.blurSize * num, 0f, 0f));
|
|
source.filterMode = FilterMode.Bilinear;
|
|
int num2 = source.width >> this.downsample;
|
|
int num3 = source.height >> this.downsample;
|
|
RenderTexture renderTexture = RenderTexture.GetTemporary(num2, num3, 0, source.format);
|
|
renderTexture.filterMode = FilterMode.Bilinear;
|
|
Graphics.Blit(source, renderTexture, this.blurMaterial, 0);
|
|
int num4 = ((this.blurType != BlurOptimized.BlurType.StandardGauss) ? 2 : 0);
|
|
for (int i = 0; i < this.blurIterations; i++)
|
|
{
|
|
float num5 = (float)i * 1f;
|
|
this.blurMaterial.SetVector("_Parameter", new Vector4(this.blurSize * num + num5, -this.blurSize * num - num5, 0f, 0f));
|
|
RenderTexture renderTexture2 = RenderTexture.GetTemporary(num2, num3, 0, source.format);
|
|
renderTexture2.filterMode = FilterMode.Bilinear;
|
|
Graphics.Blit(renderTexture, renderTexture2, this.blurMaterial, 1 + num4);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
renderTexture = renderTexture2;
|
|
renderTexture2 = RenderTexture.GetTemporary(num2, num3, 0, source.format);
|
|
renderTexture2.filterMode = FilterMode.Bilinear;
|
|
Graphics.Blit(renderTexture, renderTexture2, this.blurMaterial, 2 + num4);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
renderTexture = renderTexture2;
|
|
}
|
|
Graphics.Blit(renderTexture, destination);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
}
|
|
|
|
// Token: 0x040001EA RID: 490
|
|
[Range(0f, 2f)]
|
|
public int downsample = 1;
|
|
|
|
// Token: 0x040001EB RID: 491
|
|
[Range(0f, 10f)]
|
|
public float blurSize = 3f;
|
|
|
|
// Token: 0x040001EC RID: 492
|
|
[Range(1f, 4f)]
|
|
public int blurIterations = 2;
|
|
|
|
// Token: 0x040001ED RID: 493
|
|
public BlurOptimized.BlurType blurType;
|
|
|
|
// Token: 0x040001EE RID: 494
|
|
public Shader blurShader;
|
|
|
|
// Token: 0x040001EF RID: 495
|
|
private Material blurMaterial;
|
|
|
|
// Token: 0x0200005C RID: 92
|
|
public enum BlurType
|
|
{
|
|
// Token: 0x040001F1 RID: 497
|
|
StandardGauss,
|
|
// Token: 0x040001F2 RID: 498
|
|
SgxGauss
|
|
}
|
|
}
|
|
}
|