Advertisement
Guest User

Lszt shader

a guest
Oct 7th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. Shader "Custom/Darkness"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex("Bkg Texture", 2D) = "white"{}
  6.         _FluidTex("Fluid Texture", 2D) = "white"{}
  7.         _MaskTex("Mask Texture", 2D) = "white"{}
  8.         _Color ("Zoom Color", Color) = (1,1,1,1)
  9.     }
  10.     SubShader
  11.     {
  12.         Lighting off
  13.         Pass
  14.         {
  15.             CGPROGRAM
  16.             #pragma vertex vert
  17.             #pragma fragment frag
  18.            
  19.             #include "UnityCG.cginc"
  20.            
  21.             uniform sampler2D _MainTex;
  22.             uniform sampler2D _FluidTex;
  23.             uniform sampler2D _MaskTex;
  24.             uniform float4 _Color;
  25.            
  26.             uniform half4 _FrameData;
  27.            
  28.             struct vIN
  29.             {
  30.                 float4 vertex : POSITION;
  31.                 float2 texcoord0 : TEXCOORD0;
  32.                 float4 color : COLOR;
  33.             };
  34.            
  35.             struct vOUT
  36.             {
  37.                 float4 pos : SV_POSITION;
  38.                 float2 tex : TEXCOORD0;
  39.                 half4 col : COLOR;
  40.             };
  41.            
  42.             vOUT vert( vIN v )
  43.             {
  44.                 vOUT o;
  45.                 o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
  46.                 o.tex = v.texcoord0;
  47.                 o.col = v.color;
  48.                 return o;
  49.             }
  50.            
  51.             fixed4 frag( vOUT i ) : COLOR
  52.             {
  53.                 fixed2 flowVector = fixed2( 0, 1 );            
  54.                 fixed4 waterSample0 = tex2D( _FluidTex, i.tex - flowVector * (_FrameData.x) );
  55.                 fixed4 waterSample1 = tex2D( _FluidTex, i.tex - flowVector * (_FrameData.y) );
  56.                 fixed4 waterSample = lerp(waterSample0, waterSample1, _FrameData.z);
  57.                 fixed4 mask = tex2D( _MaskTex, i.tex );
  58.                 fixed4 bkg = tex2D( _MainTex, i.tex );
  59.                 fixed4 bkgDark = tex2D( _MainTex, i.tex + (waterSample.xy - half2(0.5,0.5)) * 0.015 );
  60.                 fixed4 col = bkg;
  61.                 fixed4 violet = fixed4( 1.0, 0.85, 0.95, 1 );
  62.                 fixed lum = Luminance( bkgDark.rgb );
  63.                 fixed inverse = 1 - bkgDark.x * 0.75;
  64.                 fixed4 dark = violet * (inverse * lum);
  65.                 fixed coef = mask.a;
  66.                 // Darkness
  67.                 fixed4 darkness = dark * coef + col * (1-coef);
  68.                 coef = _Color.a;
  69.                 col = bkg * coef + darkness * (1-coef);
  70.                 // Zoom
  71.                 fixed4 zoom = _Color * _Color.a;
  72.                 col += zoom;
  73.                 return col;
  74.             }
  75.            
  76.            
  77.             ENDCG
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement