You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ImageEffectGeneral : PostEffectsBase{ |
|
public Shader scannerShader; |
|
private Material scannerMaterial; |
|
public Material material |
|
{ |
|
get |
|
{ |
|
// 检查是否生成对应材质 |
|
scannerMaterial = CheckShaderAndCreateMaterial(scannerShader, scannerMaterial); |
|
return scannerMaterial; |
|
} |
|
} |
|
//定义相关数据调整 |
|
public string dataTags = ""; |
|
public float dataScale = 1.0f; |
|
public string dataColorTags = ""; |
|
public Color dataColor = Color.white; |
|
public new void Start() |
|
{ |
|
//如果需要提前规定Camera获取深度纹理或者法线纹理,需要提前声明 |
|
//GetComponent<Camera>().depthTextureMode = DepthTextureMode.DepthNormals; |
|
} |
|
|
|
void OnRenderImage(RenderTexture src, RenderTexture dest) |
|
{ |
|
//GetComponent<Camera>().depthTextureMode = DepthTextureMode.DepthNormals; |
|
if (material != null) |
|
{ |
|
//需要传入的数据,需要在Shader中定义好对应变量名称,作为传入依据。 |
|
material.SetFloat(dataTags, dataScale); |
|
material.SetColor(dataColorTags, dataColor); |
|
Graphics.Blit(src, dest, material); |
|
} |
|
else |
|
{ |
|
Graphics.Blit(src, dest); |
|
} |
|
} |
|
}
|
|
|