Skip to content

Instantly share code, notes, and snippets.

@fadookie
Created January 14, 2015 11:59
Show Gist options
  • Save fadookie/9c4496ae68adb995046e to your computer and use it in GitHub Desktop.
Save fadookie/9c4496ae68adb995046e to your computer and use it in GitHub Desktop.
Water screen shader w/ time scrubbing
// http://unitycoder.com/blog/2012/02/26/water-splash-screen-effect-shader/
Shader "Custom/waterscreen1" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Water ("WaterBlur (BW)", 2D) = "white" {}
_Slide ("SliderTime", Range(0, 0.2)) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
float2 uv_Water;
};
sampler2D _MainTex;
sampler2D _Water;
uniform float _Slide;
void surf (Input IN, inout SurfaceOutput o)
{
float time = _Slide + _Time.x;
float fader = smoothstep( 1, 0.0, time*7);
half4 waterflow = tex2D(_Water, float2(IN.uv_Water.x,IN.uv_Water.y+(time*5)))*fader;
half4 col1 = tex2D(_MainTex, float2(IN.uv_MainTex.x+waterflow.r,IN.uv_MainTex.y+waterflow.r))*1;
o.Albedo = col1.rgb;
// o.Albedo = fixed3(time);
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment