Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. Shader "Bumped Diffuse Colour Specular" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _MainTex ("Diffuse (RGB) Aplha (A)", 2D) = "white" {}
  5. _SpecularTex ("Specular (RGB)", 2D) = "gray" {}
  6. _BumpMap ("Normal (Normal)", 2D) = "bump" {}
  7. _Cutoff ("Alpha Cut-Off Threshold", Range(0,1)) = 0.5
  8. _Gloss ("Gloss Value", Range(0,1)) = 0.5
  9. }
  10.  
  11. SubShader{
  12. Tags { "RenderType" = "Opaque" }
  13.  
  14. CGPROGRAM
  15.  
  16. struct SurfaceOutputColourSpec {
  17. fixed3 Albedo;
  18. fixed3 Normal;
  19. fixed3 Specular;
  20. fixed3 Emission;
  21. fixed Gloss;
  22. fixed Alpha;
  23. };
  24.  
  25. float _Cutoff;
  26. inline fixed4 LightingColourSpec (SurfaceOutputColourSpec s, fixed3 lightDir, fixed3 viewDir, fixed atten)
  27. {
  28. clip(s.Alpha - _Cutoff);
  29.  
  30. viewDir = normalize(viewDir);
  31. lightDir = normalize(lightDir);
  32. float NdotL = saturate(dot(s.Normal, lightDir));
  33. float3 h = normalize(lightDir + viewDir);
  34.  
  35. float specBase = saturate(dot(s.Normal, h));
  36.  
  37. float3 spec = s.Specular * pow(specBase, s.Gloss * 128) * _LightColor0.rgb;
  38.  
  39. fixed4 c;
  40. c.rgb = ((s.Albedo * _LightColor0.rgb * NdotL) + (spec)) * (atten * 2);
  41. c.a = s.Alpha;
  42. return c;
  43. }
  44.  
  45. #pragma surface surf ColourSpec
  46.  
  47. struct Input
  48. {
  49. float2 uv_MainTex;
  50. };
  51.  
  52. sampler2D _MainTex, _SpecularTex, _BumpMap;
  53.  
  54. float _Gloss;
  55. void surf (Input IN, inout SurfaceOutputColourSpec o)
  56. {
  57. o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
  58. o.Alpha = tex2D(_MainTex, IN.uv_MainTex).a;
  59. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
  60. o.Specular = tex2D(_SpecularTex, IN.uv_MainTex).rgb;
  61. o.Gloss = _Gloss;
  62. }
  63. ENDCG
  64. }
  65. FallBack "Transparent/Cutout/VertexLit"
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement