Advertisement
Agasper

Unity3D Surface Shader Example

May 26th, 2012
4,617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. Shader "AgasperShaders/TestShader" {
  2. Properties {
  3.     _Color ("Main Color", Color) = (1,1,1,1)
  4.     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
  5.     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
  6.     _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
  7.     _BumpMap ("Normalmap", 2D) = "bump" {}
  8.     _Amount ("Extrusion Amount", Range(-1,1)) = 0.5
  9. }
  10.    
  11. SubShader {
  12.     Tags { "RenderType"="Opaque" }
  13.  
  14. CGPROGRAM
  15.  
  16. #pragma surface surf BlinnPhong vertex:vert
  17.  
  18. sampler2D _MainTex;
  19. sampler2D _BumpMap;
  20. fixed4 _Color;
  21. half _Shininess;
  22. float _Amount;
  23.  
  24. void vert (inout appdata_full v) {
  25.   v.vertex.xyz += v.normal * _Amount * v.vertex.xyz;
  26. }
  27.  
  28.  
  29. struct Input {
  30.     float2 uv_MainTex;
  31.     float2 uv_BumpMap;
  32. };
  33.  
  34. void surf (Input IN, inout SurfaceOutput o) {
  35.     fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
  36.     o.Albedo = tex.rgb * _Color.rgb;
  37.     o.Gloss = tex.rgb;
  38.     o.Specular = _Shininess;
  39.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  40. }
  41.  
  42. ENDCG
  43. }
  44.  
  45. FallBack "Specular"
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement