冯乐乐的《Unity Shader入门精要》附带项目,其中部分shader已经修改测试
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.
 
 

42 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ImageScannerEffect : PostEffectsBase
{
public Shader scannerShader;
private Material scannerMaterial;
public Material material
{
get
{
// 检查是否生成对应材质
scannerMaterial = CheckShaderAndCreateMaterial(scannerShader, scannerMaterial);
return scannerMaterial;
}
}
//定义相关数据调整
public float dataScale = 1.0f;
public float dataLength = 1.0f;
public Color dataColor = Color.white;
public Texture dataTex;
public float tillY;
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
//GetComponent<Camera>().depthTextureMode = DepthTextureMode.DepthNormals;
if (material != null)
{
material.SetFloat("_DepthParam", dataScale);
material.SetColor("_DepthColor", dataColor);
material.SetFloat("_DepthLength", dataLength);
material.SetTexture("_MaskTex", dataTex);
material.SetFloat("_MaskTexTillY", tillY);
Graphics.Blit(src, dest, material);
}
else
{
Graphics.Blit(src, dest);
}
}
}