Unity3d shader裁剪圆形头像

来源:互联网 发布:计算机发展史知乎 编辑:程序博客网 时间:2024/05/18 01:09
Shader "Custom/D2" {Properties {_MainTex ("Base (RGB)", 2D) = "white" {}_Mask ("Base (RGB)", 2D) = "white" {}}SubShader {Tags{"Queue"="Transparent"}Pass{blend SrcAlpha OneMinusDstAlphaSetTexture [_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 200CGPROGRAM#pragma surface surf Lambert alphasampler2D _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"}


0 0
原创粉丝点击