scripts
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.ImageEffects
|
||||
{
|
||||
// Token: 0x0200006E RID: 110
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Edge Detection/Edge Detection")]
|
||||
public class EdgeDetection : PostEffectsBase
|
||||
{
|
||||
// Token: 0x06000133 RID: 307 RVA: 0x0000DFA0 File Offset: 0x0000C3A0
|
||||
public override bool CheckResources()
|
||||
{
|
||||
base.CheckSupport(true);
|
||||
this.edgeDetectMaterial = base.CheckShaderAndCreateMaterial(this.edgeDetectShader, this.edgeDetectMaterial);
|
||||
if (this.mode != this.oldMode)
|
||||
{
|
||||
this.SetCameraFlag();
|
||||
}
|
||||
this.oldMode = this.mode;
|
||||
if (!this.isSupported)
|
||||
{
|
||||
base.ReportAutoDisable();
|
||||
}
|
||||
return this.isSupported;
|
||||
}
|
||||
|
||||
// Token: 0x06000134 RID: 308 RVA: 0x0000E007 File Offset: 0x0000C407
|
||||
private new void Start()
|
||||
{
|
||||
this.oldMode = this.mode;
|
||||
}
|
||||
|
||||
// Token: 0x06000135 RID: 309 RVA: 0x0000E018 File Offset: 0x0000C418
|
||||
private void SetCameraFlag()
|
||||
{
|
||||
if (this.mode == EdgeDetection.EdgeDetectMode.SobelDepth || this.mode == EdgeDetection.EdgeDetectMode.SobelDepthThin)
|
||||
{
|
||||
base.GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
|
||||
}
|
||||
else if (this.mode == EdgeDetection.EdgeDetectMode.TriangleDepthNormals || this.mode == EdgeDetection.EdgeDetectMode.RobertsCrossDepthNormals)
|
||||
{
|
||||
base.GetComponent<Camera>().depthTextureMode |= DepthTextureMode.DepthNormals;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000136 RID: 310 RVA: 0x0000E07F File Offset: 0x0000C47F
|
||||
private void OnEnable()
|
||||
{
|
||||
this.SetCameraFlag();
|
||||
}
|
||||
|
||||
// Token: 0x06000137 RID: 311 RVA: 0x0000E088 File Offset: 0x0000C488
|
||||
[ImageEffectOpaque]
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
if (!this.CheckResources())
|
||||
{
|
||||
Graphics.Blit(source, destination);
|
||||
return;
|
||||
}
|
||||
Vector2 vector = new Vector2(this.sensitivityDepth, this.sensitivityNormals);
|
||||
this.edgeDetectMaterial.SetVector("_Sensitivity", new Vector4(vector.x, vector.y, 1f, vector.y));
|
||||
this.edgeDetectMaterial.SetFloat("_BgFade", this.edgesOnly);
|
||||
this.edgeDetectMaterial.SetFloat("_SampleDistance", this.sampleDist);
|
||||
this.edgeDetectMaterial.SetVector("_BgColor", this.edgesOnlyBgColor);
|
||||
this.edgeDetectMaterial.SetFloat("_Exponent", this.edgeExp);
|
||||
this.edgeDetectMaterial.SetFloat("_Threshold", this.lumThreshold);
|
||||
Graphics.Blit(source, destination, this.edgeDetectMaterial, (int)this.mode);
|
||||
}
|
||||
|
||||
// Token: 0x040002B0 RID: 688
|
||||
public EdgeDetection.EdgeDetectMode mode = EdgeDetection.EdgeDetectMode.SobelDepthThin;
|
||||
|
||||
// Token: 0x040002B1 RID: 689
|
||||
public float sensitivityDepth = 1f;
|
||||
|
||||
// Token: 0x040002B2 RID: 690
|
||||
public float sensitivityNormals = 1f;
|
||||
|
||||
// Token: 0x040002B3 RID: 691
|
||||
public float lumThreshold = 0.2f;
|
||||
|
||||
// Token: 0x040002B4 RID: 692
|
||||
public float edgeExp = 1f;
|
||||
|
||||
// Token: 0x040002B5 RID: 693
|
||||
public float sampleDist = 1f;
|
||||
|
||||
// Token: 0x040002B6 RID: 694
|
||||
public float edgesOnly;
|
||||
|
||||
// Token: 0x040002B7 RID: 695
|
||||
public Color edgesOnlyBgColor = Color.white;
|
||||
|
||||
// Token: 0x040002B8 RID: 696
|
||||
public Shader edgeDetectShader;
|
||||
|
||||
// Token: 0x040002B9 RID: 697
|
||||
private Material edgeDetectMaterial;
|
||||
|
||||
// Token: 0x040002BA RID: 698
|
||||
private EdgeDetection.EdgeDetectMode oldMode = EdgeDetection.EdgeDetectMode.SobelDepthThin;
|
||||
|
||||
// Token: 0x0200006F RID: 111
|
||||
public enum EdgeDetectMode
|
||||
{
|
||||
// Token: 0x040002BC RID: 700
|
||||
TriangleDepthNormals,
|
||||
// Token: 0x040002BD RID: 701
|
||||
RobertsCrossDepthNormals,
|
||||
// Token: 0x040002BE RID: 702
|
||||
SobelDepth,
|
||||
// Token: 0x040002BF RID: 703
|
||||
SobelDepthThin,
|
||||
// Token: 0x040002C0 RID: 704
|
||||
TriangleLuminance
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user