카테고리 없음

14-4 2pass 그림자

소나무꼴 2020. 4. 6. 23:30
Shader "Custom/14-4"
{
    Properties
    {
        //_Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        //_Glossiness ("Smoothness", Range(0,1)) = 0.5
        //_Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200
		cull front
		// 1 pass
        CGPROGRAM        
        #pragma surface surf NoLight vertex:vert noshadow noambient
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        UNITY_INSTANCING_BUFFER_START(Props)
        UNITY_INSTANCING_BUFFER_END(Props)

		void vert(inout appdata_full v)
		{
			v.vertex.xyz = v.vertex.xyz + v.normal.xyz*-0.01;
		}

		void surf(Input IN, inout SurfaceOutput o)
        {
        }

		float4 LightingNoLight(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
		{
			return float4(0, 0, 0, 1);
		}

        ENDCG

		cull back
		// 2 pass
		CGPROGRAM
		#pragma surface surf Lambert
		#pragma target 3.0

		sampler2D _MainTex;

		struct Input
		{
			float2 uv_MainTex;
		};

		UNITY_INSTANCING_BUFFER_START(Props)
		UNITY_INSTANCING_BUFFER_END(Props)

		void surf(Input IN, inout SurfaceOutput o)
		{
			fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
		}

		ENDCG
    }
    FallBack "Diffuse"
}

//appdata_base: 포지션, 노멀, 하나의 텍스처 좌표
//appdata_tan : 포지션, 탄젠트, 노멀, 하나의 텍스처 좌표
//appdata_full : 포지션, 탄젠트, 노멀, 네 개의 텍스처 좌표, 컬러