273 lines
6.8 KiB
C#
273 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x02000078 RID: 120
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(Camera))]
|
|
public class PostEffectsBase : MonoBehaviour
|
|
{
|
|
// Token: 0x0600015B RID: 347 RVA: 0x000076D0 File Offset: 0x00005AD0
|
|
protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
|
|
{
|
|
if (!s)
|
|
{
|
|
Debug.Log("Missing shader in " + this.ToString());
|
|
base.enabled = false;
|
|
return null;
|
|
}
|
|
if (s.isSupported && m2Create && m2Create.shader == s)
|
|
{
|
|
return m2Create;
|
|
}
|
|
if (!s.isSupported)
|
|
{
|
|
this.NotSupported();
|
|
Debug.Log(string.Concat(new string[]
|
|
{
|
|
"The shader ",
|
|
s.ToString(),
|
|
" on effect ",
|
|
this.ToString(),
|
|
" is not supported on this platform!"
|
|
}));
|
|
return null;
|
|
}
|
|
m2Create = new Material(s);
|
|
this.createdMaterials.Add(m2Create);
|
|
m2Create.hideFlags = HideFlags.DontSave;
|
|
return m2Create;
|
|
}
|
|
|
|
// Token: 0x0600015C RID: 348 RVA: 0x0000779C File Offset: 0x00005B9C
|
|
protected Material CreateMaterial(Shader s, Material m2Create)
|
|
{
|
|
if (!s)
|
|
{
|
|
Debug.Log("Missing shader in " + this.ToString());
|
|
return null;
|
|
}
|
|
if (m2Create && m2Create.shader == s && s.isSupported)
|
|
{
|
|
return m2Create;
|
|
}
|
|
if (!s.isSupported)
|
|
{
|
|
return null;
|
|
}
|
|
m2Create = new Material(s);
|
|
this.createdMaterials.Add(m2Create);
|
|
m2Create.hideFlags = HideFlags.DontSave;
|
|
return m2Create;
|
|
}
|
|
|
|
// Token: 0x0600015D RID: 349 RVA: 0x0000781E File Offset: 0x00005C1E
|
|
private void OnEnable()
|
|
{
|
|
this.isSupported = true;
|
|
}
|
|
|
|
// Token: 0x0600015E RID: 350 RVA: 0x00007827 File Offset: 0x00005C27
|
|
private void OnDestroy()
|
|
{
|
|
this.RemoveCreatedMaterials();
|
|
}
|
|
|
|
// Token: 0x0600015F RID: 351 RVA: 0x00007830 File Offset: 0x00005C30
|
|
private void RemoveCreatedMaterials()
|
|
{
|
|
while (this.createdMaterials.Count > 0)
|
|
{
|
|
Material material = this.createdMaterials[0];
|
|
this.createdMaterials.RemoveAt(0);
|
|
global::UnityEngine.Object.Destroy(material);
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000160 RID: 352 RVA: 0x00007872 File Offset: 0x00005C72
|
|
protected bool CheckSupport()
|
|
{
|
|
return this.CheckSupport(false);
|
|
}
|
|
|
|
// Token: 0x06000161 RID: 353 RVA: 0x0000787B File Offset: 0x00005C7B
|
|
public virtual bool CheckResources()
|
|
{
|
|
Debug.LogWarning("CheckResources () for " + this.ToString() + " should be overwritten.");
|
|
return this.isSupported;
|
|
}
|
|
|
|
// Token: 0x06000162 RID: 354 RVA: 0x0000789D File Offset: 0x00005C9D
|
|
protected void Start()
|
|
{
|
|
this.CheckResources();
|
|
}
|
|
|
|
// Token: 0x06000163 RID: 355 RVA: 0x000078A8 File Offset: 0x00005CA8
|
|
protected bool CheckSupport(bool needDepth)
|
|
{
|
|
this.isSupported = true;
|
|
this.supportHDRTextures = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf);
|
|
this.supportDX11 = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders;
|
|
if (!SystemInfo.supportsImageEffects)
|
|
{
|
|
this.NotSupported();
|
|
return false;
|
|
}
|
|
if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
|
|
{
|
|
this.NotSupported();
|
|
return false;
|
|
}
|
|
if (needDepth)
|
|
{
|
|
base.GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Token: 0x06000164 RID: 356 RVA: 0x00007927 File Offset: 0x00005D27
|
|
protected bool CheckSupport(bool needDepth, bool needHdr)
|
|
{
|
|
if (!this.CheckSupport(needDepth))
|
|
{
|
|
return false;
|
|
}
|
|
if (needHdr && !this.supportHDRTextures)
|
|
{
|
|
this.NotSupported();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Token: 0x06000165 RID: 357 RVA: 0x00007951 File Offset: 0x00005D51
|
|
public bool Dx11Support()
|
|
{
|
|
return this.supportDX11;
|
|
}
|
|
|
|
// Token: 0x06000166 RID: 358 RVA: 0x00007959 File Offset: 0x00005D59
|
|
protected void ReportAutoDisable()
|
|
{
|
|
Debug.LogWarning("The image effect " + this.ToString() + " has been disabled as it's not supported on the current platform.");
|
|
}
|
|
|
|
// Token: 0x06000167 RID: 359 RVA: 0x00007978 File Offset: 0x00005D78
|
|
private bool CheckShader(Shader s)
|
|
{
|
|
Debug.Log(string.Concat(new string[]
|
|
{
|
|
"The shader ",
|
|
s.ToString(),
|
|
" on effect ",
|
|
this.ToString(),
|
|
" is not part of the Unity 3.2+ effects suite anymore. For best performance and quality, please ensure you are using the latest Standard Assets Image Effects (Pro only) package."
|
|
}));
|
|
if (!s.isSupported)
|
|
{
|
|
this.NotSupported();
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x06000168 RID: 360 RVA: 0x000079D3 File Offset: 0x00005DD3
|
|
protected void NotSupported()
|
|
{
|
|
base.enabled = false;
|
|
this.isSupported = false;
|
|
}
|
|
|
|
// Token: 0x06000169 RID: 361 RVA: 0x000079E4 File Offset: 0x00005DE4
|
|
protected void DrawBorder(RenderTexture dest, Material material)
|
|
{
|
|
RenderTexture.active = dest;
|
|
bool flag = true;
|
|
GL.PushMatrix();
|
|
GL.LoadOrtho();
|
|
for (int i = 0; i < material.passCount; i++)
|
|
{
|
|
material.SetPass(i);
|
|
float num;
|
|
float num2;
|
|
if (flag)
|
|
{
|
|
num = 1f;
|
|
num2 = 0f;
|
|
}
|
|
else
|
|
{
|
|
num = 0f;
|
|
num2 = 1f;
|
|
}
|
|
float num3 = 0f;
|
|
float num4 = 1f / ((float)dest.width * 1f);
|
|
float num5 = 0f;
|
|
float num6 = 1f;
|
|
GL.Begin(7);
|
|
GL.TexCoord2(0f, num);
|
|
GL.Vertex3(num3, num5, 0.1f);
|
|
GL.TexCoord2(1f, num);
|
|
GL.Vertex3(num4, num5, 0.1f);
|
|
GL.TexCoord2(1f, num2);
|
|
GL.Vertex3(num4, num6, 0.1f);
|
|
GL.TexCoord2(0f, num2);
|
|
GL.Vertex3(num3, num6, 0.1f);
|
|
num3 = 1f - 1f / ((float)dest.width * 1f);
|
|
num4 = 1f;
|
|
num5 = 0f;
|
|
num6 = 1f;
|
|
GL.TexCoord2(0f, num);
|
|
GL.Vertex3(num3, num5, 0.1f);
|
|
GL.TexCoord2(1f, num);
|
|
GL.Vertex3(num4, num5, 0.1f);
|
|
GL.TexCoord2(1f, num2);
|
|
GL.Vertex3(num4, num6, 0.1f);
|
|
GL.TexCoord2(0f, num2);
|
|
GL.Vertex3(num3, num6, 0.1f);
|
|
num3 = 0f;
|
|
num4 = 1f;
|
|
num5 = 0f;
|
|
num6 = 1f / ((float)dest.height * 1f);
|
|
GL.TexCoord2(0f, num);
|
|
GL.Vertex3(num3, num5, 0.1f);
|
|
GL.TexCoord2(1f, num);
|
|
GL.Vertex3(num4, num5, 0.1f);
|
|
GL.TexCoord2(1f, num2);
|
|
GL.Vertex3(num4, num6, 0.1f);
|
|
GL.TexCoord2(0f, num2);
|
|
GL.Vertex3(num3, num6, 0.1f);
|
|
num3 = 0f;
|
|
num4 = 1f;
|
|
num5 = 1f - 1f / ((float)dest.height * 1f);
|
|
num6 = 1f;
|
|
GL.TexCoord2(0f, num);
|
|
GL.Vertex3(num3, num5, 0.1f);
|
|
GL.TexCoord2(1f, num);
|
|
GL.Vertex3(num4, num5, 0.1f);
|
|
GL.TexCoord2(1f, num2);
|
|
GL.Vertex3(num4, num6, 0.1f);
|
|
GL.TexCoord2(0f, num2);
|
|
GL.Vertex3(num3, num6, 0.1f);
|
|
GL.End();
|
|
}
|
|
GL.PopMatrix();
|
|
}
|
|
|
|
// Token: 0x040002FA RID: 762
|
|
protected bool supportHDRTextures = true;
|
|
|
|
// Token: 0x040002FB RID: 763
|
|
protected bool supportDX11;
|
|
|
|
// Token: 0x040002FC RID: 764
|
|
protected bool isSupported = true;
|
|
|
|
// Token: 0x040002FD RID: 765
|
|
private List<Material> createdMaterials = new List<Material>();
|
|
}
|
|
}
|