Unity3d shader裁剪圆形头像

跟風遠走 提交于 2019-12-03 16:16:21
Shader "Custom/D2" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_Mask ("Base (RGB)", 2D) = "white" {}
	}
	SubShader {
		Tags{"Queue"="Transparent"}
		Pass{		

			blend SrcAlpha OneMinusDstAlpha
		
			SetTexture [_MainTex]{
				combine  texture 
			}
			
			SetTexture [_Mask]{
				combine  Previous , texture
			}
		}
		
	} 

}






Shader "Custom/D3" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_banjin ("Rodius",Range(0.01,0.25)) = 0.25
	}
	SubShader {
		Tags { "RenderType"="Opaque" "Queue"="Transparent"}
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert alpha

		sampler2D _MainTex;
		float _banjin;

		struct Input {
			float2 uv_MainTex;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			float2 uv_XY = IN.uv_MainTex;
			float2 middle = float2(0.5,0.5);
			float2 cha = uv_XY - middle;
			float value = cha.x * cha.x + cha.y * cha.y;

			half4 c = tex2D (_MainTex, uv_XY);
			
			if(value > _banjin){
				o.Albedo = float3(1,1,1);
				o.Alpha = 0;
			}else{
				o.Albedo = c.rgb;
				o.Alpha = c.a;
			}
			
		}
		ENDCG
	} 
	FallBack "Diffuse"
}


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!