Advertisement
dnnkeeper

VertexGradient shader

Mar 25th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. Shader "Custom/VertexGradient" {
  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.         _GradientStartingHeight("GradientStartingHeight", Range(-1,1)) = -1.0
  8.     }
  9.     SubShader {
  10.         Tags { "RenderType"="Opaque" }
  11.         LOD 200
  12.        
  13.         CGPROGRAM
  14.         // Physically based Standard lighting model, and enable shadows on all light types
  15.         #pragma surface surf Standard fullforwardshadows vertex:vert
  16.  
  17.         // Use shader model 3.0 target, to get nicer looking lighting
  18.         #pragma target 3.0
  19.  
  20.         sampler2D _MainTex;
  21.  
  22.         struct Input {
  23.             float2 uv_MainTex;
  24.             float4 vertColor : COLOR;
  25.         };
  26.    
  27.         half _Glossiness;
  28.         half _Metallic;
  29.         fixed4 _Color;
  30.  
  31.         half _GradientStartingHeight;
  32.         void vert (inout appdata_full v) {
  33.             v.color = (v.vertex.y-_GradientStartingHeight);
  34.         }
  35.         void surf (Input IN, inout SurfaceOutputStandard o) {
  36.             // Albedo comes from a texture tinted by color
  37.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color * IN.vertColor;
  38.             o.Albedo = c.rgb;
  39.             // Metallic and smoothness come from slider variables
  40.             o.Metallic = _Metallic;
  41.             o.Smoothness = _Glossiness;
  42.             o.Alpha = c.a;
  43.         }
  44.         ENDCG
  45.     }
  46.     FallBack "Diffuse"
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement