99 lines
2.7 KiB
C#
99 lines
2.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x0200008E RID: 142
|
|
[RequireComponent(typeof(Camera))]
|
|
[AddComponentMenu("Image Effects/Camera/Tilt Shift (Lens Blur)")]
|
|
internal class TiltShift : PostEffectsBase
|
|
{
|
|
// Token: 0x06000196 RID: 406 RVA: 0x00012249 File Offset: 0x00010649
|
|
public override bool CheckResources()
|
|
{
|
|
base.CheckSupport(true);
|
|
this.tiltShiftMaterial = base.CheckShaderAndCreateMaterial(this.tiltShiftShader, this.tiltShiftMaterial);
|
|
if (!this.isSupported)
|
|
{
|
|
base.ReportAutoDisable();
|
|
}
|
|
return this.isSupported;
|
|
}
|
|
|
|
// Token: 0x06000197 RID: 407 RVA: 0x00012284 File Offset: 0x00010684
|
|
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (!this.CheckResources())
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
return;
|
|
}
|
|
this.tiltShiftMaterial.SetFloat("_BlurSize", (this.maxBlurSize >= 0f) ? this.maxBlurSize : 0f);
|
|
this.tiltShiftMaterial.SetFloat("_BlurArea", this.blurArea);
|
|
source.filterMode = FilterMode.Bilinear;
|
|
RenderTexture renderTexture = destination;
|
|
if ((float)this.downsample > 0f)
|
|
{
|
|
renderTexture = RenderTexture.GetTemporary(source.width >> this.downsample, source.height >> this.downsample, 0, source.format);
|
|
renderTexture.filterMode = FilterMode.Bilinear;
|
|
}
|
|
int num = (int)this.quality;
|
|
num *= 2;
|
|
Graphics.Blit(source, renderTexture, this.tiltShiftMaterial, (this.mode != TiltShift.TiltShiftMode.TiltShiftMode) ? (num + 1) : num);
|
|
if (this.downsample > 0)
|
|
{
|
|
this.tiltShiftMaterial.SetTexture("_Blurred", renderTexture);
|
|
Graphics.Blit(source, destination, this.tiltShiftMaterial, 6);
|
|
}
|
|
if (renderTexture != destination)
|
|
{
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
}
|
|
}
|
|
|
|
// Token: 0x0400038E RID: 910
|
|
public TiltShift.TiltShiftMode mode;
|
|
|
|
// Token: 0x0400038F RID: 911
|
|
public TiltShift.TiltShiftQuality quality = TiltShift.TiltShiftQuality.Normal;
|
|
|
|
// Token: 0x04000390 RID: 912
|
|
[Range(0f, 15f)]
|
|
public float blurArea = 1f;
|
|
|
|
// Token: 0x04000391 RID: 913
|
|
[Range(0f, 25f)]
|
|
public float maxBlurSize = 5f;
|
|
|
|
// Token: 0x04000392 RID: 914
|
|
[Range(0f, 1f)]
|
|
public int downsample;
|
|
|
|
// Token: 0x04000393 RID: 915
|
|
public Shader tiltShiftShader;
|
|
|
|
// Token: 0x04000394 RID: 916
|
|
private Material tiltShiftMaterial;
|
|
|
|
// Token: 0x0200008F RID: 143
|
|
public enum TiltShiftMode
|
|
{
|
|
// Token: 0x04000396 RID: 918
|
|
TiltShiftMode,
|
|
// Token: 0x04000397 RID: 919
|
|
IrisMode
|
|
}
|
|
|
|
// Token: 0x02000090 RID: 144
|
|
public enum TiltShiftQuality
|
|
{
|
|
// Token: 0x04000399 RID: 921
|
|
Preview,
|
|
// Token: 0x0400039A RID: 922
|
|
Normal,
|
|
// Token: 0x0400039B RID: 923
|
|
High
|
|
}
|
|
}
|
|
}
|