Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/Darkness"
- {
- Properties
- {
- _MainTex("Bkg Texture", 2D) = "white"{}
- _FluidTex("Fluid Texture", 2D) = "white"{}
- _MaskTex("Mask Texture", 2D) = "white"{}
- _Color ("Zoom Color", Color) = (1,1,1,1)
- }
- SubShader
- {
- Lighting off
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- uniform sampler2D _MainTex;
- uniform sampler2D _FluidTex;
- uniform sampler2D _MaskTex;
- uniform float4 _Color;
- uniform half4 _FrameData;
- struct vIN
- {
- float4 vertex : POSITION;
- float2 texcoord0 : TEXCOORD0;
- float4 color : COLOR;
- };
- struct vOUT
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- half4 col : COLOR;
- };
- vOUT vert( vIN v )
- {
- vOUT o;
- o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
- o.tex = v.texcoord0;
- o.col = v.color;
- return o;
- }
- fixed4 frag( vOUT i ) : COLOR
- {
- fixed2 flowVector = fixed2( 0, 1 );
- fixed4 waterSample0 = tex2D( _FluidTex, i.tex - flowVector * (_FrameData.x) );
- fixed4 waterSample1 = tex2D( _FluidTex, i.tex - flowVector * (_FrameData.y) );
- fixed4 waterSample = lerp(waterSample0, waterSample1, _FrameData.z);
- fixed4 mask = tex2D( _MaskTex, i.tex );
- fixed4 bkg = tex2D( _MainTex, i.tex );
- fixed4 bkgDark = tex2D( _MainTex, i.tex + (waterSample.xy - half2(0.5,0.5)) * 0.015 );
- fixed4 col = bkg;
- fixed4 violet = fixed4( 1.0, 0.85, 0.95, 1 );
- fixed lum = Luminance( bkgDark.rgb );
- fixed inverse = 1 - bkgDark.x * 0.75;
- fixed4 dark = violet * (inverse * lum);
- fixed coef = mask.a;
- // Darkness
- fixed4 darkness = dark * coef + col * (1-coef);
- coef = _Color.a;
- col = bkg * coef + darkness * (1-coef);
- // Zoom
- fixed4 zoom = _Color * _Color.a;
- col += zoom;
- return col;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement