Unity Shader 屏幕后处理反相
程序员文章站
2024-02-14 09:46:34
...
Shader代码如下:
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}//渲染纹理
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv:TEXCOORD0;
};
v2f vert(appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
return o;
}
fixed4 frag(v2f i) : SV_Target {
return fixed4(fixed3(1.0 - tex2D(_MainTex,i.uv).rgb),1.0);
}
ENDCG
}
}
FallBack Off
}
效果如下: