91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
// Token: 0x02000065 RID: 101
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(Camera))]
|
|
[AddComponentMenu("Image Effects/Edge Detection/Crease Shading")]
|
|
public class CreaseShading : PostEffectsBase
|
|
{
|
|
// Token: 0x06000116 RID: 278 RVA: 0x0000BD40 File Offset: 0x0000A140
|
|
public override bool CheckResources()
|
|
{
|
|
base.CheckSupport(true);
|
|
this.blurMaterial = base.CheckShaderAndCreateMaterial(this.blurShader, this.blurMaterial);
|
|
this.depthFetchMaterial = base.CheckShaderAndCreateMaterial(this.depthFetchShader, this.depthFetchMaterial);
|
|
this.creaseApplyMaterial = base.CheckShaderAndCreateMaterial(this.creaseApplyShader, this.creaseApplyMaterial);
|
|
if (!this.isSupported)
|
|
{
|
|
base.ReportAutoDisable();
|
|
}
|
|
return this.isSupported;
|
|
}
|
|
|
|
// Token: 0x06000117 RID: 279 RVA: 0x0000BDB4 File Offset: 0x0000A1B4
|
|
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (!this.CheckResources())
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
return;
|
|
}
|
|
int width = source.width;
|
|
int height = source.height;
|
|
float num = 1f * (float)width / (1f * (float)height);
|
|
float num2 = 0.001953125f;
|
|
RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0);
|
|
RenderTexture renderTexture = RenderTexture.GetTemporary(width / 2, height / 2, 0);
|
|
Graphics.Blit(source, temporary, this.depthFetchMaterial);
|
|
Graphics.Blit(temporary, renderTexture);
|
|
for (int i = 0; i < this.softness; i++)
|
|
{
|
|
RenderTexture renderTexture2 = RenderTexture.GetTemporary(width / 2, height / 2, 0);
|
|
this.blurMaterial.SetVector("offsets", new Vector4(0f, this.spread * num2, 0f, 0f));
|
|
Graphics.Blit(renderTexture, renderTexture2, this.blurMaterial);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
renderTexture = renderTexture2;
|
|
renderTexture2 = RenderTexture.GetTemporary(width / 2, height / 2, 0);
|
|
this.blurMaterial.SetVector("offsets", new Vector4(this.spread * num2 / num, 0f, 0f, 0f));
|
|
Graphics.Blit(renderTexture, renderTexture2, this.blurMaterial);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
renderTexture = renderTexture2;
|
|
}
|
|
this.creaseApplyMaterial.SetTexture("_HrDepthTex", temporary);
|
|
this.creaseApplyMaterial.SetTexture("_LrDepthTex", renderTexture);
|
|
this.creaseApplyMaterial.SetFloat("intensity", this.intensity);
|
|
Graphics.Blit(source, destination, this.creaseApplyMaterial);
|
|
RenderTexture.ReleaseTemporary(temporary);
|
|
RenderTexture.ReleaseTemporary(renderTexture);
|
|
}
|
|
|
|
// Token: 0x0400024D RID: 589
|
|
public float intensity = 0.5f;
|
|
|
|
// Token: 0x0400024E RID: 590
|
|
public int softness = 1;
|
|
|
|
// Token: 0x0400024F RID: 591
|
|
public float spread = 1f;
|
|
|
|
// Token: 0x04000250 RID: 592
|
|
public Shader blurShader;
|
|
|
|
// Token: 0x04000251 RID: 593
|
|
private Material blurMaterial;
|
|
|
|
// Token: 0x04000252 RID: 594
|
|
public Shader depthFetchShader;
|
|
|
|
// Token: 0x04000253 RID: 595
|
|
private Material depthFetchMaterial;
|
|
|
|
// Token: 0x04000254 RID: 596
|
|
public Shader creaseApplyShader;
|
|
|
|
// Token: 0x04000255 RID: 597
|
|
private Material creaseApplyMaterial;
|
|
}
|
|
}
|