Advertisement
Boomsma95

ShaderTemplate Sort of Fix

Jul 18th, 2013
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. Shader "${ShaderName}"
  2. {
  3. Properties
  4. {
  5. ${ShaderProperties}
  6. }
  7.  
  8. SubShader
  9. {
  10. Tags
  11. {
  12. ${Tags}
  13. }
  14. ${GrabPass}
  15.  
  16. ${Options}
  17.  
  18. CGPROGRAM
  19. #pragma surface surf BlinnPhongEditor ${SurfaceFlags}
  20. ${ShaderPragma}
  21.  
  22.  
  23. ${ShaderVariableNames}
  24. struct EditorSurfaceOutput {
  25. half3 Albedo;
  26. half3 Normal;
  27. half3 Emission;
  28. half3 Gloss;
  29. half Specular;
  30. half Alpha;
  31. half4 Custom;
  32. };
  33.  
  34. inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
  35. {
  36. ${LightingFunctionPrePass}
  37. }
  38.  
  39. inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
  40. {
  41. half3 h = normalize (lightDir + viewDir);
  42.  
  43. half diff = max (0, dot ( lightDir, s.Normal ));
  44.  
  45. float nh = max (0, dot (s.Normal, h));
  46. float spec = pow (nh, s.Specular*128.0);
  47.  
  48. half4 res;
  49. res.rgb = _LightColor0.rgb * diff;
  50. res.w = spec * Luminance (_LightColor0.rgb);
  51. res *= atten * 2.0;
  52.  
  53. return LightingBlinnPhongEditor_PrePass( s, res );
  54. }
  55.  
  56. struct Input {
  57. ${StructInputs}
  58. };
  59.  
  60. void vert (inout appdata_full v) {
  61. ${VertexShader}
  62. ${VertexShaderMods}
  63. }
  64.  
  65.  
  66. void surf (Input IN, inout EditorSurfaceOutput o) {
  67. o.Normal = float3(0.0,0.0,1.0);
  68. o.Alpha = 1.0;
  69. o.Albedo = 0.0;
  70. o.Emission = 0.0;
  71. o.Gloss = 0.0;
  72. o.Specular = 0.0;
  73. o.Custom = 0.0;
  74.  
  75. ${SurfaceShader}
  76. o.Normal = normalize(o.Normal);
  77. }
  78. ENDCG
  79. }
  80. Fallback "${Fallback}"
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement