186 lines
5.1 KiB
C#
186 lines
5.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x0200004B RID: 75
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(Camera))]
|
|
[AddComponentMenu("Image Effects/Other/Antialiasing")]
|
|
public class Antialiasing : PostEffectsBase
|
|
{
|
|
// Token: 0x060000C9 RID: 201 RVA: 0x00007CD8 File Offset: 0x000060D8
|
|
public Material CurrentAAMaterial()
|
|
{
|
|
Material material;
|
|
switch (this.mode)
|
|
{
|
|
case AAMode.FXAA2:
|
|
material = this.materialFXAAII;
|
|
break;
|
|
case AAMode.FXAA3Console:
|
|
material = this.materialFXAAIII;
|
|
break;
|
|
case AAMode.FXAA1PresetA:
|
|
material = this.materialFXAAPreset2;
|
|
break;
|
|
case AAMode.FXAA1PresetB:
|
|
material = this.materialFXAAPreset3;
|
|
break;
|
|
case AAMode.NFAA:
|
|
material = this.nfaa;
|
|
break;
|
|
case AAMode.SSAA:
|
|
material = this.ssaa;
|
|
break;
|
|
case AAMode.DLAA:
|
|
material = this.dlaa;
|
|
break;
|
|
default:
|
|
material = null;
|
|
break;
|
|
}
|
|
return material;
|
|
}
|
|
|
|
// Token: 0x060000CA RID: 202 RVA: 0x00007D74 File Offset: 0x00006174
|
|
public override bool CheckResources()
|
|
{
|
|
base.CheckSupport(false);
|
|
this.materialFXAAPreset2 = base.CreateMaterial(this.shaderFXAAPreset2, this.materialFXAAPreset2);
|
|
this.materialFXAAPreset3 = base.CreateMaterial(this.shaderFXAAPreset3, this.materialFXAAPreset3);
|
|
this.materialFXAAII = base.CreateMaterial(this.shaderFXAAII, this.materialFXAAII);
|
|
this.materialFXAAIII = base.CreateMaterial(this.shaderFXAAIII, this.materialFXAAIII);
|
|
this.nfaa = base.CreateMaterial(this.nfaaShader, this.nfaa);
|
|
this.ssaa = base.CreateMaterial(this.ssaaShader, this.ssaa);
|
|
this.dlaa = base.CreateMaterial(this.dlaaShader, this.dlaa);
|
|
if (!this.ssaaShader.isSupported)
|
|
{
|
|
base.NotSupported();
|
|
base.ReportAutoDisable();
|
|
}
|
|
return this.isSupported;
|
|
}
|
|
|
|
// Token: 0x060000CB RID: 203 RVA: 0x00007E54 File Offset: 0x00006254
|
|
public void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (!this.CheckResources())
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
return;
|
|
}
|
|
if (this.mode == AAMode.FXAA3Console && this.materialFXAAIII != null)
|
|
{
|
|
this.materialFXAAIII.SetFloat("_EdgeThresholdMin", this.edgeThresholdMin);
|
|
this.materialFXAAIII.SetFloat("_EdgeThreshold", this.edgeThreshold);
|
|
this.materialFXAAIII.SetFloat("_EdgeSharpness", this.edgeSharpness);
|
|
Graphics.Blit(source, destination, this.materialFXAAIII);
|
|
}
|
|
else if (this.mode == AAMode.FXAA1PresetB && this.materialFXAAPreset3 != null)
|
|
{
|
|
Graphics.Blit(source, destination, this.materialFXAAPreset3);
|
|
}
|
|
else if (this.mode == AAMode.FXAA1PresetA && this.materialFXAAPreset2 != null)
|
|
{
|
|
source.anisoLevel = 4;
|
|
Graphics.Blit(source, destination, this.materialFXAAPreset2);
|
|
source.anisoLevel = 0;
|
|
}
|
|
else if (this.mode == AAMode.FXAA2 && this.materialFXAAII != null)
|
|
{
|
|
Graphics.Blit(source, destination, this.materialFXAAII);
|
|
}
|
|
else if (this.mode == AAMode.SSAA && this.ssaa != null)
|
|
{
|
|
Graphics.Blit(source, destination, this.ssaa);
|
|
}
|
|
else if (this.mode == AAMode.DLAA && this.dlaa != null)
|
|
{
|
|
source.anisoLevel = 0;
|
|
RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height);
|
|
Graphics.Blit(source, temporary, this.dlaa, 0);
|
|
Graphics.Blit(temporary, destination, this.dlaa, (!this.dlaaSharp) ? 1 : 2);
|
|
RenderTexture.ReleaseTemporary(temporary);
|
|
}
|
|
else if (this.mode == AAMode.NFAA && this.nfaa != null)
|
|
{
|
|
source.anisoLevel = 0;
|
|
this.nfaa.SetFloat("_OffsetScale", this.offsetScale);
|
|
this.nfaa.SetFloat("_BlurRadius", this.blurRadius);
|
|
Graphics.Blit(source, destination, this.nfaa, (!this.showGeneratedNormals) ? 0 : 1);
|
|
}
|
|
else
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
}
|
|
}
|
|
|
|
// Token: 0x04000163 RID: 355
|
|
public AAMode mode = AAMode.FXAA3Console;
|
|
|
|
// Token: 0x04000164 RID: 356
|
|
public bool showGeneratedNormals;
|
|
|
|
// Token: 0x04000165 RID: 357
|
|
public float offsetScale = 0.2f;
|
|
|
|
// Token: 0x04000166 RID: 358
|
|
public float blurRadius = 18f;
|
|
|
|
// Token: 0x04000167 RID: 359
|
|
public float edgeThresholdMin = 0.05f;
|
|
|
|
// Token: 0x04000168 RID: 360
|
|
public float edgeThreshold = 0.2f;
|
|
|
|
// Token: 0x04000169 RID: 361
|
|
public float edgeSharpness = 4f;
|
|
|
|
// Token: 0x0400016A RID: 362
|
|
public bool dlaaSharp;
|
|
|
|
// Token: 0x0400016B RID: 363
|
|
public Shader ssaaShader;
|
|
|
|
// Token: 0x0400016C RID: 364
|
|
private Material ssaa;
|
|
|
|
// Token: 0x0400016D RID: 365
|
|
public Shader dlaaShader;
|
|
|
|
// Token: 0x0400016E RID: 366
|
|
private Material dlaa;
|
|
|
|
// Token: 0x0400016F RID: 367
|
|
public Shader nfaaShader;
|
|
|
|
// Token: 0x04000170 RID: 368
|
|
private Material nfaa;
|
|
|
|
// Token: 0x04000171 RID: 369
|
|
public Shader shaderFXAAPreset2;
|
|
|
|
// Token: 0x04000172 RID: 370
|
|
private Material materialFXAAPreset2;
|
|
|
|
// Token: 0x04000173 RID: 371
|
|
public Shader shaderFXAAPreset3;
|
|
|
|
// Token: 0x04000174 RID: 372
|
|
private Material materialFXAAPreset3;
|
|
|
|
// Token: 0x04000175 RID: 373
|
|
public Shader shaderFXAAII;
|
|
|
|
// Token: 0x04000176 RID: 374
|
|
private Material materialFXAAII;
|
|
|
|
// Token: 0x04000177 RID: 375
|
|
public Shader shaderFXAAIII;
|
|
|
|
// Token: 0x04000178 RID: 376
|
|
private Material materialFXAAIII;
|
|
}
|
|
}
|