// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
//12.3 边缘检测
Shader "Unlit/Chapter12-EdgeDetection"
{
Properties
{
//主纹理对应输入纹理
_MainTex ("Base(RGB)", 2D) = "white" {}
//边缘线强度
_EdgeOnly("Edge Only",Float) = 1.0
//边缘线颜色
_EdgeColor("Edge Color",Color) = (0,0,0,0)
//背景颜色
_BackgroundColor("Background Color",Color) = (1,1,1,1)
}
SubShader
{
Pass
{
//关闭深度测试和写入
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
//声明对应变量
sampler2D _MainTex;
//XXX_TexelSize是unity提供的访问XXX纹理对应的每个纹素的大小,由于卷轴需要对相邻区域内的纹理进行采样,因此需要_TexelSize计算各个相邻区域的纹理坐标
half4 _MainTex_TexelSize;