Shader/Shader - SurfaceShader

18-3타들어가는

소나무꼴 2020. 4. 15. 16:23
Shader "Custom/18-3"
{
	Properties
	{
		_MainTex("Texture", 2D) = "white" {}
		_MaskTex("Mask", 2D) = "white" {}
		_Cut("Cut", Range(0, 1)) = 0
			[HDR]_OutColor("outColor", Color) = (1,1,1,1)
	}
	SubShader
	{
		Tags { "RenderType" = "Transparent" "Queue" = "Transparent"}
		// 1st
		zwrite on
		ColorMask 0
		cull off
		CGPROGRAM
		#pragma surface surf nolight noambient noforwardadd nolightmap novertexlights noshadow
		struct Input
		{
			float4 color:COLOR;
		};
		void surf(Input IN, inout SurfaceOutput o)
		{
		}
		float4 Lightingnolight(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
		{
			return float4(0, 0, 0, 0);
		}
		ENDCG

			// 2nt
			zwrite off
			CGPROGRAM
			#pragma surface surf Lambert alpha:fade
			sampler2D _MainTex;
			sampler2D _MaskTex;
			float4 _OutColor;
			float _Cut;
			struct Input
			{
				float2 uv_MainTex;
				float2 uv_MaskTex;
			};

			void surf(Input IN, inout SurfaceOutput o)
			{
				fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
				fixed4 m = tex2D(_MaskTex, IN.uv_MaskTex);
				o.Albedo = c.rgb;

				_Cut = sin(_Time.y)*0.05;

				float _Alpha;
				if (m.r >= _Cut)
					_Alpha = 1;
				else 
					_Alpha = 0;

				float outline;
				if (m.r >= _Cut * 1.3)
					outline = 0;
				else
					outline = 1;
				o.Emission = _OutColor.rgb * outline;


				o.Alpha = _Alpha;
			}
			ENDCG

	}
	FallBack "Diffuse"
}

'Shader > Shader - SurfaceShader' 카테고리의 다른 글

18-6 외곡  (0) 2020.04.23
18-4 풀흔들기  (0) 2020.04.22
18-2  (0) 2020.04.15
18-1-2Pass Alpha  (0) 2020.04.15
17-1알파블렌딩  (0) 2020.04.15