Advertisement
dnnkeeper

TestSurfaceDecal_Blend

Jan 24th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. Shader "Custom/TestSurfaceDecalBlend" {
  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.         //_SpecColor("SpecColor", Color) = (1,1,1,1)
  8.         _Specular("Specular", Range(0.0, 1.0)) = 1.0
  9.         _Gloss("Gloss", Range(0.0, 1.0)) = 1.0
  10.     }
  11.     SubShader {
  12.         Tags { "RenderType" = "Opaque" "Queue" = "Geometry+1" "ForceNoShadowCasting" = "True" }
  13.         LOD 200
  14.         //Offset -1, -1
  15.        
  16.         //Blend SrcAlpha OneMinusSrcAlpha
  17.         //Blend One One
  18.         //Blend SrcColor OneMinusSrcColor
  19.         //Blend SrcColor One
  20.  
  21.         GrabPass{ "_SharedGrabTexture" }
  22.  
  23.         CGPROGRAM
  24.         // Physically based Standard lighting model, and enable shadows on all light types
  25.         #pragma surface surf StandardSpecular vertex:vert decal:add //alpha:blend
  26.  
  27.         // Use shader model 3.0 target, to get nicer looking lighting
  28.         #pragma target 3.0
  29.  
  30.         //sampler2D _SharedGrabTexture;
  31.  
  32.         sampler2D _MainTex;
  33.  
  34.         sampler2D _BumpMap;
  35.  
  36.         sampler2D _SpecGlossMap;
  37.  
  38.         float _Specular, _Gloss;
  39.  
  40.         fixed4 _Color;
  41.  
  42.         struct Input {
  43.             float2 uv_MainTex;
  44.             float2 uv_BumpMap;
  45.             float4 grabUV;
  46.             float4 color: Color;
  47.         };
  48.  
  49.         void vert(inout appdata_full v, out Input o) {
  50.             float4 hpos = mul(UNITY_MATRIX_MVP, v.vertex);
  51.             o.uv_MainTex = v.texcoord;
  52.             o.uv_BumpMap = v.texcoord1;
  53.             o.grabUV = ComputeGrabScreenPos(hpos);
  54.             o.color = v.color;
  55.         }
  56.  
  57.         void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
  58.             //fixed4 grab = tex2Dproj(_SharedGrabTexture, UNITY_PROJ_COORD(IN.grabUV))  * _Color;
  59.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color  * IN.color;
  60.             o.Albedo = c.rgb *  c.a;
  61.             o.Alpha = c.a;
  62.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  63.             half4 specGloss = tex2D(_SpecGlossMap, IN.uv_MainTex);
  64.            
  65.             o.Specular = specGloss.rgb *  c.a * _Specular;
  66.             o.Smoothness = specGloss.a * _Gloss;
  67.             //clip((c.a-0.5)*2);
  68.                
  69.         }
  70.         ENDCG
  71.     }
  72.     FallBack "Decal/Transparent Diffuse"
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement