1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| Shader "keyle/Basic_Phong" { Properties { _MainTint ("Diffuse Tint", Color) = (1,1,1,1) _MainTex ("Base (RGB)", 2D) = "white" {} _SpecularColor ("Specular Color", Color) = (1,1,1,1) _SpecPower ("Specular Power", Range(0,30)) = 1 } SubShader { Tags { "RenderType"="Opaque" } LOD 100
CGPROGRAM #pragma surface surf CustomBlinnPhong
float4 _SpecularColor; sampler2D _MainTex; float4 _MainTint; float _SpecPower;
fixed4 LightingCustomBlinnPhong (SurfaceOutput s, fixed3 lightDir,half3 viewDir, fixed atten) { float NdotL = max(0,dot(s.Normal, lightDir)); float3 halfVector = normalize(lightDir + viewDir); float NdotH = max(0, dot(s.Normal, halfVector)); float spec = pow(NdotH, _SpecPower) * _SpecularColor; float4 c; c.rgb = (s.Albedo * _LightColor0.rgb * NdotL) + (_LightColor0.rgb * _SpecularColor.rgb * spec) * atten; c.a = s.Alpha; return c; }
struct Input { float2 uv_MainTex; };
void surf(Input IN,inout SurfaceOutput o) { float4 c = tex2D(_MainTex,IN.uv_MainTex); o.Albedo = c.rgb; o.Alpha = c.a; }
ENDCG } }
|