56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x02000075 RID: 117
|
|
[ExecuteInEditMode]
|
|
[AddComponentMenu("Image Effects/Blur/Motion Blur (Color Accumulation)")]
|
|
[RequireComponent(typeof(Camera))]
|
|
public class MotionBlur : ImageEffectBase
|
|
{
|
|
// Token: 0x0600014A RID: 330 RVA: 0x0000E889 File Offset: 0x0000CC89
|
|
protected override void OnDisable()
|
|
{
|
|
base.OnDisable();
|
|
global::UnityEngine.Object.DestroyImmediate(this.accumTexture);
|
|
}
|
|
|
|
// Token: 0x0600014B RID: 331 RVA: 0x0000E89C File Offset: 0x0000CC9C
|
|
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (this.accumTexture == null || this.accumTexture.width != source.width || this.accumTexture.height != source.height)
|
|
{
|
|
global::UnityEngine.Object.DestroyImmediate(this.accumTexture);
|
|
this.accumTexture = new RenderTexture(source.width, source.height, 0);
|
|
this.accumTexture.hideFlags = HideFlags.HideAndDontSave;
|
|
Graphics.Blit(source, this.accumTexture);
|
|
}
|
|
if (this.extraBlur)
|
|
{
|
|
RenderTexture temporary = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
|
|
this.accumTexture.MarkRestoreExpected();
|
|
Graphics.Blit(this.accumTexture, temporary);
|
|
Graphics.Blit(temporary, this.accumTexture);
|
|
RenderTexture.ReleaseTemporary(temporary);
|
|
}
|
|
this.blurAmount = Mathf.Clamp(this.blurAmount, 0f, 0.92f);
|
|
base.material.SetTexture("_MainTex", this.accumTexture);
|
|
base.material.SetFloat("_AccumOrig", 1f - this.blurAmount);
|
|
this.accumTexture.MarkRestoreExpected();
|
|
Graphics.Blit(source, this.accumTexture, base.material);
|
|
Graphics.Blit(this.accumTexture, destination);
|
|
}
|
|
|
|
// Token: 0x040002D2 RID: 722
|
|
[Range(0f, 0.92f)]
|
|
public float blurAmount = 0.8f;
|
|
|
|
// Token: 0x040002D3 RID: 723
|
|
public bool extraBlur;
|
|
|
|
// Token: 0x040002D4 RID: 724
|
|
private RenderTexture accumTexture;
|
|
}
|
|
}
|