Unity之图片高光处理

在片断着色器里处理

fixed4 frag (v2f i) : SV_Target
{
	half2 tc0 = i.texcoord + half2(-_Offset.x, -_Offset.y);
	half2 tc1 = i.texcoord + half2(         0.0, -_Offset.y);
	half2 tc2 = i.texcoord + half2(-_Offset.x,          0.0);
	half2 tc3 = i.texcoord + half2(_Offset.x,          0.0);
	half2 tc4 = i.texcoord + half2(         0.0, _Offset.y);
	half2 tc5 = i.texcoord + half2(_Offset.x, _Offset.y);


	fixed4 col0 = tex2D(_MainTex, tc0);
	fixed4 col1 = tex2D(_MainTex, tc1);
	fixed4 col2 = tex2D(_MainTex, tc2);
	fixed4 col3 = tex2D(_MainTex, tc3);
	fixed4 col4 = tex2D(_MainTex, tc4);
	fixed4 col5 = tex2D(_MainTex, tc5);




	fixed4 col = tex2D(_MainTex, i.texcoord);
	col=col+ (col3 + col4 + col5)-(col0 + col1 + col2) ;
	UNITY_APPLY_FOG(i.fogCoord, col);
	UNITY_OPAQUE_ALPHA(col.a);
	return col;
}


展开阅读全文

没有更多推荐了,返回首页