카테고리 없음

14-7-Diffuse Warping

소나무꼴 2020. 4. 7. 00:14
Shader "Custom/14-7"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
		_bumpMap("NormalMap", 2D) = "white"{}
		_RampTex("RampTex (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

		CGPROGRAM
		#pragma surface surf Warp noambient
		#pragma target 3.0

		sampler2D _MainTex;
		sampler2D _bumpMap;
		sampler2D _RampTex;

		struct Input
		{
			float2 uv_MainTex;
			float2 uv_BumpMap;
		};

		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.Normal = UnpackNormal(tex2D(_bumpMap, IN.uv_BumpMap));
			o.Albedo = c.rgb;
			o.Alpha = c.a;

		}

		float4 LightingWarp(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
		{
			float nodtl = dot(s.Normal, -lightDir) * 0.5 + 0.5;
			float4 ramp = tex2D(_RampTex, float2(nodtl, 0.9));

			float4 final;
			final.rgb = s.Albedo.rgb * ramp.rgb;
			final.a = s.Alpha;

			return final;//nodtl;
		}

		ENDCG
    }
    FallBack "Diffuse"
}