dnnkeeper

GunShaderDeferred

Feb 1st, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. Shader "Custom/GunShaderDeferred" {
  2.     Properties {
  3.         _Color ("Color", Color) = (1,1,1,1)
  4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  6.         _Metallic ("Metallic", Range(0,1)) = 0.0
  7.     }
  8.     SubShader {
  9.         Tags { "RenderType"="Transparent"  "Queue"="Geometry+1"  }
  10.         LOD 200
  11.  
  12.         Pass {
  13.             Cull Back
  14.             ZTest Always
  15.  
  16.             Tags { "LightMode" = "Deferred" }
  17.  
  18.             CGPROGRAM
  19.             #pragma vertex vert_surf
  20.             #pragma fragment frag_surf
  21.  
  22.             #include "UnityCG.cginc"
  23.  
  24.             sampler2D _MainTex;
  25.      
  26.             struct Input {
  27.                 float2 uv_MainTex;
  28.             };
  29.      
  30.             // vertex-to-fragment interpolation data
  31.             struct v2f_surf {
  32.               float4 pos : SV_POSITION;
  33.               float2 pack0 : TEXCOORD0; // _MainTex
  34.               half3 worldNormal : TEXCOORD1;
  35.               float3 worldPos : TEXCOORD2;
  36.             };
  37.             float4 _MainTex_ST;
  38.  
  39.             // vertex shader
  40.             v2f_surf vert_surf (appdata_full v) {
  41.               v2f_surf o;
  42.               UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
  43.               o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  44.               o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
  45.               float3 worldPos = mul(_Object2World, v.vertex).xyz;
  46.               fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
  47.               o.worldPos = worldPos;
  48.               o.worldNormal = worldNormal;
  49.               return o;
  50.             }
  51.  
  52.             // fragment shader
  53.             void frag_surf (v2f_surf IN,
  54.                 out half4 outEmission : SV_Target3)
  55.             {
  56.               outEmission = float4(1,1,1,1);
  57.             }
  58.  
  59.             ENDCG
  60.         }
  61.  
  62.  
  63.         CGPROGRAM
  64.         // Physically based Standard lighting model, and enable shadows on all light types
  65.         #pragma surface surf Standard fullforwardshadows
  66.  
  67.         // Use shader model 3.0 target, to get nicer looking lighting
  68.         #pragma target 3.0
  69.  
  70.         sampler2D _MainTex;
  71.  
  72.         struct Input {
  73.             float2 uv_MainTex;
  74.         };
  75.  
  76.         half _Glossiness;
  77.         half _Metallic;
  78.         fixed4 _Color;
  79.  
  80.         void surf (Input IN, inout SurfaceOutputStandard o) {
  81.             // Albedo comes from a texture tinted by color
  82.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  83.             o.Albedo = c.rgb;
  84.             // Metallic and smoothness come from slider variables
  85.             o.Metallic = _Metallic;
  86.             o.Smoothness = _Glossiness;
  87.             o.Alpha = c.a;
  88.         }
  89.         ENDCG
  90.  
  91.     }
  92.  
  93.     Fallback "Mobile/VertexLit"
  94. }
Advertisement
Add Comment
Please, Sign In to add comment