Advertisement
dnnkeeper

SurfaceDecalShader

Jan 20th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. Shader "Custom/TestSurfaceDecal" {
  2.     Properties {
  3.         _Color("Main Color", Color) = (1,1,1,1)
  4.         _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
  5.         _BumpMap("Normalmap", 2D) = "bump" {}
  6.         _SpecGlossMap("Specular", 2D) = "white" {}
  7.         _Gloss("Gloss", Range(0.0, 1.0)) = 1.0
  8.     }
  9.     SubShader {
  10.         Tags { "RenderType"="Transparent" "IgnoreProjector" = "True" "Queue" = "AlphaTest" }
  11.         LOD 200
  12.        
  13.         //Blend SrcAlpha OneMinusSrcAlpha
  14.  
  15.         CGPROGRAM
  16.         // Physically based Standard lighting model, and enable shadows on all light types
  17.         #pragma surface surf StandardSpecular fullforwardshadows decal:blend//alpha:blend
  18.  
  19.         // Use shader model 3.0 target, to get nicer looking lighting
  20.         #pragma target 3.0
  21.  
  22.         sampler2D _MainTex;
  23.         sampler2D _BumpMap;
  24.         sampler2D _SpecGlossMap;
  25.         float _Gloss;
  26.         fixed4 _Color;
  27.  
  28.         struct Input {
  29.             float2 uv_MainTex;
  30.             float2 uv_BumpMap;
  31.             float4 color: Color;
  32.         };
  33.  
  34.         void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
  35.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color  * IN.color;
  36.             o.Albedo = c.rgb;
  37.             o.Alpha = c.a;
  38.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  39.             half4 specGloss = tex2D(_SpecGlossMap, IN.uv_MainTex);
  40.             o.Specular = specGloss.rgb;
  41.             o.Smoothness = specGloss.a*_Gloss;
  42.         }
  43.         ENDCG
  44.     }
  45.     FallBack "Decal/Transparent Diffuse"
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement