Advertisement
Guest User

Untitled

a guest
Mar 21st, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.75 KB | None | 0 0
  1. /* This shader requires Unity Pro - if you are receiving an error
  2. that "No subshaders can run on this card", or if this shader is pink and
  3. doesn't present slots for the textures and properties, you will need to use a different shader
  4. that is compatible with your version of Unity
  5. */
  6.  
  7. Shader "River Shader"
  8. {
  9.     Properties
  10.     {
  11.         _BumpAmt  ("Distortion", range (0,128)) = 10
  12.         _MainTex ("Tint Color (RGB)", 2D) = "white" {}
  13.         _BumpMap ("Bumpmap (RGB)", 2D) = "bump" {}
  14.     }
  15.    
  16.     SubShader
  17.     {
  18.         Tags { "Queue" = "Transparent-110" }
  19.        
  20.         GrabPass
  21.         {                          
  22.             Name "BASE"
  23.             Tags { "LightMode" = "Always" }
  24.         }
  25.        
  26.         Pass
  27.         {
  28.             Name "BASE"
  29.             Tags { "LightMode" = "Always" }
  30.             Cull Back
  31.            
  32.         CGPROGRAM
  33.         #pragma exclude_renderers gles
  34.         #pragma fragment frag
  35.         #pragma fragmentoption ARB_precision_hint_fastest
  36.         #pragma fragmentoption ARB_fog_exp2
  37.         #include "UnityCG.cginc"
  38.  
  39.         sampler2D _GrabTexture : register(s0);
  40.         float4 _GrabTexture_TexelSize;
  41.         sampler2D _BumpMap : register(s1);
  42.         sampler2D _MainTex : register(s2);
  43.  
  44.         struct v2f
  45.         {
  46.             float4 uvgrab : TEXCOORD0;
  47.             float2 uvbump : TEXCOORD1;
  48.             float2 uvmain : TEXCOORD2;
  49.         };
  50.  
  51.         uniform float _BumpAmt;
  52.  
  53.         half4 frag( v2f i ) : COLOR
  54.         {
  55.             half2 bump = tex2D( _BumpMap, i.uvbump + _Time * 0.5f).rg * 2 - 1;
  56.             float2 offset = bump * _BumpAmt;
  57.  
  58.             offset *= _GrabTexture_TexelSize.xy;
  59.  
  60.             i.uvgrab.xy = offset * i.uvgrab.z + i.uvgrab.xy;
  61.            
  62.             half4 col = tex2Dproj( _GrabTexture, i.uvgrab.xyw );
  63.             half4 tint = tex2D( _MainTex, i.uvmain );
  64.            
  65.             return col * tint;
  66.         }
  67.  
  68.         ENDCG
  69.             SetTexture [_GrabTexture] {}    // Texture we grabbed in the pass above
  70.             SetTexture [_BumpMap] {}        // Perturbation bumpmap
  71.             SetTexture [_MainTex] {}        // Color tint
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement